From: Mikko Rasa Date: Fri, 12 Jul 2013 08:41:33 +0000 (+0300) Subject: Fix handling of various special keys on Windows X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=a1341ef0d1e5a153a97fee929f11c3655ff5a8ea;p=libs%2Fgui.git Fix handling of various special keys on Windows --- diff --git a/source/input/windows/keyboard.cpp b/source/input/windows/keyboard.cpp index cbba914..e6882fe 100644 --- a/source/input/windows/keyboard.cpp +++ b/source/input/windows/keyboard.cpp @@ -14,10 +14,14 @@ std::string Keyboard::get_button_name(unsigned btn) const if(btn==KEY_NONE) return "None"; + unsigned vkey = key_to_sys(btn); + unsigned scan = MapVirtualKey(vkey&0xFF, MAPVK_VK_TO_VSC); + scan |= vkey&0x100; + char buf[128]; - unsigned scan = MapVirtualKey(key_to_sys(btn), MAPVK_VK_TO_VSC); if(!GetKeyNameText(scan<<16, buf, sizeof(buf))) return Device::get_button_name(btn); + return buf; } @@ -27,7 +31,17 @@ void Keyboard::input_event(const Graphics::Window::Event &event) { case WM_KEYDOWN: case WM_KEYUP: - set_button_state(key_from_sys(event.wparam), event.msg==WM_KEYDOWN, true); + { + unsigned key = event.wparam | ((event.lparam>>16)&0x100); + if(key==VK_SHIFT) + { + if(((event.lparam>>16)&0xFF)==MapVirtualKey(VK_RSHIFT, MAPVK_VK_TO_VSC)) + key = VK_RSHIFT; + else + key = VK_LSHIFT; + } + set_button_state(key_from_sys(key), event.msg==WM_KEYDOWN, true); + } break; case WM_CHAR: signal_character.emit(event.wparam); diff --git a/source/input/windows/keys.cpp b/source/input/windows/keys.cpp index 6501196..601146e 100644 --- a/source/input/windows/keys.cpp +++ b/source/input/windows/keys.cpp @@ -31,15 +31,15 @@ unsigned sys_keymap[N_KEYS_]= 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, 0, 0, 0, 0, - VK_HOME, VK_END, VK_PRIOR, VK_NEXT, VK_INSERT, VK_DELETE, 0, 0, + VK_LEFT|0x100, VK_RIGHT|0x100, VK_UP|0x100, VK_DOWN|0x100, 0, 0, 0, 0, + VK_HOME|0x100, VK_END|0x100, VK_PRIOR|0x100, VK_NEXT|0x100, VK_INSERT|0x100, VK_DELETE|0x100, 0, 0, 0, VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12, 0, 0, 0, - VK_LSHIFT, VK_RSHIFT, VK_LCONTROL, VK_RCONTROL, 0, 0, VK_LWIN, VK_RWIN, - VK_CAPITAL, VK_SCROLL, VK_NUMLOCK, 0, 0, 0, 0, 0, + VK_LSHIFT, VK_RSHIFT, VK_CONTROL, VK_CONTROL|0x100, 0, 0, VK_LWIN, VK_RWIN, + VK_CAPITAL, VK_SCROLL, VK_NUMLOCK|0x100, 0, 0, 0, 0, 0, VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3, VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7, - VK_NUMPAD8, VK_NUMPAD9, VK_ADD, VK_SUBTRACT, VK_MULTIPLY, VK_DIVIDE, VK_SEPARATOR, 0, + VK_NUMPAD8, VK_NUMPAD9, VK_ADD, VK_SUBTRACT, VK_MULTIPLY, VK_DIVIDE|0x100, VK_SEPARATOR, 0, VK_PAUSE, VK_SNAPSHOT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,