Mice behind an ASUS Omni receiver all enumerate with the same usb id
(0b05:1ace), so the regular bus:vid:pid DeviceMatch cannot tell models
apart. Identify the model during probe instead:
- asus-rog-omni-receiver.device is a minimal bootstrap file that only
declares Quirks=OMNI_RECEIVER, so the asus driver gets probed on the
receiver's hidraw nodes
- the probe queries the serial number signature (03 12 12 02) and
matches its prefix against the OmniSignature field of the .device
files, then re-resolves the device data for the identified usb id
- an unknown signature fails the probe with -ENODEV, which also drops
the receiver's keyboard and media control nodes
The Strix Impact III family answers with data two bytes earlier than the
original protocol (code plus params echo instead of code plus pad), so
two quirks cover the new layouts:
- LED_V2: per-zone LED responses with data at offset 4, brightness in
0-100
- SETTINGS_V2: settings and DPI responses with data at offset 4,
rate/debounce/snapping as single bytes
Also write DPI values with two bytes so presets above 12850 dpi work.
Verified on a ROG Strix Impact III Wireless: identification on hidraw4,
all 5 profiles with 8 buttons, 1 LED and DPI presets 400/800/1600/3200,
report rate 1000 Hz, debounce 12 ms, LED brightness 127 (50%). Writes
round-trip and survive a ratbagd restart.
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>
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
Macros can be used for that instead, drivers can adapt them as needed.
Simple key actions will stay here for now, but I plan to completely
replace them with macros eventually.
Although it does work for some mice and fixes there being several
configurable devices for a single mouse in libratbag, for some mice it
does *not* apply, making them unusable with libratbag.
This erroneously declared it with name `__packed__` instead of using it
as an attribute.
It doesn't seem like it changes struct's size, but it has no
static_assert on it so we can't be 100% sure.
If by any chance returned `size` was `0`, it would erroneously return 0,
which would do an uninitialized pointer dereference in
sinowealthnubwo_probe().
This fixes a convoluted warning by clang-analyze.