driver-hidpp20: use the correct active dpi index

There is no guarantees the current value of dpi_index will be correct.
On my G502 the profiles are read in reverse order meaning that setting the
dpi_index can be applied to a wrong value.

Look for the correct libratbag dpi index before setting it.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
Benjamin Tissoires
2019-04-24 12:21:58 +02:00
committed by Peter Hutterer
parent a04f2d1c24
commit 563550c473

View File

@@ -1254,9 +1254,14 @@ hidpp20drv_commit(struct ratbag_device *device)
return RATBAG_ERROR_DEVICE;
list_for_each(profile, &device->profiles, link) {
if (profile->is_active)
if (profile->is_active) {
ratbag_profile_for_each_resolution(profile, resolution) {
if (resolution->is_active)
dpi_index = resolution->index;
}
hidpp20_onboard_profiles_set_current_dpi_index(drv_data->dev,
dpi_index);
}
}
}