From 28280240cbb2ab361138781041bf93a1fdf0da75 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Thu, 27 Aug 2015 18:10:44 -0400 Subject: [PATCH] read only once from the mouse given that we create all the buttons and profiles during probe(), there is no need to re-probe for it every time we access it. Right now, this works because only ratbag-command uses the library and is a one shot program. In the future, we should also read the events to detect changes in the configuration if the user can use physical buttons to change the profile, dpi or something else. Signed-off-by: Benjamin Tissoires --- src/libratbag.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/libratbag.c b/src/libratbag.c index 47abd2aa..7e4de53e 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -633,11 +633,8 @@ ratbag_device_get_profile_by_index(struct ratbag_device *device, unsigned int in return NULL; list_for_each(profile, &device->profiles, link) { - if (profile->index == index) { - assert(device->driver->read_profile); - device->driver->read_profile(profile, index); + if (profile->index == index) return ratbag_profile_ref(profile); - } } log_bug_libratbag(device->ratbag, "Profile %d not found\n", index); @@ -801,11 +798,8 @@ ratbag_profile_get_button_by_index(struct ratbag_profile *profile, return NULL; list_for_each(button, &profile->buttons, link) { - if (button->index == index) { - if (device->driver->read_button) - device->driver->read_button(button); + if (button->index == index) return ratbag_button_ref(button); - } } log_bug_libratbag(device->ratbag, "Button %d, profile %d not found\n", @@ -829,9 +823,6 @@ ratbag_button_get_action_type(struct ratbag_button *button) LIBRATBAG_EXPORT unsigned int ratbag_button_get_button(struct ratbag_button *button) { - if (!button->profile->device->driver->read_button) - return 0; /* FIXME */ - if (button->action.type != RATBAG_BUTTON_ACTION_TYPE_BUTTON) return 0; @@ -858,9 +849,6 @@ ratbag_button_set_button(struct ratbag_button *button, unsigned int btn) LIBRATBAG_EXPORT enum ratbag_button_action_special ratbag_button_get_special(struct ratbag_button *button) { - if (!button->profile->device->driver->read_button) - return -ENOTSUP; - if (button->action.type != RATBAG_BUTTON_ACTION_TYPE_SPECIAL) return 0; @@ -892,9 +880,6 @@ ratbag_button_get_key(struct ratbag_button *button, unsigned int *modifiers, size_t *sz) { - if (!button->profile->device->driver->read_button) - return 0; - if (button->action.type != RATBAG_BUTTON_ACTION_TYPE_KEY) return 0;