mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 15:14:38 +01:00
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:
@@ -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
|
||||
|
||||
@@ -3,3 +3,6 @@ Name=Logitech G502 Hero
|
||||
DeviceMatch=usb:046d:c08b
|
||||
Driver=hidpp20
|
||||
DeviceType=mouse
|
||||
|
||||
[Driver/hidpp20]
|
||||
Quirk=INDEX_OFFSET
|
||||
|
||||
@@ -3,3 +3,6 @@ Name=Logitech G502 Proteus Spectrum
|
||||
DeviceMatch=usb:046d:c332
|
||||
Driver=hidpp20
|
||||
DeviceType=mouse
|
||||
|
||||
[Driver/hidpp20]
|
||||
Quirk=INDEX_OFFSET
|
||||
|
||||
@@ -3,3 +3,6 @@ Name=Logitech G604
|
||||
DeviceMatch=usb:046d:4085;bluetooth:046d:b024
|
||||
Driver=hidpp20
|
||||
DeviceType=mouse
|
||||
|
||||
[Driver/hidpp20]
|
||||
Quirk=INDEX_OFFSET
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user