Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor notification handling #2737

Merged
merged 4 commits into from
Jan 2, 2025

Conversation

MattHag
Copy link
Collaborator

@MattHag MattHag commented Dec 31, 2024

Related #2273

@MattHag MattHag marked this pull request as draft December 31, 2024 15:39
@MattHag MattHag force-pushed the refactor_event_handling branch from 8a8b835 to fcc8599 Compare January 1, 2025 15:57
@MattHag MattHag marked this pull request as ready for review January 1, 2025 15:57
@MattHag MattHag requested a review from pfps January 1, 2025 16:10
@MattHag MattHag force-pushed the refactor_event_handling branch from fcc8599 to c91b574 Compare January 1, 2025 16:26
@pfps
Copy link
Collaborator

pfps commented Jan 1, 2025

There appears to be some sort of timing error on startup

idefix Solaar> bin/solaar -dd
2025-01-01 11:22:30,083,083     INFO [MainThread] solaar.gtk: version 1.1.14-44-g3c0930fe, language en_US (UTF-8)
2025-01-01 11:22:30,088,088     INFO [MainThread] solaar.dbus: connected to system dbus, watching for suspend/resume events
2025-01-01 11:22:30,129,129     INFO [MainThread] solaar.ui.desktop_notifications: starting desktop notifications
2025-01-01 11:22:30,198,198     INFO [MainThread] solaar.listener: starting receiver listening threads
2025-01-01 11:22:30,354,354     INFO [MainThread] hidapi.udev_impl: Found device /dev/hidraw3 BID 0003 VID 0000046D PID 0000C52B HID++ True True USB 2 2
2025-01-01 11:22:30,354,354     INFO [MainThread] solaar.listener: receiver event add DeviceInfo(path='/dev/hidraw3', bus_id=3, vendor_id='046D', product_id='C52B', interface=2, driver='logitech-djreceiver', manufacturer=None, product=None, serial='', release=None, isDevice=None, hidpp_short=True, hidpp_long=True)
2025-01-01 11:22:30,355,355     INFO [MainThread] hidapi.udev_impl: OPEN PATH /dev/hidraw3
2025-01-01 11:22:30,355,355     INFO [MainThread] logitech_receiver.base: New lock 15
2025-01-01 11:22:30,368,368     INFO [SolaarListener:hidraw3] logitech_receiver.listener: started with <UnifyingReceiver(/dev/hidraw3,T15)> (15)
2025-01-01 11:22:30,369,369     INFO [SolaarListener:hidraw3] solaar.listener: <UnifyingReceiver(/dev/hidraw3,T15)>: notifications listener has started (15)
2025-01-01 11:22:30,369,369     INFO [SolaarListener:hidraw3] logitech_receiver.base: New lock <_ThreadedHandle(/dev/hidraw3)>
2025-01-01 11:22:30,372,372     INFO [MainThread] hidapi.udev_impl: Found device /dev/hidraw1 BID 0005 VID 0000046D PID 0000B023 HID++ False True USB None None
2025-01-01 11:22:30,372,372     INFO [MainThread] solaar.listener: receiver event add DeviceInfo(path='/dev/hidraw1', bus_id=5, vendor_id='046D', product_id='B023', interface=None, driver='logitech-hidpp-device', manufacturer=None, product=None, serial='ca:91:d3:d1:50:0a', release=None, isDevice=True, hidpp_short=False, hidpp_long=True)
2025-01-01 11:22:30,372,372     INFO [MainThread] hidapi.udev_impl: OPEN PATH /dev/hidraw1
2025-01-01 11:22:30,373,373     INFO [MainThread] logitech_receiver.base: New lock 16
2025-01-01 11:22:30,373,373     INFO [SolaarListener:hidraw3] logitech_receiver.receiver: <UnifyingReceiver(/dev/hidraw3,T15)>: receiver notifications enabled => ['software present', 'wireless']
2025-01-01 11:22:30,382,382     INFO [SolaarListener:hidraw3] solaar.listener: status_changed <UnifyingReceiver(/dev/hidraw3,T15)>: present (0) 
2025-01-01 11:22:30,456,456     INFO [SolaarListener:hidraw3] hidapi.udev_impl: OPEN PATH /dev/hidraw4
2025-01-01 11:22:30,457,457     INFO [SolaarListener:hidraw3] logitech_receiver.receiver: <UnifyingReceiver(/dev/hidraw3,T15)>: found new device 1 (4082)
2025-01-01 11:22:30,457,457     INFO [SolaarListener:hidraw3] solaar.listener: connection Notification(10,1,41,04,728240) for device wpid 4082 kind mouse serial 198E3EB8
2025-01-01 11:22:30,457,457     INFO [SolaarListener:hidraw3] solaar.listener: status_changed <UnifyingReceiver(/dev/hidraw3,T15)>: present (0) 
2025-01-01 11:22:30,458,458     INFO [SolaarListener:hidraw3] logitech_receiver.base: New lock 17
2025-01-01 11:22:30,461,461  WARNING [SolaarListener:hidraw3] logitech_receiver.notifications: <Device(1,4082,MX Master 3 Wireless Mouse,198E3EB8)>: feature notification but features not set up: 41 Notification(10,1,41,04,728240)
2025-01-01 11:22:30,526,526     INFO [SolaarListener:hidraw3] hidapi.udev_impl: OPEN PATH /dev/hidraw5
2025-01-01 11:22:30,526,526     INFO [SolaarListener:hidraw3] logitech_receiver.receiver: <UnifyingReceiver(/dev/hidraw3,T15)>: found new device 2 (2011)
2025-01-01 11:22:30,526,526     INFO [SolaarListener:hidraw3] solaar.listener: connection Notification(10,2,41,04,711120) for device wpid 2011 kind keyboard serial 81111951
2025-01-01 11:22:30,526,526     INFO [SolaarListener:hidraw3] solaar.listener: status_changed <UnifyingReceiver(/dev/hidraw3,T15)>: present (0) 
2025-01-01 11:22:30,526,526  WARNING [SolaarListener:hidraw3] logitech_receiver.notifications: <Device(2,2011,Wireless Keyboard K520,81111951)>: unrecognized Notification(10,2,41,04,711120)
2025-01-01 11:22:30,597,597     INFO [SolaarListener:hidraw3] hidapi.udev_impl: OPEN PATH /dev/hidraw6
2025-01-01 11:22:30,597,597     INFO [SolaarListener:hidraw3] logitech_receiver.receiver: <UnifyingReceiver(/dev/hidraw3,T15)>: found new device 3 (4066)
2025-01-01 11:22:30,598,598     INFO [SolaarListener:hidraw3] solaar.listener: connection Notification(10,3,41,04,716640) for device wpid 4066 kind keyboard serial 112C46EA
2025-01-01 11:22:30,598,598     INFO [SolaarListener:hidraw3] solaar.listener: status_changed <UnifyingReceiver(/dev/hidraw3,T15)>: present (0) 
2025-01-01 11:22:30,598,598     INFO [SolaarListener:hidraw3] logitech_receiver.base: New lock 19
2025-01-01 11:22:30,601,601  WARNING [SolaarListener:hidraw3] logitech_receiver.notifications: <Device(3,4066,Craft Advanced Keyboard,112C46EA)>: feature notification but features not set up: 41 Notification(10,3,41,04,716640)
2025-01-01 11:22:30,834,834     INFO [SolaarListener:hidraw1] logitech_receiver.listener: started with <Device(255,B023,MX Master 3 Wireless Mouse,)> (16)
2025-01-01 11:22:30,834,834     INFO [SolaarListener:hidraw1] solaar.listener: <Device(255,B023,MX Master 3 Wireless Mouse,)>: notifications listener has started (16)
2025-01-01 11:22:30,835,835     INFO [SolaarListener:hidraw1] logitech_receiver.base: New lock <_ThreadedHandle(/dev/hidraw1)>
2025-01-01 11:22:30,847,847     INFO [MainThread] hidapi.udev_impl: Found device /dev/hidraw0 BID 0005 VID 0000046D PID 0000B350 HID++ False True USB None None
2025-01-01 11:22:30,847,847     INFO [MainThread] solaar.listener: receiver event add DeviceInfo(path='/dev/hidraw0', bus_id=5, vendor_id='046D', product_id='B350', interface=None, driver='hid-generic', manufacturer=None, product=None, serial='c3:02:89:84:9b:f4', release=None, isDevice=True, hidpp_short=False, hidpp_long=True)
2025-01-01 11:22:30,848,848     INFO [MainThread] hidapi.udev_impl: OPEN PATH /dev/hidraw0
2025-01-01 11:22:30,848,848     INFO [MainThread] logitech_receiver.base: New lock 20
2025-01-01 11:22:30,854,854     INFO [SolaarListener:hidraw1] solaar.listener: status_changed <Device(255,B023,MX Master 3 Wireless Mouse,)>: paired online (0) 
2025-01-01 11:22:30,893,893     INFO [SolaarListener:hidraw1] solaar.configuration: config file '/home/pfps/.config/solaar/config.yaml' was generated by another version of solaar (config: 1.1.14-40-g57bb2b81, current: 1.1.14-44-g3c0930fe). refreshing detected device capabilities
2025-01-01 11:22:31,846,846     INFO [SolaarListener:hidraw0] logitech_receiver.listener: started with <Device(255,B350,Craft Advanced Keyboard,)> (20)
2025-01-01 11:22:31,846,846     INFO [SolaarListener:hidraw0] solaar.listener: <Device(255,B350,Craft Advanced Keyboard,)>: notifications listener has started (20)
2025-01-01 11:22:31,847,847     INFO [SolaarListener:hidraw0] logitech_receiver.base: New lock <_ThreadedHandle(/dev/hidraw0)>
2025-01-01 11:22:31,856,856     INFO [MainThread] hidapi.udev_impl: OPEN PATH /dev/hidraw1
2025-01-01 11:22:31,889,889     INFO [SolaarListener:hidraw0] solaar.listener: status_changed <Device(255,B350,Craft Advanced Keyboard,)>: paired online (0) 
2025-01-01 11:22:32,148,148     INFO [MainThread] solaar.listener: status_changed <Device(255,B023,MX Master 3 Wireless Mouse,)>: paired online (0) 
2025-01-01 11:22:32,598,598     INFO [SolaarListener:hidraw1] logitech_receiver.device: <Device(255,B023,MX Master 3 Wireless Mouse,)> pushing device settings [<Setting([feature:1] MX Master 3:hires-smooth-invert=None)>, <Setting([feature:1] MX Master 3:hires-smooth-resolution=None)>, <Setting([feature:1] MX Master 3:hires-scroll-mode=None)>, <Setting([feature:2] MX Master 3:scroll-ratchet=None)>, <Setting([feature:4] MX Master 3:smart-shift=None)>, <Setting([feature:1] MX Master 3:thumb-scroll-invert=None)>, <Setting([feature:1] MX Master 3:thumb-scroll-mode=None)>, <Setting([feature:2] MX Master 3:dpi=None)>, <Setting([feature:10] MX Master 3:reprogrammable-keys=None)>, <Setting([feature:10] MX Master 3:divert-keys=None)>, <Setting([feature:2] MX Master 3:change-host=None)>]
2025-01-01 11:22:32,654,654     INFO [AsyncUI] hidapi.udev_impl: OPEN PATH /dev/hidraw1
2025-01-01 11:22:33,623,623     INFO [SolaarListener:hidraw1] solaar.listener: status_changed <Device(255,B023,MX Master 3 Wireless Mouse,)>: paired online (0) initialization
2025-01-01 11:22:37,113,113     INFO [Thread-1] solaar.configuration: saved ['1.1.14-44-g3c0930fe', {'_NAME': 'MX Master 3 Wireless Mouse', '_modelId': 'B02340820000', '_sensitive': {'divert-keys': True, 'hires-scroll-mode': 'ignore', 'hires-smooth-invert': 'ignore', 'hires-smooth-resolution': 'ignore', 'reprogrammable-keys': True}, '_serial': '198E3EB8', '_unitId': '198E3EB8', '_wpid': '4082', 'change-host': None, 'divert-keys': {82: 0, 83: 0, 86: 0, 195: 0, 196: 0}, 'dpi': 1000, 'hires-scroll-mode': False, 'hires-smooth-invert': False, 'hires-smooth-resolution': True, 'reprogrammable-keys': {80: 80, 81: 81, 82: 82, 83: 83, 86: 86, 195: 195, 196: 196}, 'scroll-ratchet': 2, 'smart-shift': 23, 'thumb-scroll-invert': False, 'thumb-scroll-mode': False, '_battery': 4096, '_absent': ['hi-res-scroll', 'lowres-scroll-mode', 'onboard_profiles', 'report_rate', 'report_rate_extended', 'pointer_speed', 'dpi_extended', 'speed-change', 'backlight', 'backlight_level', 'backlight_duration_hands_out', 'backlight_duration_hands_in', 'backlight_duration_powered', 'backlight-timed', 'led_control', 'led_zone_', 'rgb_control', 'rgb_zone_', 'brightness_control', 'per-key-lighting', 'fn-swap', 'persistent-remappable-keys', 'disable-keyboard-keys', 'crown-smooth', 'divert-crown', 'divert-gkeys', 'm-key-leds', 'mr-key-led', 'multiplatform', 'gesture2-gestures', 'gesture2-divert', 'gesture2-params', 'sidetone', 'equalizer', 'adc_power_management']}, {'_NAME': 'Craft Advanced Keyboard', '_modelId': 'B35040660000', '_sensitive': {'backlight': False, 'divert-keys': False, 'hires-scroll-mode': 'ignore', 'hires-smooth-invert': 'ignore', 'hires-smooth-resolution': 'ignore', 'persistent-remappable-keys': False}, '_serial': '112C46EA', '_unitId': '43DAF041', '_wpid': '4066', 'backlight': 0, 'change-host': None, 'crown-smooth': False, 'disable-keyboard-keys': {1: False, 2: False, 4: False, 8: False, 16: False}, 'divert-crown': False, 'divert-keys': {10: 0, 110: 0, 111: 0, 191: 0, 199: 0, 200: 0, 209: 0, 210: 0, 211: 0, 224: 0, 225: 0, 226: 0, 227: 0, 228: 0, 229: 0, 230: 0, 231: 0, 232: 0, 233: 0, 234: 0, 235: 0, 236: 0}, 'fn-swap': True, 'multiplatform': 0, 'persistent-remappable-keys': None}] to /home/pfps/.config/solaar/config.yaml
2025-01-01 11:22:37,401,401     INFO [SolaarListener:hidraw0] logitech_receiver.device: <Device(255,B350,Craft Advanced Keyboard,)> pushing device settings [<Setting([feature:2] Craft:backlight=None)>, <Setting([feature:1] Craft:fn-swap=None)>, <Setting([feature:10] Craft:persistent-remappable-keys=None)>, <Setting([feature:10] Craft:divert-keys=None)>, <Setting([feature:16] Craft:disable-keyboard-keys=None)>, <Setting([feature:1] Craft:crown-smooth=None)>, <Setting([feature:1] Craft:divert-crown=None)>, <Setting([feature:2] Craft:multiplatform=None)>, <Setting([feature:2] Craft:change-host=None)>]
2025-01-01 11:22:38,921,921     INFO [SolaarListener:hidraw0] solaar.listener: status_changed <Device(255,B350,Craft Advanced Keyboard,)>: paired online (0) 
2025-01-01 11:22:38,965,965     INFO [SolaarListener:hidraw0] solaar.listener: status_changed <Device(255,B350,Craft Advanced Keyboard,)>: paired online (0) initialization
2025-01-01 11:22:42,422,422     INFO [Thread-2] solaar.configuration: saved ['1.1.14-44-g3c0930fe', {'_NAME': 'MX Master 3 Wireless Mouse', '_modelId': 'B02340820000', '_sensitive': {'divert-keys': True, 'hires-scroll-mode': 'ignore', 'hires-smooth-invert': 'ignore', 'hires-smooth-resolution': 'ignore', 'reprogrammable-keys': True}, '_serial': '198E3EB8', '_unitId': '198E3EB8', '_wpid': '4082', 'change-host': None, 'divert-keys': {82: 0, 83: 0, 86: 0, 195: 0, 196: 0}, 'dpi': 1000, 'hires-scroll-mode': False, 'hires-smooth-invert': False, 'hires-smooth-resolution': True, 'reprogrammable-keys': {80: 80, 81: 81, 82: 82, 83: 83, 86: 86, 195: 195, 196: 196}, 'scroll-ratchet': 2, 'smart-shift': 23, 'thumb-scroll-invert': False, 'thumb-scroll-mode': False, '_battery': 4096, '_absent': ['hi-res-scroll', 'lowres-scroll-mode', 'onboard_profiles', 'report_rate', 'report_rate_extended', 'pointer_speed', 'dpi_extended', 'speed-change', 'backlight', 'backlight_level', 'backlight_duration_hands_out', 'backlight_duration_hands_in', 'backlight_duration_powered', 'backlight-timed', 'led_control', 'led_zone_', 'rgb_control', 'rgb_zone_', 'brightness_control', 'per-key-lighting', 'fn-swap', 'persistent-remappable-keys', 'disable-keyboard-keys', 'crown-smooth', 'divert-crown', 'divert-gkeys', 'm-key-leds', 'mr-key-led', 'multiplatform', 'gesture2-gestures', 'gesture2-divert', 'gesture2-params', 'sidetone', 'equalizer', 'adc_power_management']}, {'_NAME': 'Craft Advanced Keyboard', '_modelId': 'B35040660000', '_sensitive': {'backlight': False, 'divert-keys': False, 'hires-scroll-mode': 'ignore', 'hires-smooth-invert': 'ignore', 'hires-smooth-resolution': 'ignore', 'persistent-remappable-keys': False}, '_serial': '112C46EA', '_unitId': '43DAF041', '_wpid': '4066', 'backlight': 0, 'change-host': None, 'crown-smooth': False, 'disable-keyboard-keys': {1: False, 2: False, 4: False, 8: False, 16: False}, 'divert-crown': False, 'divert-keys': {10: 0, 110: 0, 111: 0, 191: 0, 199: 0, 200: 0, 209: 0, 210: 0, 211: 0, 224: 0, 225: 0, 226: 0, 227: 0, 228: 0, 229: 0, 230: 0, 231: 0, 232: 0, 233: 0, 234: 0, 235: 0, 236: 0}, 'fn-swap': True, 'multiplatform': 0, 'persistent-remappable-keys': None, '_absent': ['hi-res-scroll', 'lowres-scroll-mode', 'hires-smooth-invert', 'hires-smooth-resolution', 'hires-scroll-mode', 'scroll-ratchet', 'smart-shift', 'thumb-scroll-invert', 'thumb-scroll-mode', 'onboard_profiles', 'report_rate', 'report_rate_extended', 'pointer_speed', 'dpi', 'dpi_extended', 'speed-change', 'backlight_level', 'backlight_duration_hands_out', 'backlight_duration_hands_in', 'backlight_duration_powered', 'backlight-timed', 'led_control', 'led_zone_', 'rgb_control', 'rgb_zone_', 'brightness_control', 'per-key-lighting', 'reprogrammable-keys', 'divert-gkeys', 'm-key-leds', 'mr-key-led', 'gesture2-gestures', 'gesture2-divert', 'gesture2-params', 'sidetone', 'equalizer', 'adc_power_management'], '_battery': 4096}] to /home/pfps/.config/solaar/config.yaml

@pfps pfps marked this pull request as draft January 1, 2025 16:30
@MattHag MattHag force-pushed the refactor_event_handling branch 2 times, most recently from 8c3fdc2 to d22b76e Compare January 2, 2025 12:50
@MattHag MattHag marked this pull request as ready for review January 2, 2025 12:54
@MattHag
Copy link
Collaborator Author

MattHag commented Jan 2, 2025

The warning should be fixed - aka condition reverted. I think I had accidentally switched a logic condition in a push in between.

Split processing of receiver notification into smaller functions.
Extract handler functions for every receiver notification for simple
maintenence and testability.

Related pwr-Solaar#2273
Remove repeated code pattern with generalized implementation. Aim
towards easy extension and code readability.

Related pwr-Solaar#2273
Simplify code and unify interfaces and type hints.

Related pwr-Solaar#2273
@MattHag MattHag force-pushed the refactor_event_handling branch from d22b76e to 6177a1a Compare January 2, 2025 12:57
Copy link
Collaborator

@pfps pfps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@pfps pfps merged commit d42524d into pwr-Solaar:master Jan 2, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants