summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@mplayer2.org>2012-04-07 14:47:06 +0200
committerwm4 <wm4@mplayer2.org>2012-04-07 14:47:06 +0200
commit440797ca711d098958dd4d87119c2b6870f0face (patch)
treecbcbddfb5a45e3556e556f5d490558738129505b
parent1020ae516ba5577c0fc356acad58e12a9ba56c65 (diff)
downloadmpv-440797ca711d098958dd4d87119c2b6870f0face.tar.bz2
mpv-440797ca711d098958dd4d87119c2b6870f0face.tar.xz
win32: fix behavior of enter key
Windows sends the same character code on CTRL+Enter and CTRL+J. I'm not sure what's the proper way to deal with this, but the hack added with this commit seems to work fine. Just to be sure, don't forward the modified wParam to DefWindowProc. Add the missing "break;" in the switch statement, which sometimes produced bogus mouse button events. Fix the F12 key, which wasn't mapped correctly due to a typo.
-rw-r--r--libvo/w32_common.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/libvo/w32_common.c b/libvo/w32_common.c
index 653f1f518f..dd9a427a64 100644
--- a/libvo/w32_common.c
+++ b/libvo/w32_common.c
@@ -93,7 +93,7 @@ static const struct mp_keymap vk_map[] = {
// F-keys
{VK_F1, KEY_F+1}, {VK_F2, KEY_F+2}, {VK_F3, KEY_F+3}, {VK_F4, KEY_F+4},
{VK_F5, KEY_F+5}, {VK_F6, KEY_F+6}, {VK_F7, KEY_F+7}, {VK_F8, KEY_F+8},
- {VK_F9, KEY_F+9}, {VK_F10, KEY_F+10}, {VK_F11, KEY_F+11}, {VK_F1, KEY_F+12},
+ {VK_F9, KEY_F+9}, {VK_F10, KEY_F+10}, {VK_F11, KEY_F+11}, {VK_F12, KEY_F+12},
// numpad
{VK_NUMPAD0, KEY_KP0}, {VK_NUMPAD1, KEY_KP1}, {VK_NUMPAD2, KEY_KP2},
{VK_NUMPAD3, KEY_KP3}, {VK_NUMPAD4, KEY_KP4}, {VK_NUMPAD5, KEY_KP5},
@@ -220,16 +220,22 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
case WM_CHAR:
case WM_SYSCHAR: {
int mods = mod_state();
+ int code = wParam;
// Apparently Ctrl+A to Ctrl+Z is special cased, and produces
// character codes from 1-26. Work it around.
- if ((mods & KEY_MODIFIER_CTRL) && wParam >= 1 && wParam <= 26)
- wParam = wParam - 1 + (mods & KEY_MODIFIER_SHIFT ? 'A' : 'a');
- if (wParam >= 32 && wParam < (1<<21)) {
- mplayer_put_key(wParam | mods);
+ // Also, enter/return (including the keypad variant) and CTRL+J both
+ // map to wParam==10. As a workaround, check VK_RETURN to
+ // distinguish these two key combinations.
+ if ((mods & KEY_MODIFIER_CTRL) && code >= 1 && code <= 26
+ && !key_state[VK_RETURN])
+ code = code - 1 + (mods & KEY_MODIFIER_SHIFT ? 'A' : 'a');
+ if (code >= 32 && code < (1<<21)) {
+ mplayer_put_key(code | mods);
// At least with Alt+char, not calling DefWindowProcW stops
// Windows from emitting a beep.
return 0;
}
+ break;
}
case WM_LBUTTONDOWN:
if (!vo_nomouse_input && (vo_fs || (wParam & MK_CONTROL))) {