From 773dac56b691365820bf85190e72b00ce2d1fb3d Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Mon, 5 Dec 2022 09:35:13 -0500 Subject: [PATCH] solaar: improve handling of wheel notifications --- lib/logitech_receiver/notifications.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/logitech_receiver/notifications.py b/lib/logitech_receiver/notifications.py index 98ad6825..3e3de9df 100644 --- a/lib/logitech_receiver/notifications.py +++ b/lib/logitech_receiver/notifications.py @@ -433,13 +433,14 @@ def _process_feature_notification(device, status, n, feature): periods = flags & 0x0f _log.info('%s: WHEEL: res: %d periods: %d delta V:%-3d', device, high_res, periods, delta_v) elif (n.address == 0x10): - ratchet = ord(n.data[:1]) & 0x01 + ratchet = n.data[0] if _log.isEnabledFor(_INFO): _log.info('%s: WHEEL: ratchet: %d', device, ratchet) - from solaar.ui.config_panel import record_setting # prevent circular import - setting = next((s for s in device.settings if s.name == _st.ScrollRatchet.name), None) - if setting: - record_setting(device, setting, [2 if ratchet else 1]) + if ratchet < 2: # don't process messages with unusual ratchet values + from solaar.ui.config_panel import record_setting # prevent circular import + setting = next((s for s in device.settings if s.name == _st.ScrollRatchet.name), None) + if setting: + record_setting(device, setting, [2 if ratchet else 1]) else: if _log.isEnabledFor(_INFO): _log.info('%s: unknown WHEEL %s', device, n)