From 854404a6395a5d9d2129f34c1f9bb6ec58c7425b Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Tue, 13 Jul 2021 14:34:32 +0800 Subject: terminal-unix: fix ^Z identification When using "stty susp ''" to disable sending the TSTP signal with ^Z, mpv didn't recognize ^Z correctly in the terminal: [input] No key binding found for key 'Ctrl+2'. Because ASCII 26 (^Z) and above were incorrectly considered ^. This commit moves the cutoff between letters/numbers from 25 to 26 so that ^Z is now detected correctly as ^. Additionally, it rephrases the ^ formula for clarity. --- osdep/terminal-unix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c index 86c3030cdd..1e7d874028 100644 --- a/osdep/terminal-unix.c +++ b/osdep/terminal-unix.c @@ -235,7 +235,8 @@ static void process_input(struct input_ctx *input_ctx, bool timeout) unsigned char c = buf.b[0]; skip_buf(&buf, 1); if (c < 32) { - c = c <= 25 ? (c + 'a' - 1) : (c - 25 + '2' - 1); + // 1..26 is ^A..^Z, and 27..31 is ^3..^7 + c = c <= 26 ? (c + 'a' - 1) : (c + '3' - 27); mods |= MP_KEY_MODIFIER_CTRL; } mp_input_put_key(input_ctx, c | mods); -- cgit v1.2.3