From 6fb020f5de1487484712e7113db0e86dd97481bd Mon Sep 17 00:00:00 2001 From: Vivek Jain Date: Sat, 30 Nov 2013 21:23:39 -0800 Subject: options: add option to disable using right Alt key as Alt Gr mpv was hardcoded to always consider the right Alt key as Alt Gr, but there are parituclar combinations of platforms and keyboard layouts where it's more convenient to treat the right Alt as a keyboard modifier just like the left one. Fixes #388 --- video/out/vo_sdl.c | 8 +++++--- video/out/w32_common.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'video') diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c index 6fe62b187b..86643788b9 100644 --- a/video/out/vo_sdl.c +++ b/video/out/vo_sdl.c @@ -495,11 +495,13 @@ static void check_events(struct vo *vo) case SDL_TEXTINPUT: { int sdl_mod = SDL_GetModState(); int mpv_mod = 0; - // we ignore KMOD_LSHIFT, KMOD_RSHIFT and KMOD_RALT because - // these are already factored into ev.text.text + // we ignore KMOD_LSHIFT, KMOD_RSHIFT and KMOD_RALT (if + // mp_input_use_alt_gr() is true) because these are already + // factored into ev.text.text if (sdl_mod & (KMOD_LCTRL | KMOD_RCTRL)) mpv_mod |= MP_KEY_MODIFIER_CTRL; - if (sdl_mod & KMOD_LALT) + if ((sdl_mod & KMOD_LALT) || + (sdl_mod & KMOD_RALT) && !mp_input_use_alt_gr(vo->input_ctx)) mpv_mod |= MP_KEY_MODIFIER_ALT; if (sdl_mod & (KMOD_LGUI | KMOD_RGUI)) mpv_mod |= MP_KEY_MODIFIER_META; diff --git a/video/out/w32_common.c b/video/out/w32_common.c index f5b2729956..6c5ebe1703 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -203,7 +203,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, // Windows enables Ctrl+Alt when AltGr (VK_RMENU) is pressed. // E.g. AltGr+9 on a German keyboard would yield Ctrl+Alt+[ // Warning: wine handles this differently. Don't test this on wine! - if (key_state(vo, VK_RMENU)) + if (key_state(vo, VK_RMENU) && mp_input_use_alt_gr(vo->input_ctx)) mods &= ~(MP_KEY_MODIFIER_CTRL | MP_KEY_MODIFIER_ALT); // Apparently Ctrl+A to Ctrl+Z is special cased, and produces // character codes from 1-26. Work it around. -- cgit v1.2.3