brought solaar-cli in sync with the latest gui code
This commit is contained in:
parent
f64942b51d
commit
dd24ed5fe0
|
|
@ -80,36 +80,38 @@ def _find_device(receiver, name, may_be_receiver=False):
|
||||||
def _print_receiver(receiver, verbose=False):
|
def _print_receiver(receiver, verbose=False):
|
||||||
paired_count = receiver.count()
|
paired_count = receiver.count()
|
||||||
if not verbose:
|
if not verbose:
|
||||||
print ("-: Unifying Receiver [%s:%s] with %d devices" % (receiver.path, receiver.serial, paired_count))
|
print ("Unifying Receiver [%s:%s] with %d devices" % (receiver.path, receiver.serial, paired_count))
|
||||||
return
|
return
|
||||||
|
|
||||||
print ("-: Unifying Receiver")
|
print ("Unifying Receiver")
|
||||||
print (" Device path :", receiver.path)
|
print (" Device path :", receiver.path)
|
||||||
|
print (" USB id : 046d:%s" % receiver.product_id)
|
||||||
print (" Serial :", receiver.serial)
|
print (" Serial :", receiver.serial)
|
||||||
for f in receiver.firmware:
|
for f in receiver.firmware:
|
||||||
print (" %-11s: %s" % (f.kind, f.version))
|
print (" %-11s: %s" % (f.kind, f.version))
|
||||||
|
|
||||||
print (" Has", paired_count, "paired device(s) out of a maximum of", receiver.max_devices)
|
print (" Has", paired_count, "paired device(s) out of a maximum of", receiver.max_devices, ".")
|
||||||
|
|
||||||
from logitech.unifying_receiver import hidpp10
|
from logitech.unifying_receiver import hidpp10
|
||||||
notification_flags = hidpp10.get_notification_flags(receiver)
|
notification_flags = hidpp10.get_notification_flags(receiver)
|
||||||
if notification_flags is not None:
|
if notification_flags is not None:
|
||||||
if notification_flags:
|
if notification_flags:
|
||||||
notification_names = hidpp10.NOTIFICATION_FLAG.flag_names(notification_flags)
|
notification_names = hidpp10.NOTIFICATION_FLAG.flag_names(notification_flags)
|
||||||
print (" Notifications: 0x%06X = %s." % (notification_flags, ', '.join(notification_names)))
|
print (" Notifications: 0x%06X = %s" % (notification_flags, ', '.join(notification_names)))
|
||||||
else:
|
else:
|
||||||
print (" Notifications: (none).")
|
print (" Notifications: (none)")
|
||||||
|
|
||||||
if receiver.unifying_supported:
|
if receiver.unifying_supported:
|
||||||
activity = receiver.read_register(0x2B3)
|
activity = receiver.read_register(0x2B3)
|
||||||
if activity:
|
if activity:
|
||||||
activity = [(d, ord(activity[d - 1:d])) for d in range(1, receiver.max_devices)]
|
activity = [(d, ord(activity[d - 1:d])) for d in range(1, receiver.max_devices)]
|
||||||
print (" Device activity counters:", ', '.join(('%d=%d' % (d, a)) for d, a in activity if a > 0))
|
activity_text = ', '.join(('%d=%d' % (d, a)) for d, a in activity if a > 0)
|
||||||
|
print (" Device activity counters:", activity_text or '(empty)')
|
||||||
|
|
||||||
|
|
||||||
def _print_device(dev, verbose=False):
|
def _print_device(dev, verbose=False):
|
||||||
p = dev.protocol
|
assert dev
|
||||||
state = '' if p > 0 else 'offline'
|
state = '' if dev.ping() else 'offline'
|
||||||
|
|
||||||
if not verbose:
|
if not verbose:
|
||||||
print ("%d: %s [%s:%s]" % (dev.number, dev.name, dev.codename, dev.serial), state)
|
print ("%d: %s [%s:%s]" % (dev.number, dev.name, dev.codename, dev.serial), state)
|
||||||
|
|
@ -118,10 +120,10 @@ def _print_device(dev, verbose=False):
|
||||||
print ("%d: %s" % (dev.number, dev.name))
|
print ("%d: %s" % (dev.number, dev.name))
|
||||||
print (" Codename :", dev.codename)
|
print (" Codename :", dev.codename)
|
||||||
print (" Kind :", dev.kind)
|
print (" Kind :", dev.kind)
|
||||||
if p == 0:
|
if dev.protocol == 0:
|
||||||
print (" Protocol : unknown (device is offline)")
|
print (" Protocol : unknown (device is offline)")
|
||||||
else:
|
else:
|
||||||
print (" Protocol : HID++ %1.1f" % p)
|
print (" Protocol : HID++ %1.1f" % dev.protocol)
|
||||||
print (" Polling rate :", dev.polling_rate, "ms")
|
print (" Polling rate :", dev.polling_rate, "ms")
|
||||||
print (" Wireless PID :", dev.wpid)
|
print (" Wireless PID :", dev.wpid)
|
||||||
print (" Serial number:", dev.serial)
|
print (" Serial number:", dev.serial)
|
||||||
|
|
@ -129,19 +131,20 @@ def _print_device(dev, verbose=False):
|
||||||
print (" %-11s:" % fw.kind, (fw.name + ' ' + fw.version).strip())
|
print (" %-11s:" % fw.kind, (fw.name + ' ' + fw.version).strip())
|
||||||
|
|
||||||
if dev.power_switch_location:
|
if dev.power_switch_location:
|
||||||
print (" The power switch is located on the", dev.power_switch_location)
|
print (" The power switch is located on the %s." % dev.power_switch_location)
|
||||||
|
|
||||||
from logitech.unifying_receiver import hidpp10, hidpp20, special_keys
|
from logitech.unifying_receiver import hidpp10, hidpp20, special_keys
|
||||||
|
|
||||||
notification_flags = hidpp10.get_notification_flags(dev)
|
if dev.online:
|
||||||
if notification_flags is not None:
|
notification_flags = hidpp10.get_notification_flags(dev)
|
||||||
if notification_flags:
|
if notification_flags is not None:
|
||||||
notification_names = hidpp10.NOTIFICATION_FLAG.flag_names(notification_flags)
|
if notification_flags:
|
||||||
print (" Notifications: 0x%06X = %s." % (notification_flags, ', '.join(notification_names)))
|
notification_names = hidpp10.NOTIFICATION_FLAG.flag_names(notification_flags)
|
||||||
else:
|
print (" Notifications: 0x%06X = %s." % (notification_flags, ', '.join(notification_names)))
|
||||||
print (" Notifications: (none).")
|
else:
|
||||||
|
print (" Notifications: (none).")
|
||||||
|
|
||||||
if p > 0:
|
if dev.online:
|
||||||
if dev.features:
|
if dev.features:
|
||||||
print (" Supports %d HID++ 2.0 features:" % len(dev.features))
|
print (" Supports %d HID++ 2.0 features:" % len(dev.features))
|
||||||
for index, feature in enumerate(dev.features):
|
for index, feature in enumerate(dev.features):
|
||||||
|
|
@ -151,19 +154,25 @@ def _print_device(dev, verbose=False):
|
||||||
flags = hidpp20.FEATURE_FLAG.flag_names(flags)
|
flags = hidpp20.FEATURE_FLAG.flag_names(flags)
|
||||||
print (" %2d: %-22s {%04X} %s" % (index, feature, feature, ', '.join(flags)))
|
print (" %2d: %-22s {%04X} %s" % (index, feature, feature, ', '.join(flags)))
|
||||||
|
|
||||||
|
if dev.online:
|
||||||
if dev.keys:
|
if dev.keys:
|
||||||
print (" Has %d reprogrammable keys:" % len(dev.keys))
|
print (" Has %d reprogrammable keys:" % len(dev.keys))
|
||||||
for k in dev.keys:
|
for k in dev.keys:
|
||||||
flags = special_keys.KEY_FLAG.flag_names(k.flags)
|
flags = special_keys.KEY_FLAG.flag_names(k.flags)
|
||||||
print (" %2d: %-26s => %-27s %s" % (k.index, k.key, k.task, ', '.join(flags)))
|
print (" %2d: %-26s => %-27s %s" % (k.index, k.key, k.task, ', '.join(flags)))
|
||||||
|
|
||||||
if p > 0:
|
if dev.online:
|
||||||
battery = hidpp20.get_battery(dev)
|
battery = hidpp20.get_battery(dev)
|
||||||
if battery is None:
|
if battery is None:
|
||||||
battery = hidpp10.get_battery(dev)
|
battery = hidpp10.get_battery(dev)
|
||||||
if battery:
|
if battery is not None:
|
||||||
charge, status = battery
|
from logitech.unifying_receiver.common import NamedInt as _NamedInt
|
||||||
print (" Battery is %d%% charged," % charge, status)
|
level, status = battery
|
||||||
|
if isinstance(level, _NamedInt):
|
||||||
|
text = str(level)
|
||||||
|
else:
|
||||||
|
text = '%d%%' % level
|
||||||
|
print (" Battery: %s, %s," % (text, status))
|
||||||
else:
|
else:
|
||||||
print (" Battery status unavailable.")
|
print (" Battery status unavailable.")
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue