Repository: pwr-Solaar/Solaar

Issue:
G-key diversion broken by update 1.1.9
**Information**
<!-- Make sure that your issue is not one of the known issues in the Solaar documentation at https://pwr-solaar.github.io/Solaar/ -->
<!-- Do not bother opening an issue for a version older than 1.1.0.  Upgrade to the latest version and see if your issue persists. -->
<!-- If you not running the current version of Solaar, strongly consider upgrading to the newest version. -->
- Solaar version (`solaar --version` or `git describe --tags` if cloned from this repository): 1.1.9
- Distribution: Arch
- Kernel version (ex. `uname -srmo`): Linux 6.2.10-zen1-1-zen x86_64 GNU/Linux
- Output of `solaar show`:

<details>

```
solaar version 1.1.9

USB and Bluetooth Devices

1: G815 Mechanical Keyboard
Device path  : /dev/hidraw2
USB id       : 046d:C33F
Codename     : G815
Kind         : keyboard
Protocol     : HID++ 4.2
Polling rate : 1 ms (1000Hz)
Serial number:
Model ID:      C33F00000000
Unit ID:       35304716
Bootloader: BOT 84.00.B0003
Firmware: U1  31.02.B0018
Other:
Other:
Other:
Supports 24 HID++ 2.0 features:
0: ROOT                   {0000} V0
1: FEATURE SET            {0001} V0
2: DEVICE FW VERSION      {0003} V2
Firmware: Bootloader BOT 84.00.B0003 AAEA
Firmware: Firmware U1  31.02.B0018 C33F
Firmware: Other
Firmware: Other
Firmware: Other
Unit ID: 35304716  Model ID: C33F00000000  Transport IDs: {'usbid': 'C33F'}
3: DEVICE NAME            {0005} V0
Name: G815 RGB MECHANICAL GAMING KEYBOARD
Kind: keyboard
4: CONFIG CHANGE          {0020} V0
5: DFUCONTROL SIGNED      {00C2} V0
6: DFU                    {00D0} V0
7: REPORT HID USAGE       {1BC0} V0
8: KEYBOARD DISABLE BY USAGE {4522} V0
9: KEYBOARD LAYOUT 2      {4540} V0
10: GKEY                   {8010} V0
Divert G Keys (saved): True
Divert G Keys        : False
11: MKEYS                  {8020} V0
M-Key LEDs (saved): {M1:False, M2:False, M3:False}
M-Key LEDs        : {M1:False, M2:False, M3:False}
12: MR                     {8030} V0
MR-Key LED (saved): False
MR-Key LED        : False
13: BRIGHTNESS CONTROL     {8040} V0
14: REPORT RATE            {8060} V0
Polling Rate (ms): 1
Polling Rate (ms) (saved): 1
Polling Rate (ms)        : 1
15: RGB EFFECTS            {8071} V0
16: PER KEY LIGHTING V2    {8081} V2
17: ONBOARD PROFILES       {8100} V0
Device Mode: Host
Onboard Profiles (saved): Disable
Onboard Profiles        : Disable
18: unknown:1801           {1801} V0    internal, hidden
19: DEVICE RESET           {1802} V0    internal, hidden
20: CONFIG DEVICE PROPS    {1806} V5    internal, hidden
21: unknown:18B0           {18B0} V0    internal, hidden
22: unknown:1E00           {1E00} V0    hidden
23: unknown:1EB0           {1EB0} V0    internal, hidden
Battery status unavailable.

2: G502 Proteus Spectrum Optical Mouse
Device path  : /dev/hidraw4
USB id       : 046d:C332
Codename     : G502 Proteus Spectrum
Kind         : mouse
Protocol     : HID++ 4.2
Polling rate : 1 ms (1000Hz)
Serial number:
Model ID:      C33200000000
Unit ID:       31374706
Firmware: U1  03.02.B0012
Bootloader: BOT 14.00.B0007
Supports 20 HID++ 2.0 features:
0: ROOT                   {0000} V0
1: FEATURE SET            {0001} V0
2: COLOR LED EFFECTS      {8070} V3
3: DEVICE FW VERSION      {0003} V1
Firmware: Firmware U1  03.02.B0012 C332
Firmware: Bootloader BOT 14.00.B0007 AABF
Unit ID: 31374706  Model ID: C33200000000  Transport IDs: {'usbid': 'C332'}
4: DEVICE NAME            {0005} V0
Name: Tunable RGB Gaming Mouse G502
Kind: mouse
5: LED CONTROL            {1300} V0
6: unknown:18A1           {18A1} V0    internal, hidden
7: unknown:1E00           {1E00} V0    hidden
8: unknown:1E20           {1E20} V0
9: unknown:1EB0           {1EB0} V0    internal, hidden
10: ADJUSTABLE DPI         {2201} V1
Sensitivity (DPI) (saved): 7000
Sensitivity (DPI)        : 7000
11: ANGLE SNAPPING         {2230} V0
12: SURFACE TUNING         {2240} V0
13: REPORT RATE            {8060} V0
Polling Rate (ms): 1
Polling Rate (ms) (saved): 1
Polling Rate (ms)        : 1
14: ONBOARD PROFILES       {8100} V0
Device Mode: On-Board
Onboard Profiles (saved): Enable
Onboard Profiles        : Enable
15: MOUSE BUTTON SPY       {8110} V0
16: unknown:1850           {1850} V0    internal, hidden
17: DFUCONTROL UNSIGNED    {00C1} V0
18: unknown:1801           {1801} V0    internal, hidden
19: DEVICE RESET           {1802} V0    internal, hidden
Battery status unavailable.
```
</details>

- Contents of `~/.config/solaar/config.yaml` (or `~/.config/solaar/config.json` if `~/.config/solaar/config.yaml` not present):

<details>

```
- 1.1.9
- _NAME: G815 Mechanical Keyboard
_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, pointer_speed, dpi, speed-change, backlight, backlight-timed, fn-swap, reprogrammable-keys, persistent-remappable-keys, divert-keys,
disable-keyboard-keys, crown-smooth, divert-crown, multiplatform, change-host, gesture2-gestures, gesture2-divert, gesture2-params, sidetone, equalizer,
adc_power_management]
_battery: 0
_modelId: C33F00000000
_sensitive: {divert-gkeys: true, m-key-leds: true, mr-key-led: true, onboard_profiles: true, report_rate: true}
_unitId: '35304716'
divert-gkeys: true
m-key-leds: {1: false, 2: false, 4: false}
mr-key-led: false
onboard_profiles: 2
report_rate: 1
- _NAME: G502 Proteus Spectrum Optical Mouse
_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, pointer_speed, speed-change, backlight, backlight-timed, fn-swap, reprogrammable-keys, persistent-remappable-keys, divert-keys, disable-keyboard-keys,
crown-smooth, divert-crown, divert-gkeys, m-key-leds, mr-key-led, multiplatform, change-host, gesture2-gestures, gesture2-divert, gesture2-params, sidetone,
equalizer, adc_power_management]
_battery: 0
_modelId: C33200000000
_sensitive: {dpi: false}
_unitId: '31374706'
dpi: 7000
onboard_profiles: 1
report_rate: 1
```
</details>


- Errors or warrnings from Solaar:
<!-- Under normal operation Solaar keeps a log of warning and error messages in ~/.tmp
while it is running as a file starting with 'Solaar'.
If this file is not available or does not have useful information you can
run Solaar as `solaar -dd`, after killing any running Solaar processes to
have Solaar log informational, warning, and error messages to stdout. -->

<details>

