diff --git a/src/driver-hidpp20.c b/src/driver-hidpp20.c index b776301c..d70688cc 100644 --- a/src/driver-hidpp20.c +++ b/src/driver-hidpp20.c @@ -1209,9 +1209,7 @@ hidpp20drv_read_profile_8100(struct ratbag_profile *profile) profile->is_enabled = drv_data->profiles->profiles[profile->index].enabled; - profile->is_active = false; - if ((int)profile->index == hidpp20drv_current_profile(device)) - profile->is_active = true; + profile->is_active = (profile->index == drv_data->profiles->active_profile_index); if (profile->is_active) dpi_index = hidpp20_onboard_profiles_get_current_dpi_index(drv_data->dev); diff --git a/src/hidpp20.c b/src/hidpp20.c index e117a7c9..32e6feed 100644 --- a/src/hidpp20.c +++ b/src/hidpp20.c @@ -2244,8 +2244,7 @@ hidpp20_onboard_profiles_allocate(struct hidpp20_device *device, { struct hidpp20_onboard_profiles_info info = { 0 }; struct hidpp20_profiles *profiles; - int onboard_mode; - int rc; + int onboard_mode, active_profile_index, rc; rc = hidpp20_onboard_profiles_get_profiles_desc(device, &info); if (rc) @@ -2269,6 +2268,12 @@ hidpp20_onboard_profiles_allocate(struct hidpp20_device *device, return rc; } + rc = hidpp20_onboard_profiles_get_current_profile(device); + if (rc < 0) + return rc; + + active_profile_index = rc; + profiles = zalloc(sizeof(struct hidpp20_profiles)); profiles->profiles = zalloc(info.profile_count * sizeof(struct hidpp20_profile)); profiles->sector_size = info.sector_size; @@ -2280,6 +2285,7 @@ hidpp20_onboard_profiles_allocate(struct hidpp20_device *device, profiles->num_leds = HIDPP20_LED_COUNT; profiles->has_g_shift = (info.mechanical_layout & 0x03) == 0x02; profiles->has_dpi_shift = ((info.mechanical_layout & 0x0c) >> 2) == 0x02; + profiles->active_profile_index = active_profile_index; switch(info.various_info & 0x07) { case 1: profiles->corded = 1; diff --git a/src/hidpp20.h b/src/hidpp20.h index 8ae9f888..8970115f 100644 --- a/src/hidpp20.h +++ b/src/hidpp20.h @@ -915,6 +915,7 @@ struct hidpp20_profiles { uint8_t wireless; uint8_t sector_count; uint16_t sector_size; + uint8_t active_profile_index; struct hidpp20_profile *profiles; };