1
0
forked from drath/libratbag

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 <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2019-03-07 15:37:28 +10:00
committed by Yaroslav Chvanov
parent 95243307ce
commit cdf19a904e
8 changed files with 12 additions and 4 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);