```
2023-04-10 10:11:09,057,057     INFO [MainThread] root: language en_US (UTF-8), translations path /usr/share/locale

(solaar:100509): Gtk-WARNING **: 10:11:09.110: Theme parsing error: gtk.css:1649:16: '-gtk-icon-size' is not a valid property name

(solaar:100509): Gtk-WARNING **: 10:11:09.110: Theme parsing error: gtk.css:1652:16: '-gtk-icon-size' is not a valid property name
2023-04-10 10:11:09,192,192     INFO [MainThread] logitech_receiver.diversion: GDK Keymap set up
2023-04-10 10:11:09,196,196     INFO [MainThread] logitech_receiver.diversion: loaded 1 rules from /home/xdmatthewbx/.config/solaar/rules.yaml
2023-04-10 10:11:09,212,212     INFO [MainThread] solaar.upower: connected to system dbus, watching for suspend/resume events
2023-04-10 10:11:09,214,214     INFO [MainThread] solaar.ui.notify: starting desktop notifications
2023-04-10 10:11:09,257,257     INFO [MainThread] solaar.listener: starting receiver listening threads
2023-04-10 10:11:09,351,351     INFO [MainThread] hidapi.udev: Found device BID 0003 VID 0000046D PID 0000C33F HID++ False True USB 1 1
2023-04-10 10:11:09,351,351     INFO [MainThread] solaar.listener: receiver event add DeviceInfo(path='/dev/hidraw2', bus_id=3, vendor_id='046D', product_id='C33F', interface=1, driver='hid-generic', manufacturer=None, product=None, serial='165730613232', release=None, isDevice=True, hidpp_short=False, hidpp_long=True)
2023-04-10 10:11:09,352,352     INFO [ReceiverListener:hidraw2] logitech_receiver.listener: started with <Device(255,C33F,G815 Mechanical Keyboard,)>(14)
2023-04-10 10:11:09,352,352     INFO [ReceiverListener:hidraw2] solaar.listener: <Device(255,C33F,G815 Mechanical Keyboard,)>: notifications listenerhas started (14)
2023-04-10 10:11:09,352,352     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(255,C33F,G815 Mechanical Keyboard,)>: paired offline, {'NOTIFICATION FLAGS': False} (0)
2023-04-10 10:11:09,352,352     INFO [ReceiverListener:hidraw2] logitech_receiver.base: New lock <_ThreadedHandle(/dev/hidraw2)>
2023-04-10 10:11:09,356,356     INFO [MainThread] hidapi.udev: Found device BID 0003 VID 0000046D PID 0000C332 HID++ True True USB 1 1
2023-04-10 10:11:09,361,361     INFO [MainThread] solaar.listener: receiver event add DeviceInfo(path='/dev/hidraw4', bus_id=3, vendor_id='046D', product_id='C332', interface=1, driver='hid-generic', manufacturer=None, product=None, serial='066837513432', release=None, isDevice=True, hidpp_short=True, hidpp_long=True)
2023-04-10 10:11:09,361,361     INFO [ReceiverListener:hidraw4] logitech_receiver.listener: started with <Device(255,C332,G502 Proteus Spectrum Optical Mouse,)> (15)
2023-04-10 10:11:09,361,361     INFO [ReceiverListener:hidraw4] solaar.listener: <Device(255,C332,G502 Proteus Spectrum Optical Mouse,)>: notifications listener has started (15)
2023-04-10 10:11:09,361,361     INFO [ReceiverListener:hidraw4] solaar.listener: status_changed <Device(255,C332,G502 Proteus Spectrum Optical Mouse,)>: paired offline, {'NOTIFICATION FLAGS': False} (0)
2023-04-10 10:11:09,361,361     INFO [ReceiverListener:hidraw4] logitech_receiver.base: New lock <_ThreadedHandle(/dev/hidraw4)>
2023-04-10 10:11:09,362,362  WARNING [MainThread] hidapi.udev: Report Descriptor not processed for BID 0003 VID 00001B1C PID 00000C1C: Expecting 768 usages but got 1
2023-04-10 10:11:09,363,363  WARNING [MainThread] hidapi.udev: Report Descriptor not processed for BID 0003 VID 00001B1C PID 00000C1C: Expecting 256 usages but got 1
2023-04-10 10:11:09,363,363  WARNING [MainThread] hidapi.udev: Report Descriptor not processed for BID 0003 VID 00000951 PID 000016A4: Expecting 16 usages but got 1
2023-04-10 10:11:09,412,412     INFO [ReceiverListener:hidraw4] logitech_receiver.status: <Device(255,C332,G502 Proteus Spectrum Optical Mouse,)> pushing device settings [<Setting([feature:choice] G502 Proteus Spectrum:onboard_profiles=None)>, <Setting([feature:choice] G502 Proteus Spectrum:report_rate=None)>, <Setting([feature:choice] G502 Proteus Spectrum:dpi=None)>]
2023-04-10 10:11:09,424,424     INFO [ReceiverListener:hidraw2] logitech_receiver.status: <Device(255,C33F,G815 Mechanical Keyboard,)> pushing devicesettings [<Setting([feature:choice] G815:onboard_profiles=None)>, <Setting([feature:choice] G815:report_rate=None)>, <Setting([feature:toggle] G815:divert-gkeys=None)>, <Setting([feature:multiple toggle] G815:m-key-leds=None)>, <Setting([feature:toggle] G815:mr-key-led=None)>]
2023-04-10 10:11:09,426,426    ERROR [ReceiverListener:hidraw4] logitech_receiver.base: (15) device 255 error on feature request {0D29}: 2 = invalid argument
2023-04-10 10:11:09,427,427  WARNING [ReceiverListener:hidraw4] logitech_receiver.settings: report_rate: error applying value 1 so ignore it (<Device(255,C332,G502 Proteus Spectrum Optical Mouse,)>)
2023-04-10 10:11:09,431,431     INFO [ReceiverListener:hidraw4] solaar.listener: status_changed <Device(255,C332,G502 Proteus Spectrum Optical Mouse,)>: paired online, {'NOTIFICATION FLAGS': False} (0) initialization
2023-04-10 10:11:09,453,453     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(255,C33F,G815 Mechanical Keyboard,)>: paired online, {'NOTIFICATION FLAGS': False} (0) initialization
2023-04-10 10:11:09,454,454    ERROR [ReceiverListener:hidraw2] logitech_receiver.listener: processing Notification(11,255,0A,00,00000000000000000000000000000000)
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/logitech_receiver/listener.py", line 176, in run
self._notifications_callback(n)
File "/usr/lib/python3.10/site-packages/solaar/listener.py", line 196, in _notifications_handler
_notifications.process(self.receiver, n)
File "/usr/lib/python3.10/site-packages/logitech_receiver/notifications.py", line 61, in process
return _process_device_notification(device, status, notification)
File "/usr/lib/python3.10/site-packages/logitech_receiver/notifications.py", line 201, in _process_device_notification
return _process_feature_notification(device, status, n, feature)
File "/usr/lib/python3.10/site-packages/logitech_receiver/notifications.py", line 448, in _process_feature_notification
_diversion.process_notification(device, status, n, feature)
File "/usr/lib/python3.10/site-packages/logitech_receiver/diversion.py", line 1374, in process_notification
new_g_keys_down = _unpack('!4I', notification.data[:4])[0]
struct.error: unpack requires a buffer of 16 bytes

(solaar:100509): Gdk-CRITICAL **: 10:11:09.470: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed
2023-04-10 10:11:11,220,220    ERROR [ReceiverListener:hidraw2] logitech_receiver.listener: processing Notification(11,255,0A,00,04000000000000000000000000000000)
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/logitech_receiver/listener.py", line 176, in run
self._notifications_callback(n)
File "/usr/lib/python3.10/site-packages/solaar/listener.py", line 196, in _notifications_handler
_notifications.process(self.receiver, n)
File "/usr/lib/python3.10/site-packages/logitech_receiver/notifications.py", line 61, in process
return _process_device_notification(device, status, notification)
File "/usr/lib/python3.10/site-packages/logitech_receiver/notifications.py", line 201, in _process_device_notification
return _process_feature_notification(device, status, n, feature)
File "/usr/lib/python3.10/site-packages/logitech_receiver/notifications.py", line 448, in _process_feature_notification
_diversion.process_notification(device, status, n, feature)
File "/usr/lib/python3.10/site-packages/logitech_receiver/diversion.py", line 1374, in process_notification
new_g_keys_down = _unpack('!4I', notification.data[:4])[0]
struct.error: unpack requires a buffer of 16 bytes
2023-04-10 10:11:11,295,295    ERROR [ReceiverListener:hidraw2] logitech_receiver.listener: processing Notification(11,255,0A,00,00000000000000000000000000000000)
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/logitech_receiver/listener.py", line 176, in run
self._notifications_callback(n)
File "/usr/lib/python3.10/site-packages/solaar/listener.py", line 196, in _notifications_handler
_notifications.process(self.receiver, n)
File "/usr/lib/python3.10/site-packages/logitech_receiver/notifications.py", line 61, in process
return _process_device_notification(device, status, notification)
File "/usr/lib/python3.10/site-packages/logitech_receiver/notifications.py", line 201, in _process_device_notification
return _process_feature_notification(device, status, n, feature)
File "/usr/lib/python3.10/site-packages/logitech_receiver/notifications.py", line 448, in _process_feature_notification
_diversion.process_notification(device, status, n, feature)
File "/usr/lib/python3.10/site-packages/logitech_receiver/diversion.py", line 1374, in process_notification
new_g_keys_down = _unpack('!4I', notification.data[:4])[0]
struct.error: unpack requires a buffer of 16 bytes
2023-04-10 10:11:11,380,380    ERROR [ReceiverListener:hidraw2] logitech_receiver.listener: processing Notification(11,255,0A,00,04000000000000000000000000000000)
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/logitech_receiver/listener.py", line 176, in run
self._notifications_callback(n)
File "/usr/lib/python3.10/site-packages/solaar/listener.py", line 196, in _notifications_handler
_notifications.process(self.receiver, n)
File "/usr/lib/python3.10/site-packages/logitech_receiver/notifications.py", line 61, in process
return _process_device_notification(device, status, notification)
File "/usr/lib/python3.10/site-packages/logitech_receiver/notifications.py", line 201, in _process_device_notification
return _process_feature_notification(device, status, n, feature)
File "/usr/lib/python3.10/site-packages/logitech_receiver/notifications.py", line 448, in _process_feature_notification
_diversion.process_notification(device, status, n, feature)
File "/usr/lib/python3.10/site-packages/logitech_receiver/diversion.py", line 1374, in process_notification
new_g_keys_down = _unpack('!4I', notification.data[:4])[0]
struct.error: unpack requires a buffer of 16 bytes
2023-04-10 10:11:11,460,460    ERROR [ReceiverListener:hidraw2] logitech_receiver.listener: processing Notification(11,255,0A,00,00000000000000000000000000000000)
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/logitech_receiver/listener.py", line 176, in run
self._notifications_callback(n)
File "/usr/lib/python3.10/site-packages/solaar/listener.py", line 196, in _notifications_handler
_notifications.process(self.receiver, n)
File "/usr/lib/python3.10/site-packages/logitech_receiver/notifications.py", line 61, in process
return _process_device_notification(device, status, notification)
File "/usr/lib/python3.10/site-packages/logitech_receiver/notifications.py", line 201, in _process_device_notification
return _process_feature_notification(device, status, n, feature)
File "/usr/lib/python3.10/site-packages/logitech_receiver/notifications.py", line 448, in _process_feature_notification
_diversion.process_notification(device, status, n, feature)
File "/usr/lib/python3.10/site-packages/logitech_receiver/diversion.py", line 1374, in process_notification
new_g_keys_down = _unpack('!4I', notification.data[:4])[0]
struct.error: unpack requires a buffer of 16 bytes
2023-04-10 10:11:14,309,309     INFO [MainThread] solaar.listener: stopping receiver listening threads [<ReceiverListener(ReceiverListener:hidraw2, started daemon 140677505537728)>, <ReceiverListener(ReceiverListener:hidraw4, started daemon 140677524485824)>]
2023-04-10 10:11:14,312,312     INFO [MainThread] solaar.configuration: saved ['1.1.9', {'_NAME': 'G815 Mechanical Keyboard', '_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', 'pointer_speed', 'dpi', 'speed-change', 'backlight', 'backlight-timed', 'fn-swap', 'reprogrammable-keys', 'persistent-remappable-keys', 'divert-keys', 'disable-keyboard-keys', 'crown-smooth', 'divert-crown', 'multiplatform', 'change-host', 'gesture2-gestures', 'gesture2-divert', 'gesture2-params', 'sidetone', 'equalizer', 'adc_power_management'], '_battery': 0, '_modelId': 'C33F00000000', '_sensitive': {'divert-gkeys': True, 'm-key-leds': True, 'mr-key-led': True, 'onboard_profiles': True, 'report_rate': True}, '_unitId': '35304716', 'divert-gkeys': True, 'm-key-leds': {1: False, 2: False, 4: False}, 'mr-key-led': False, 'onboard_profiles': 2, 'report_rate': 1}, {'_NAME': 'G502 Proteus Spectrum Optical Mouse', '_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', 'pointer_speed', 'speed-change', 'backlight', 'backlight-timed', 'fn-swap', 'reprogrammable-keys', 'persistent-remappable-keys', 'divert-keys', 'disable-keyboard-keys', 'crown-smooth', 'divert-crown', 'divert-gkeys', 'm-key-leds', 'mr-key-led', 'multiplatform', 'change-host', 'gesture2-gestures', 'gesture2-divert', 'gesture2-params', 'sidetone', 'equalizer', 'adc_power_management'], '_battery': 0, '_modelId': 'C33200000000', '_sensitive': {'dpi': False}, '_unitId': '31374706', 'dpi': 7000, 'onboard_profiles': 1, 'report_rate': 1}] to /home/xdmatthewbx/.config/solaar/config.yaml
2023-04-10 10:11:14,436,436     INFO [ReceiverListener:hidraw4] solaar.listener: <Device(255,C332,G502 Proteus Spectrum Optical Mouse,)>: notifications listener has stopped
2023-04-10 10:11:14,463,463     INFO [ReceiverListener:hidraw2] solaar.listener: <Device(255,C33F,G815 Mechanical Keyboard,)>: notifications listenerhas stopped
2023-04-10 10:11:14,464,464     INFO [MainThread] solaar.ui.notify: stopping desktop notifications
```

</details>


**Describe the bug**
G815 broken by update 1.1.9. Keybinds (at least ones bound to G keys, diverted or not) do not work.

Downgrading to 1.1.8 fixes the issue.

**To Reproduce**
Steps to reproduce the behavior:
1. Use Solaar 1.1.9 with G815
2. Divert G keys (optional)
3. Create rule for pressing any G key
4. Attempt to press G key

Expected:
Rule triggers

Actual:
Rule does not trigger

**Screenshots**
1.1.9 (broken):
![image](https://user-images.githubusercontent.com/16640162/230918979-7114613e-db3b-486b-bdd9-30218f9dd59b.png)
1.1.8 (working):
![image](https://user-images.githubusercontent.com/16640162/230919041-b748385c-6c5a-4867-a298-6e2c22de18ec.png)


**Additional context**
Add any other context about the problem here.



Discussion:
In 1.1.8 when running `solaar -ddd` do you see

```
2023-04-10 10:11:09,426,426    ERROR [ReceiverListener:hidraw4] logitech_receiver.base: (15) device 255 error on feature request {0D29}: 2 = invalid argument
2023-04-10 10:11:09,427,427  WARNING [ReceiverListener:hidraw4] logitech_receiver.settings: report_rate: error applying value 1 so ignore it (<Device(255,C332,G502 Proteus Spectrum Optical Mouse,)>)
```
Also, what are the contents of your `~/.config/solaar/rules.yaml` file?
Indeed, there is a bug introduced in December.   The fix should be simple.   

Resolving patch:
diff --git a/lib/logitech_receiver/diversion.py b/lib/logitech_receiver/diversion.py
--- a/lib/logitech_receiver/diversion.py
+++ b/lib/logitech_receiver/diversion.py
@@ -1371,11 +1371,11 @@ def process_notification(device, status, notification, feature):
         keys_down = new_keys_down
     # and also G keys down
     elif feature == _F.GKEY and notification.address == 0x00:
-        new_g_keys_down = _unpack('!4I', notification.data[:4])[0]
+        new_g_keys_down = _unpack('<I', notification.data[:4])[0]
         for i in range(32):
-            if new_g_keys_down & (0x01 << (i - 1)) and not g_keys_down & (0x01 << (i - 1)):
+            if new_g_keys_down & (0x01 << i) and not g_keys_down & (0x01 << i):
                 key_down = _CONTROL['G' + str(i + 1)]
-            if g_keys_down & (0x01 << (i - 1)) and not new_g_keys_down & (0x01 << (i - 1)):
+            if g_keys_down & (0x01 << i) and not new_g_keys_down & (0x01 << i):
                 key_up = _CONTROL['G' + str(i + 1)]
         g_keys_down = new_g_keys_down
     # and also M keys down


Test patch: