mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
Implement ratbag_button_has_action_type
etekcity suppports macros already, the other two don't. hidpp10 doesn't support any write stuff but let's claim we do anyway. The driver hook for this isn't ideal, read_button is called during init but we should set all this up during probe and then use read_button exclusively to update the button, not set the capabilities as well. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -588,6 +588,11 @@ etekcity_read_button(struct ratbag_button *button)
|
||||
if (action)
|
||||
button->action = *action;
|
||||
button->type = etekcity_raw_to_button_type(button->index);
|
||||
|
||||
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);
|
||||
ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_MACRO);
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -79,6 +79,10 @@ hidpp10drv_read_button(struct ratbag_button *button)
|
||||
}
|
||||
|
||||
button->type = type;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -89,6 +89,10 @@ hidpp20drv_read_button(struct ratbag_button *button)
|
||||
action = hidpp20_1b04_get_logical_mapping(mapping);
|
||||
if (action)
|
||||
button->action = *action;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -242,8 +242,16 @@ struct ratbag_button {
|
||||
unsigned index;
|
||||
enum ratbag_button_type type;
|
||||
struct ratbag_button_action action;
|
||||
uint32_t action_caps;
|
||||
};
|
||||
|
||||
static inline void
|
||||
ratbag_button_enable_action_type(struct ratbag_button *button,
|
||||
enum ratbag_button_action_type type)
|
||||
{
|
||||
button->action_caps |= 1 << type;
|
||||
}
|
||||
|
||||
static inline int
|
||||
ratbag_open_path(struct ratbag_device *device, const char *path, int flags)
|
||||
{
|
||||
|
||||
@@ -893,6 +893,23 @@ ratbag_button_get_action_type(struct ratbag_button *button)
|
||||
return button->action.type;
|
||||
}
|
||||
|
||||
LIBRATBAG_EXPORT int
|
||||
ratbag_button_has_action_type(struct ratbag_button *button,
|
||||
enum ratbag_button_action_type action_type)
|
||||
{
|
||||
switch (action_type) {
|
||||
case RATBAG_BUTTON_ACTION_TYPE_BUTTON:
|
||||
case RATBAG_BUTTON_ACTION_TYPE_SPECIAL:
|
||||
case RATBAG_BUTTON_ACTION_TYPE_KEY:
|
||||
case RATBAG_BUTTON_ACTION_TYPE_MACRO:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return !!(button->action_caps & (1 << action_type));
|
||||
}
|
||||
|
||||
LIBRATBAG_EXPORT unsigned int
|
||||
ratbag_button_get_button(struct ratbag_button *button)
|
||||
{
|
||||
|
||||
@@ -1046,7 +1046,7 @@ ratbag_button_get_action_type(struct ratbag_button *button);
|
||||
*
|
||||
* @note It is a client bug to pass in @ref
|
||||
* RATBAG_BUTTON_ACTION_TYPE_UNKNOWN or @ref
|
||||
* RATBAG_BUTTON_ACTION_TYPE_UNKNOWN.
|
||||
* RATBAG_BUTTON_ACTION_TYPE_NONE.
|
||||
*
|
||||
* @param button A previously initialized button
|
||||
* @param action_type An action type
|
||||
|
||||
@@ -10,6 +10,7 @@ global:
|
||||
ratbag_button_get_key;
|
||||
ratbag_button_get_special;
|
||||
ratbag_button_get_user_data;
|
||||
ratbag_button_has_action_type;
|
||||
ratbag_button_ref;
|
||||
ratbag_button_set_button;
|
||||
ratbag_button_set_key;
|
||||
|
||||
Reference in New Issue
Block a user