diff options
author | wm4 <wm4@nowhere> | 2014-08-26 20:39:28 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-08-26 20:39:28 +0200 |
commit | b7f72aa2f401037177149dde1a178c55741b0ff2 (patch) | |
tree | 047f65d467e5168ba8cd64efcc9ef1bb0d359d0c /input/input.c | |
parent | 480febf043be47f21b322c03abbcac953a67c468 (diff) | |
download | mpv-b7f72aa2f401037177149dde1a178c55741b0ff2.tar.bz2 mpv-b7f72aa2f401037177149dde1a178c55741b0ff2.tar.xz |
input: make key bindings like "Shift+X" work (for ASCII)
"Shift+X" didn't actually map any key, as opposed to "Shift+x". This is
because shift usually changes the case of a character, so a plain
printable character like "X" simply can never be combined with shift.
But this is not very intuitive. Always remove the shift code from
printable characters. Also, for ASCII, actually apply the case mapping
to uppercase characters if combined with shift. Doing this for unicode
in general would be nice, but that would require lookup tables. In
general, we don't know anyway what character a key produces when
combined with shift - it could be anything, and depends on the keyboard
layout.
Diffstat (limited to 'input/input.c')
-rw-r--r-- | input/input.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/input/input.c b/input/input.c index 1dd029219f..e85d16ccd2 100644 --- a/input/input.c +++ b/input/input.c @@ -613,15 +613,6 @@ static struct mp_cmd *resolve_key(struct input_ctx *ictx, int code) static void interpret_key(struct input_ctx *ictx, int code, double scale) { - /* On normal keyboards shift changes the character code of non-special - * keys, so don't count the modifier separately for those. In other words - * we want to have "a" and "A" instead of "a" and "Shift+A"; but a separate - * shift modifier is still kept for special keys like arrow keys. - */ - int unmod = code & ~MP_KEY_MODIFIER_MASK; - if (unmod >= 32 && unmod < MP_KEY_BASE) - code &= ~MP_KEY_MODIFIER_SHIFT; - int state = code & (MP_KEY_STATE_DOWN | MP_KEY_STATE_UP); code = code & ~(unsigned)state; @@ -633,7 +624,7 @@ static void interpret_key(struct input_ctx *ictx, int code, double scale) talloc_free(key); } - if (MP_KEY_DEPENDS_ON_MOUSE_POS(unmod)) + if (MP_KEY_DEPENDS_ON_MOUSE_POS(code & ~MP_KEY_MODIFIER_MASK)) ictx->mouse_event_counter++; mp_input_wakeup(ictx); @@ -687,6 +678,7 @@ static void interpret_key(struct input_ctx *ictx, int code, double scale) static void mp_input_feed_key(struct input_ctx *ictx, int code, double scale) { + code = mp_normalize_keycode(code); int unmod = code & ~MP_KEY_MODIFIER_MASK; if (code == MP_INPUT_RELEASE_ALL) { MP_DBG(ictx, "release all\n"); |