mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
etekcity: fill the type field of the buttons
This adds two button types: pinkie and pinkie2 when there are buttons on the right side of the mouse. OK, I could have called them left-handed-thumb. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
@@ -100,6 +100,37 @@ print_key(uint8_t key)
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
struct etekcity_button_type_mapping {
|
||||
uint8_t raw;
|
||||
enum ratbag_button_type type;
|
||||
};
|
||||
|
||||
static const struct etekcity_button_type_mapping etekcity_button_type_mapping[] = {
|
||||
{ 0, RATBAG_BUTTON_TYPE_LEFT },
|
||||
{ 1, RATBAG_BUTTON_TYPE_RIGHT },
|
||||
{ 2, RATBAG_BUTTON_TYPE_MIDDLE },
|
||||
{ 3, RATBAG_BUTTON_TYPE_EXTRA },
|
||||
{ 4, RATBAG_BUTTON_TYPE_SIDE },
|
||||
{ 5, RATBAG_BUTTON_TYPE_RESOLUTION_CYCLE_UP },
|
||||
{ 6, RATBAG_BUTTON_TYPE_PINKIE },
|
||||
{ 7, RATBAG_BUTTON_TYPE_PINKIE2 },
|
||||
{ 8, RATBAG_BUTTON_TYPE_WHEEL_UP },
|
||||
{ 9, RATBAG_BUTTON_TYPE_WHEEL_DOWN },
|
||||
};
|
||||
|
||||
static enum ratbag_button_type
|
||||
etekcity_raw_to_button_type(uint8_t data)
|
||||
{
|
||||
const struct etekcity_button_type_mapping *mapping;
|
||||
|
||||
ARRAY_FOR_EACH(etekcity_button_type_mapping, mapping) {
|
||||
if (mapping->raw == data)
|
||||
return mapping->type;
|
||||
}
|
||||
|
||||
return RATBAG_BUTTON_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
struct etekcity_button_mapping {
|
||||
uint8_t raw;
|
||||
struct ratbag_button_action action;
|
||||
@@ -316,7 +347,7 @@ etekcity_read_button(struct ratbag_button *button)
|
||||
button->index, print_key(data), data, __FILE__, __LINE__);
|
||||
action = etekcity_raw_to_button_action(data);
|
||||
button->action = *action;
|
||||
/* FIXME: button->type needs a separate lookup table */
|
||||
button->type = etekcity_raw_to_button_type(button->index);
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -436,6 +436,8 @@ enum ratbag_button_type {
|
||||
RATBAG_BUTTON_TYPE_WHEEL_RATCHET_MODE_SHIFT,
|
||||
RATBAG_BUTTON_TYPE_EXTRA,
|
||||
RATBAG_BUTTON_TYPE_SIDE,
|
||||
RATBAG_BUTTON_TYPE_PINKIE,
|
||||
RATBAG_BUTTON_TYPE_PINKIE2,
|
||||
|
||||
/* DPI switch */
|
||||
RATBAG_BUTTON_TYPE_RESOLUTION_CYCLE_UP,
|
||||
|
||||
@@ -147,6 +147,8 @@ button_type_to_str(enum ratbag_button_type type)
|
||||
case RATBAG_BUTTON_TYPE_WHEEL_DOWN: str = "wheel down"; break;
|
||||
case RATBAG_BUTTON_TYPE_EXTRA: str = "extra (forward)"; break;
|
||||
case RATBAG_BUTTON_TYPE_SIDE: str = "side (backward)"; break;
|
||||
case RATBAG_BUTTON_TYPE_PINKIE: str = "pinkie"; break;
|
||||
case RATBAG_BUTTON_TYPE_PINKIE2: str = "pinkie2"; break;
|
||||
|
||||
/* DPI switch */
|
||||
case RATBAG_BUTTON_TYPE_RESOLUTION_CYCLE_UP: str = "resolution cycle up"; break;
|
||||
|
||||
Reference in New Issue
Block a user