diff options
Diffstat (limited to 'input')
-rw-r--r-- | input/input.c | 7 | ||||
-rw-r--r-- | input/keycodes.c | 4 | ||||
-rw-r--r-- | input/keycodes.h | 7 |
3 files changed, 14 insertions, 4 deletions
diff --git a/input/input.c b/input/input.c index 87956cf2b9..89ef1ace90 100644 --- a/input/input.c +++ b/input/input.c @@ -456,7 +456,12 @@ static mp_cmd_t *get_cmd_from_keys(struct input_ctx *ictx, char *force_section, if (ictx->opts->test) return handle_test(ictx, code); - struct cmd_bind *cmd = find_any_bind_for_key(ictx, force_section, code); + struct cmd_bind *cmd = NULL; + + if (MP_KEY_IS_UNICODE(code)) + cmd = find_any_bind_for_key(ictx, force_section, MP_KEY_ANY_UNICODE); + if (!cmd) + cmd = find_any_bind_for_key(ictx, force_section, code); if (!cmd) cmd = find_any_bind_for_key(ictx, force_section, MP_KEY_UNMAPPED); if (!cmd) { diff --git a/input/keycodes.c b/input/keycodes.c index a03f07e59a..3d7fd09d11 100644 --- a/input/keycodes.c +++ b/input/keycodes.c @@ -208,6 +208,7 @@ static const struct key_name key_names[] = { { MP_KEY_MOUSE_ENTER, "MOUSE_ENTER" }, { MP_KEY_UNMAPPED, "UNMAPPED" }, + { MP_KEY_ANY_UNICODE, "ANY_UNICODE" }, { 0, NULL } }; @@ -271,8 +272,7 @@ static void mp_input_append_key_name(bstr *buf, int key) } } - // printable, and valid unicode range - if (key >= 32 && key <= 0x10FFFF) { + if (MP_KEY_IS_UNICODE(key)) { mp_append_utf8_bstr(NULL, buf, key); return; } diff --git a/input/keycodes.h b/input/keycodes.h index 12b45e528a..7385440851 100644 --- a/input/keycodes.h +++ b/input/keycodes.h @@ -22,6 +22,10 @@ // Special keys come after this. #define MP_KEY_BASE (1<<21) +// printable, and valid unicode range (we don't care too much about whether +// certain sub-ranges are reserved and disallowed, like surrogate pairs) +#define MP_KEY_IS_UNICODE(key) ((key) >= 32 && (key) <= 0x10FFFF) + #define MP_KEY_ENTER 13 #define MP_KEY_TAB 9 @@ -210,7 +214,8 @@ (MP_KEY_IS_MOUSE_CLICK(code) || MP_KEY_IS_MOUSE_MOVE(code)) // No input source should generate this. -#define MP_KEY_UNMAPPED (MP_KEY_INTERN+4) +#define MP_KEY_UNMAPPED (MP_KEY_INTERN+4) +#define MP_KEY_ANY_UNICODE (MP_KEY_INTERN+5) // Emit a command even on key-up (normally key-up is ignored). This means by // default they binding will be triggered on key-up instead of key-down. |