Merge branch 'master' into fix_2827
This commit is contained in:
commit
985e1fe889
|
|
@ -467,9 +467,7 @@ class Device:
|
|||
return False
|
||||
|
||||
if enable:
|
||||
set_flag_bits = (
|
||||
NotificationFlag.BATTERY_STATUS | NotificationFlag.UI | NotificationFlag.CONFIGURATION_COMPLETE
|
||||
).value
|
||||
set_flag_bits = NotificationFlag.BATTERY_STATUS | NotificationFlag.UI | NotificationFlag.CONFIGURATION_COMPLETE
|
||||
else:
|
||||
set_flag_bits = 0
|
||||
ok = _hidpp10.set_notification_flags(self, set_flag_bits)
|
||||
|
|
|
|||
|
|
@ -224,6 +224,25 @@ class DeviceFeature(Flag):
|
|||
https://drive.google.com/file/d/0BxbRzx7vEV7eNDBheWY0UHM5dEU/view?usp=sharing
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def flag_names(cls, flag_bits: int) -> List[str]:
|
||||
"""Extract the names of the flags from the integer."""
|
||||
indexed = {item.value: item.name for item in cls}
|
||||
|
||||
flag_names = []
|
||||
unknown_bits = flag_bits
|
||||
for k in indexed:
|
||||
# Ensure that the key (flag value) is a power of 2 (a single bit flag)
|
||||
assert bin(k).count("1") == 1
|
||||
if k & flag_bits == k:
|
||||
unknown_bits &= ~k
|
||||
flag_names.append(indexed[k].replace("_", " ").lower())
|
||||
|
||||
# Yield any remaining unknown bits
|
||||
if unknown_bits != 0:
|
||||
flag_names.append(f"unknown:{unknown_bits:06X}")
|
||||
return flag_names
|
||||
|
||||
RESERVED1 = 0x010000
|
||||
SPECIAL_BUTTONS = 0x020000
|
||||
ENHANCED_KEY_USAGE = 0x040000
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ def run(receivers, args, find_receiver, _ignore):
|
|||
|
||||
# check if it's necessary to set the notification flags
|
||||
old_notification_flags = _hidpp10.get_notification_flags(receiver) or 0
|
||||
if not (old_notification_flags & hidpp10_constants.NOTIFICATION_FLAG.wireless):
|
||||
_hidpp10.set_notification_flags(receiver, old_notification_flags | hidpp10_constants.NOTIFICATION_FLAG.wireless)
|
||||
if not (old_notification_flags & hidpp10_constants.NotificationFlag.WIRELESS):
|
||||
_hidpp10.set_notification_flags(receiver, old_notification_flags | hidpp10_constants.NotificationFlag.WIRELESS)
|
||||
|
||||
# get all current devices
|
||||
known_devices = [dev.number for dev in receiver]
|
||||
|
|
@ -121,7 +121,7 @@ def run(receivers, args, find_receiver, _ignore):
|
|||
if n:
|
||||
receiver.handle.notifications_hook(n)
|
||||
|
||||
if not (old_notification_flags & hidpp10_constants.NOTIFICATION_FLAG.wireless):
|
||||
if not (old_notification_flags & hidpp10_constants.NotificationFlag.WIRELESS):
|
||||
# only clear the flags if they weren't set before, otherwise a
|
||||
# concurrently running Solaar app might stop working properly
|
||||
_hidpp10.set_notification_flags(receiver, old_notification_flags)
|
||||
|
|
|
|||
|
|
@ -131,14 +131,14 @@ def _print_device(dev, num=None):
|
|||
notification_flags = _hidpp10.get_notification_flags(dev)
|
||||
if notification_flags is not None:
|
||||
if notification_flags:
|
||||
notification_names = hidpp10_constants.NOTIFICATION_FLAG.flag_names(notification_flags)
|
||||
notification_names = hidpp10_constants.NotificationFlag.flag_names(notification_flags)
|
||||
print(f" Notifications: {', '.join(notification_names)} (0x{notification_flags:06X}).")
|
||||
else:
|
||||
print(" Notifications: (none).")
|
||||
device_features = _hidpp10.get_device_features(dev)
|
||||
if device_features is not None:
|
||||
if device_features:
|
||||
device_features_names = hidpp10_constants.DEVICE_FEATURES.flag_names(device_features)
|
||||
device_features_names = hidpp10_constants.DeviceFeature.flag_names(device_features)
|
||||
print(f" Features: {', '.join(device_features_names)} (0x{device_features:06X})")
|
||||
else:
|
||||
print(" Features: (none)")
|
||||
|
|
|
|||
Loading…
Reference in New Issue