From 8154cd759f5d0575f7ba50ecbdda12b2ec21b100 Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Wed, 6 Mar 2024 17:43:13 -0500 Subject: [PATCH] device: use status attribute for notification_flags --- lib/logitech_receiver/status.py | 9 +++++---- lib/solaar/listener.py | 2 +- lib/solaar/ui/window.py | 3 +-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/logitech_receiver/status.py b/lib/logitech_receiver/status.py index 87d7391f..2104ca67 100644 --- a/lib/logitech_receiver/status.py +++ b/lib/logitech_receiver/status.py @@ -32,7 +32,7 @@ _hidpp10 = hidpp10.Hidpp10() ALERT = NamedInts(NONE=0x00, NOTIFICATION=0x01, SHOW_WINDOW=0x02, ATTENTION=0x04, ALL=0xFF) -KEYS = NamedInts(NOTIFICATION_FLAGS=6, ERROR=7) +KEYS = NamedInts(ERROR=7) def attach_to(device, changed_callback): @@ -54,9 +54,9 @@ class ReceiverStatus(dict): def __init__(self, receiver, changed_callback): assert receiver self._receiver = receiver - assert changed_callback self._changed_callback = changed_callback + self.notification_flags = None self.lock_open = False self.discovering = False @@ -87,7 +87,7 @@ class ReceiverStatus(dict): class DeviceStatus(dict): """Holds the 'runtime' status of a peripheral - Currently _active, battery, link_encrypted -- dict entries are being moved to attributs + Currently _active, battery, link_encrypted, notification_flags -- dict entries are being moved to attributs Updates mostly come from incoming notification events from the device itself. """ @@ -99,6 +99,7 @@ class DeviceStatus(dict): self._active = None # is the device active? self.battery = None self.link_encrypted = None + self.notification_flags = None def to_string(self): return self.battery.to_str() if self.battery is not None else "" @@ -153,7 +154,7 @@ class DeviceStatus(dict): # get cleared when the device is turned off (but not when the device # goes idle, and we can't tell the difference right now). if d.protocol < 2.0: - self[KEYS.NOTIFICATION_FLAGS] = d.enable_connection_notifications() + self.notification_flags = d.enable_connection_notifications() # battery information may have changed so try to read it now self.read_battery() diff --git a/lib/solaar/listener.py b/lib/solaar/listener.py index 6b443497..beff6885 100644 --- a/lib/solaar/listener.py +++ b/lib/solaar/listener.py @@ -74,7 +74,7 @@ class ReceiverListener(_listener.EventsListener): "Receiver on %s might not support connection notifications, GUI might not show its devices", self.receiver.path, ) - self.receiver.status[_status.KEYS.NOTIFICATION_FLAGS] = nfs + self.receiver.notification_flags = nfs self.receiver.notify_devices() self._status_changed(self.receiver) diff --git a/lib/solaar/ui/window.py b/lib/solaar/ui/window.py index 9c491906..9892dd9e 100644 --- a/lib/solaar/ui/window.py +++ b/lib/solaar/ui/window.py @@ -22,7 +22,6 @@ from gi.repository.GObject import TYPE_PYOBJECT from logitech_receiver import hidpp10_constants as _hidpp10_constants from logitech_receiver.common import NamedInt as _NamedInt from logitech_receiver.common import NamedInts as _NamedInts -from logitech_receiver.status import KEYS as _K from solaar import NAME from solaar.i18n import _, ngettext @@ -575,7 +574,7 @@ def _update_details(button): elif device.kind is None or device.online: yield (" %s" % _("Firmware"), "...") - flag_bits = device.status.get(_K.NOTIFICATION_FLAGS) + flag_bits = device.status.notification_flags if flag_bits is not None: flag_names = ( ("(%s)" % _("none"),) if flag_bits == 0 else _hidpp10_constants.NOTIFICATION_FLAG.flag_names(flag_bits)