aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfeeptr@codeberg.org <feeptr>2021-11-29 22:52:06 +0000
committerfeeptr@codeberg.org <feeptr>2021-12-02 23:47:43 +0000
commit9e111118d62a4c3264b010f71aa8622b92fb814e (patch)
tree9efb0b9cd7e12d565c11fed08132506e16029d46
parentconfig, doc, changelog: move selection-override-modifiers to [mouse-bindings] and validate other ... (diff)
config: move button_map out of value_to_mouse_combos for reuse
this mapping is only available here or in libevdev (libevdev_event_code_get_name) and it's simpler to factor it out here
-rw-r--r--config.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/config.c b/config.c
index 59d7bdab..1903e83c 100644
--- a/config.c
+++ b/config.c
@@ -1956,6 +1956,20 @@ parse_section_url_bindings(struct context *ctx)
&ctx->conf->bindings.url);
}
+static const struct {
+ const char *name;
+ int code;
+} button_map[] = {
+ {"BTN_LEFT", BTN_LEFT},
+ {"BTN_RIGHT", BTN_RIGHT},
+ {"BTN_MIDDLE", BTN_MIDDLE},
+ {"BTN_SIDE", BTN_SIDE},
+ {"BTN_EXTRA", BTN_EXTRA},
+ {"BTN_FORWARD", BTN_FORWARD},
+ {"BTN_BACK", BTN_BACK},
+ {"BTN_TASK", BTN_TASK},
+};
+
static bool
value_to_mouse_combos(struct context *ctx, struct key_combo_list *key_combos)
{
@@ -2004,24 +2018,10 @@ value_to_mouse_combos(struct context *ctx, struct key_combo_list *key_combos)
}
}
- static const struct {
- const char *name;
- int code;
- } map[] = {
- {"BTN_LEFT", BTN_LEFT},
- {"BTN_RIGHT", BTN_RIGHT},
- {"BTN_MIDDLE", BTN_MIDDLE},
- {"BTN_SIDE", BTN_SIDE},
- {"BTN_EXTRA", BTN_EXTRA},
- {"BTN_FORWARD", BTN_FORWARD},
- {"BTN_BACK", BTN_BACK},
- {"BTN_TASK", BTN_TASK},
- };
-
int button = 0;
- for (size_t i = 0; i < ALEN(map); i++) {
- if (strcmp(key, map[i].name) == 0) {
- button = map[i].code;
+ for (size_t i = 0; i < ALEN(button_map); i++) {
+ if (strcmp(key, button_map[i].name) == 0) {
+ button = button_map[i].code;
break;
}
}