From dfd3d10c2ef86375a2c60de2696c5be23cf655f8 Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Tue, 12 Mar 2024 12:18:14 -0400 Subject: [PATCH] device: optimize some functions in FeaturesArray --- lib/logitech_receiver/hidpp20.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/logitech_receiver/hidpp20.py b/lib/logitech_receiver/hidpp20.py index ada0b749..7747a985 100644 --- a/lib/logitech_receiver/hidpp20.py +++ b/lib/logitech_receiver/hidpp20.py @@ -91,6 +91,9 @@ class FeaturesArray(dict): if feature is not None: return feature elif self._check(): + feature = self.inverse.get(index) + if feature is not None: + return feature response = self.device.feature_request(FEATURE.FEATURE_SET, 0x10, index) if response: feature = FEATURE[_unpack("!H", response[:2])[0]] @@ -117,6 +120,9 @@ class FeaturesArray(dict): if index is not None: return index elif self._check(): + index = super().get(feature) + if index is not None: + return index response = self.device.request(0x0000, _pack("!H", feature)) if response: index = response[0]