mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
Don't create a button when requesting one
The drivers are responsible for initializing the buttons during probe(), then we just return the one we found Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -715,17 +715,24 @@ LIBRATBAG_EXPORT struct ratbag_button*
|
||||
ratbag_profile_get_button_by_index(struct ratbag_profile *profile,
|
||||
unsigned int index)
|
||||
{
|
||||
struct ratbag_device *device = profile->device;
|
||||
struct ratbag_button *button;
|
||||
|
||||
if (index >= ratbag_device_get_num_buttons(device))
|
||||
return NULL;
|
||||
|
||||
list_for_each(button, &profile->buttons, link) {
|
||||
if (button->index == index) {
|
||||
if (profile->device->driver->read_button)
|
||||
profile->device->driver->read_button(button);
|
||||
if (device->driver->read_button)
|
||||
device->driver->read_button(button);
|
||||
return ratbag_button_ref(button);
|
||||
}
|
||||
}
|
||||
|
||||
return ratbag_create_button(profile, index);
|
||||
log_bug_libratbag(device->ratbag, "Button %d, profile %d not found\n",
|
||||
index, profile->index);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LIBRATBAG_EXPORT enum ratbag_button_type
|
||||
|
||||
Reference in New Issue
Block a user