mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-26 07:57:59 -04:00
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
This commit is contained in:
parent
b52cd67467
commit
9e111118d6
1 changed files with 17 additions and 17 deletions
34
config.c
34
config.c
|
|
@ -1956,6 +1956,20 @@ parse_section_url_bindings(struct context *ctx)
|
||||||
&ctx->conf->bindings.url);
|
&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
|
static bool
|
||||||
value_to_mouse_combos(struct context *ctx, struct key_combo_list *key_combos)
|
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;
|
int button = 0;
|
||||||
for (size_t i = 0; i < ALEN(map); i++) {
|
for (size_t i = 0; i < ALEN(button_map); i++) {
|
||||||
if (strcmp(key, map[i].name) == 0) {
|
if (strcmp(key, button_map[i].name) == 0) {
|
||||||
button = map[i].code;
|
button = button_map[i].code;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue