1
0
forked from drath/libratbag

hidpp20: add quirk to fix active profile index on some devices (#1799)

* 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>
This commit is contained in:
Patrick Klose
2026-01-11 10:51:40 -06:00
committed by GitHub
parent c5214d2633
commit 874c01732a
7 changed files with 20 additions and 0 deletions

View File

@@ -3,3 +3,6 @@ Name=Logitech G502 Hero Wireless
DeviceMatch=usb:046d:407f;usb:046d:c08d
Driver=hidpp20
DeviceType=mouse
[Driver/hidpp20]
Quirk=INDEX_OFFSET

View File

@@ -3,3 +3,6 @@ Name=Logitech G502 Hero
DeviceMatch=usb:046d:c08b
Driver=hidpp20
DeviceType=mouse
[Driver/hidpp20]
Quirk=INDEX_OFFSET

View File

@@ -3,3 +3,6 @@ Name=Logitech G502 Proteus Spectrum
DeviceMatch=usb:046d:c332
Driver=hidpp20
DeviceType=mouse
[Driver/hidpp20]
Quirk=INDEX_OFFSET

View File

@@ -3,3 +3,6 @@ Name=Logitech G604
DeviceMatch=usb:046d:4085;bluetooth:046d:b024
Driver=hidpp20
DeviceType=mouse
[Driver/hidpp20]
Quirk=INDEX_OFFSET

View File

@@ -111,6 +111,7 @@ hidpp20_get_quirk_string(enum hidpp20_quirk quirk)
CASE_RETURN_STRING(HIDPP20_QUIRK_G305);
CASE_RETURN_STRING(HIDPP20_QUIRK_G602);
CASE_RETURN_STRING(HIDPP20_QUIRK_G502X_PLUS);
CASE_RETURN_STRING(HIDPP20_QUIRK_INDEX_OFFSET);
}
abort();
@@ -2277,6 +2278,10 @@ hidpp20_onboard_profiles_allocate(struct hidpp20_device *device,
active_profile_index = rc;
/* Apply quirk for devices that return 1-indexed profile */
if (device->quirk == HIDPP20_QUIRK_INDEX_OFFSET && active_profile_index > 0)
active_profile_index--;
profiles = zalloc(sizeof(struct hidpp20_profiles));
profiles->profiles = zalloc(info.profile_count * sizeof(struct hidpp20_profile));
profiles->sector_size = info.sector_size;

View File

@@ -56,6 +56,7 @@ enum hidpp20_quirk {
HIDPP20_QUIRK_G305,
HIDPP20_QUIRK_G602,
HIDPP20_QUIRK_G502X_PLUS, // G502X+ uses 2nd LED slot instead of 1st.
HIDPP20_QUIRK_INDEX_OFFSET, // Device returns 1-indexed profile, decrement by 1.
};
struct hidpp20_device {

View File

@@ -227,6 +227,8 @@ init_data_hidpp20(struct ratbag *ratbag,
data->hidpp20.quirk = HIDPP20_QUIRK_G602;
else if(streq(str, "G502X_PLUS"))
data->hidpp20.quirk = HIDPP20_QUIRK_G502X_PLUS;
else if(streq(str, "INDEX_OFFSET"))
data->hidpp20.quirk = HIDPP20_QUIRK_INDEX_OFFSET;
}
}