summaryrefslogtreecommitdiff
path: root/alsamixer/proc_files.c
diff options
context:
space:
mode:
authorbraph <braph93@gmx.de>2019-09-26 22:27:25 +0200
committerJaroslav Kysela <perex@perex.cz>2020-07-01 16:10:35 +0200
commit6e9e84ba609c8e86a15c0eb17aa89df11de14cdf (patch)
treef06ec5ab7faf7af1a6313dc3d254459c2a639df2 /alsamixer/proc_files.c
parent706a64c7a0f16f24bb845278086569d6cbe4ee6f (diff)
downloadalsa-utils-6e9e84ba609c8e86a15c0eb17aa89df11de14cdf.tar.gz
alsamixer: Replaced hardcoded keys by binding arrays
This commit is a preparation for making keybindings configurable. The hardcoded keys in the switch statements of mixer_widget.c, textbox.c, proc_files.c and card_select.c have been replaced by command enums. The command that shall be executed is looked up in the arrays `mixer_bindings` and `textbox_bindings`. The channel_mask enum has been made public, since LEFT and RIGHT are used as command arguments in bindings.c. Signed-off-by: Benjamin Abendroth <braph93@gmx.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'alsamixer/proc_files.c')
-rw-r--r--alsamixer/proc_files.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/alsamixer/proc_files.c b/alsamixer/proc_files.c
index b2f5f21..9d3fe3f 100644
--- a/alsamixer/proc_files.c
+++ b/alsamixer/proc_files.c
@@ -28,6 +28,7 @@
#include "widget.h"
#include "textbox.h"
#include "proc_files.h"
+#include "bindings.h"
static struct widget proc_widget;
static ITEM *items[7];
@@ -36,25 +37,12 @@ static MENU *menu;
static void on_menu_key(int key)
{
- static const struct {
- int key;
- int request;
- } key_map[] = {
- { KEY_DOWN, REQ_DOWN_ITEM },
- { KEY_UP, REQ_UP_ITEM },
- { KEY_HOME, REQ_FIRST_ITEM },
- { KEY_NPAGE, REQ_SCR_DPAGE },
- { KEY_PPAGE, REQ_SCR_UPAGE },
- { KEY_BEG, REQ_FIRST_ITEM },
- { KEY_END, REQ_LAST_ITEM },
- };
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(key_map); ++i)
- if (key_map[i].key == key) {
- menu_driver(menu, key_map[i].request);
- break;
- }
+ if (key < ARRAY_SIZE(textbox_bindings)) {
+ key = textbox_bindings[key];
+ if (key >= CMD_TEXTBOX___MIN_MENU_COMMAND &&
+ key <= CMD_TEXTBOX___MAX_MENU_COMMAND)
+ menu_driver(menu, key + KEY_MAX);
+ }
}
static void on_handle_key(int key)