src/libratbag.i calls PyInt_Check(), PyInt_AsLong() and PyInt_FromLong().
Those are Python 2 functions; they only ever worked because SWIG emitted
compatibility macros mapping them onto their PyLong_* counterparts in the
generated wrapper. SWIG 4.5.0 dropped those macros, so the generated
libratbag.c no longer compiles:
libratbag.c: In function '_wrap_ratbag_device_get_vendor_id':
libratbag.c:4583:17: error: implicit declaration of function
'PyInt_FromLong'; did you mean 'PyLong_FromLong'?
libratbag.c:4583:15: error: assignment to 'PyObject *' from 'int' makes
pointer from integer without a cast [-Wint-conversion]
Call the PyLong_* functions directly. The bindings are generated with
swig -py3, so there is no Python 2 build to keep working, and the macros
they replace expanded to exactly these functions.
Built and verified on Arch Linux with swig 4.5.0, Python 3.14, meson 1.12.0, gcc 15: `_libratbag.so` and `_hidpp.so` link cleanly with the change and fail without it.
Co-authored-by: Jitka Plesnikova <jplesnik@redhat.com>
Signed-off-by: Stephen Kitt <skitt@debian.org>
f9d1574 enabled this for the G502 X PLUS, which is the RGB variant.
I can confirm the normal G502 X Wireless has this quirk. I do not
have a base model G502 X, but comments on issue #1606 as well as logic
suggest it very likely does unless proven otherwise.
The G502 X PLUS reports a 1-indexed active profile, so without
INDEX_OFFSET libratbag targets the wrong profile and DPI/button changes
never reach the device (the mouse boots on its first profile, reported
as index 1). It also needs the existing G502X_PLUS LED quirk, so list
both now that hidpp20 supports multiple quirks.
Verified on hardware (usb:046d:4099 via the Lightspeed receiver, Linux
7.x): the device reports active profile index 1, INDEX_OFFSET maps it to
0, and the LED still reads correctly via the G502X_PLUS slot.
The hidpp20 quirk was a single enum value, so a device could carry only
one quirk. Some devices need several at once. For example the G502 X
PLUS needs G502X_PLUS (LED in the 2nd slot) and INDEX_OFFSET (1-indexed
active profile) together, which a single field cannot express. #1799
noted this was worth adding.
Make the quirk enum combinable bit flags stored as a bitmask. The
"Quirk" key now takes a ;-separated list (like the asus driver's
"Quirks"); existing single-value device files parse the same as before.
Device: Logitech G502 X PLUS
Encountered an issue where re-binding keys which previously had modifiers assigned (e.g. ALT+KEY_LEFT), resulted in the modifier being retained. This small change clears modifiers before assigning new keys or macros. Keys are still able to be assigned modifiers, as assignment hasn't changed.
I didn't see a PR template, so I'm just doing my best here...
- Assigned the back button the default setting
- Changed back button to send comma key
- before: sent `ALT+,`
- after: sent `,` ✔️
- Assigned back button to send `ALT+LEFT_ARROW`
- Changed back button to send comma key
- before: sent `ALT+,`
- after: sent `,` ✔️
- Assigned back button to send comma key
- Changed back button to send `ALT+,`
- before: sent `ALT+,`
- after: sent `ALT+,` ✔️
Closes https://github.com/libratbag/libratbag/issues/1853
Closes https://github.com/libratbag/piper/issues/835
* Added Quirk for G502 offset to resolve incorrect active profile being applied. Testing on G502- Hero Wireless. May be worth adding handling for multiple quirks.
* Added quirk in device files to correct offset for G502 Hero, G502-Proteus Spectrum, and G604.
* Refactored G502 Offset Quirk naming to be more broadly applicable as index offset.
* Correct typo in g502-proteus spectrum quirk value.
---------
Co-authored-by: Patrick Klose <pjklose@outlook.com>
* Recognize the Logitech G502X PLUS (Wired)
* Fixed: LED write functionality for G502X PLUS
Inspired by 94bd172a19
* Changed: Number of LEDs is implied by quirk set.
* Added: Extra note about single LED
Broke with Ruff v0.2.
- SIM401 Use `self._devices.get(id, None)` instead of an `if` block
- SIM113 Use `enumerate()` for index variable `i` in `for` loop
- Add type hint for Ratbagd._devices