config: reuse mousebind_button_from_str()

This commit is contained in:
Jens Peters 2024-01-06 17:56:32 +01:00 committed by Johan Malm
parent 4c59a8c3d7
commit e51c3fc5d4
3 changed files with 1 additions and 16 deletions

View file

@ -20,7 +20,6 @@ struct button_map_entry {
double tablet_get_dbl_if_positive(const char *content, const char *name); double tablet_get_dbl_if_positive(const char *content, const char *name);
enum rotation tablet_parse_rotation(int value); enum rotation tablet_parse_rotation(int value);
uint32_t tablet_button_from_str(const char *button); uint32_t tablet_button_from_str(const char *button);
uint32_t mouse_button_from_str(const char *button);
void tablet_button_mapping_add(uint32_t from, uint32_t to); void tablet_button_mapping_add(uint32_t from, uint32_t to);
void tablet_load_default_button_mappings(void); void tablet_load_default_button_mappings(void);

View file

@ -868,7 +868,7 @@ entry(xmlNode *node, char *nodename, char *content)
button_map_from = tablet_button_from_str(content); button_map_from = tablet_button_from_str(content);
} else if (!strcasecmp(nodename, "to.map.tablet")) { } else if (!strcasecmp(nodename, "to.map.tablet")) {
if (button_map_from != UINT32_MAX) { if (button_map_from != UINT32_MAX) {
uint32_t button_map_to = mouse_button_from_str(content); uint32_t button_map_to = mousebind_button_from_str(content, NULL);
if (button_map_to != UINT32_MAX) { if (button_map_to != UINT32_MAX) {
tablet_button_mapping_add(button_map_from, button_map_to); tablet_button_mapping_add(button_map_from, button_map_to);
} }

View file

@ -72,20 +72,6 @@ tablet_button_from_str(const char *button)
return UINT32_MAX; return UINT32_MAX;
} }
uint32_t
mouse_button_from_str(const char *button)
{
if (!strcasecmp(button, "Left")) {
return BTN_LEFT;
} else if (!strcasecmp(button, "Right")) {
return BTN_RIGHT;
} else if (!strcasecmp(button, "Middle")) {
return BTN_MIDDLE;
}
wlr_log(WLR_ERROR, "Invalid value for mouse button: %s", button);
return UINT32_MAX;
}
void void
tablet_button_mapping_add(uint32_t from, uint32_t to) tablet_button_mapping_add(uint32_t from, uint32_t to)
{ {