From cdf19a904e2a3d5632e341ab09c240edef4cd200 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 7 Mar 2019 15:37:28 +1000 Subject: [PATCH] libratbag: Fix the action type NONE handling Add the required hooks which were largely missing, remove a check that was a copy/paste error and add a test button. Signed-off-by: Peter Hutterer --- src/driver-etekcity.c | 1 + src/driver-gskill.c | 1 + src/driver-hidpp10.c | 1 + src/driver-hidpp20.c | 2 ++ src/driver-logitech-g300.c | 1 + src/driver-logitech-g600.c | 1 + src/driver-test.c | 4 ++++ src/libratbag.c | 5 +---- 8 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/driver-etekcity.c b/src/driver-etekcity.c index 8dfda15c..6f6eb87d 100644 --- a/src/driver-etekcity.c +++ b/src/driver-etekcity.c @@ -371,6 +371,7 @@ etekcity_read_button(struct ratbag_button *button) ratbag_button_set_action(button, action); button->type = etekcity_raw_to_button_type(button->index); + ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_NONE); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_BUTTON); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_KEY); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_SPECIAL); diff --git a/src/driver-gskill.c b/src/driver-gskill.c index 5296deaa..9df8e267 100644 --- a/src/driver-gskill.c +++ b/src/driver-gskill.c @@ -1164,6 +1164,7 @@ gskill_read_button(struct ratbag_button *button) button->type = gskill_button_type_mapping[button->index]; + ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_NONE); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_BUTTON); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_SPECIAL); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_KEY); diff --git a/src/driver-hidpp10.c b/src/driver-hidpp10.c index 06ebc87c..1a0c1bc8 100644 --- a/src/driver-hidpp10.c +++ b/src/driver-hidpp10.c @@ -295,6 +295,7 @@ hidpp10drv_read_button(struct ratbag_button *button) button->type = type; + ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_NONE); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_BUTTON); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_KEY); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_SPECIAL); diff --git a/src/driver-hidpp20.c b/src/driver-hidpp20.c index d70688cc..4b6aa278 100644 --- a/src/driver-hidpp20.c +++ b/src/driver-hidpp20.c @@ -109,6 +109,7 @@ hidpp20drv_read_button_1b04(struct ratbag_button *button) if (action) ratbag_button_set_action(button, action); + ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_NONE); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_BUTTON); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_KEY); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_SPECIAL); @@ -258,6 +259,7 @@ hidpp20drv_read_button_8100(struct ratbag_button *button) } } + ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_NONE); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_BUTTON); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_KEY); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_SPECIAL); diff --git a/src/driver-logitech-g300.c b/src/driver-logitech-g300.c index e0286646..6b9ccdd6 100644 --- a/src/driver-logitech-g300.c +++ b/src/driver-logitech-g300.c @@ -352,6 +352,7 @@ logitech_g300_read_button(struct ratbag_button *button) profile_report = &pdata->report; button_report = &profile_report->buttons[button->index]; + ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_NONE); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_BUTTON); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_SPECIAL); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_KEY); diff --git a/src/driver-logitech-g600.c b/src/driver-logitech-g600.c index d82d7e2d..1868b88c 100644 --- a/src/driver-logitech-g600.c +++ b/src/driver-logitech-g600.c @@ -355,6 +355,7 @@ logitech_g600_read_button(struct ratbag_button *button) profile_report = &pdata->report; button_report = &profile_report->buttons[button->index]; + ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_NONE); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_BUTTON); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_SPECIAL); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_KEY); diff --git a/src/driver-test.c b/src/driver-test.c index 5e02a343..b68b80f4 100644 --- a/src/driver-test.c +++ b/src/driver-test.c @@ -55,6 +55,9 @@ test_read_button(struct ratbag_button *button) button->type = d->profiles[0].buttons[button->index].button_type; switch (b->action_type) { + case RATBAG_BUTTON_ACTION_TYPE_NONE: + button->action.type = RATBAG_BUTTON_ACTION_TYPE_NONE; + break; case RATBAG_BUTTON_ACTION_TYPE_BUTTON: button->action.type = RATBAG_BUTTON_ACTION_TYPE_BUTTON; button->action.action.button = p->buttons[button->index].button; @@ -84,6 +87,7 @@ test_read_button(struct ratbag_button *button) button->action.type = RATBAG_BUTTON_ACTION_TYPE_UNKNOWN; } + ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_NONE); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_BUTTON); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_KEY); ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_SPECIAL); diff --git a/src/libratbag.c b/src/libratbag.c index c78585b1..c9270566 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -1203,6 +1203,7 @@ ratbag_button_has_action_type(struct ratbag_button *button, enum ratbag_button_action_type action_type) { switch (action_type) { + case RATBAG_BUTTON_ACTION_TYPE_NONE: case RATBAG_BUTTON_ACTION_TYPE_BUTTON: case RATBAG_BUTTON_ACTION_TYPE_SPECIAL: case RATBAG_BUTTON_ACTION_TYPE_KEY: @@ -1330,10 +1331,6 @@ ratbag_button_disable(struct ratbag_button *button) { struct ratbag_button_action action = {0}; - if (!ratbag_button_has_action_type(button, - RATBAG_BUTTON_ACTION_TYPE_KEY)) - return RATBAG_ERROR_CAPABILITY; - action.type = RATBAG_BUTTON_ACTION_TYPE_NONE; ratbag_button_set_action(button, &action);