From 563550c473ff29849560007eec6808f2995152c2 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Wed, 24 Apr 2019 12:21:58 +0200 Subject: [PATCH] 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 --- src/driver-hidpp20.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/driver-hidpp20.c b/src/driver-hidpp20.c index bb990ec1..ee4ef36e 100644 --- a/src/driver-hidpp20.c +++ b/src/driver-hidpp20.c @@ -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); + } } }