From 08d7c6997dccbbea6bd98f4c3670b95ce7ae1c07 Mon Sep 17 00:00:00 2001 From: Yaroslav Chvanov Date: Sat, 21 Jan 2023 14:08:53 +0300 Subject: [PATCH] sinowealth: move active profile index and debounce time getting to init They were out of place being directly in the `probe` function. Also, this will make more sense once we add an API for changing debounce times. --- src/driver-sinowealth.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/driver-sinowealth.c b/src/driver-sinowealth.c index 4692767e..89d77332 100644 --- a/src/driver-sinowealth.c +++ b/src/driver-sinowealth.c @@ -1532,6 +1532,11 @@ sinowealth_init_profile(struct ratbag_device *device) if (rc) return rc; + rc = sinowealth_get_active_profile(device); + if (rc < 0) + return rc; + log_debug(device->ratbag, "Active profile index: %d\n", rc); + const struct sinowealth_device_data *device_data = sinowealth_find_device_data(device, fw_version); if (device_data == NULL) { @@ -1558,6 +1563,18 @@ sinowealth_init_profile(struct ratbag_device *device) ratbag_device_init_profiles(device, SINOWEALTH_NUM_PROFILES, SINOWEALTH_NUM_DPIS, drv_data->button_count, drv_data->led_count); + rc = sinowealth_get_debounce_time(device); + /* Seems like some mice don't support debounce time changing. + * + * Examples: + * - ANT Esports GM500 (libratbag/libratbag#1296). + */ + if (rc >= 0) { + log_debug(device->ratbag, "Debounce time: %d ms\n", rc); + } else { + log_debug(device->ratbag, "Device doesn't support debounce time changing\n"); + } + /* Generate DPI list */ unsigned int dpis[num_dpis]; for (unsigned int i = 0; i < num_dpis; i++) { @@ -1749,14 +1766,6 @@ sinowealth_probe(struct ratbag_device *device) sinowealth_update_profile_from_buttons(profile); } - rc = sinowealth_get_active_profile(device); - if (rc >= 0) - log_debug(device->ratbag, "Current profile index: %d\n", rc); - - rc = sinowealth_get_debounce_time(device); - if (rc >= 0) - log_info(device->ratbag, "Debounce time: %d ms\n", rc); - if (drv_data->is_long) sinowealth_print_long_lod_and_anglesnapping(device);