]> git.tdb.fi Git - libs/gui.git/commitdiff
Fix handling of various special keys on Windows
authorMikko Rasa <tdb@tdb.fi>
Fri, 12 Jul 2013 08:41:33 +0000 (11:41 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 12 Jul 2013 08:41:33 +0000 (11:41 +0300)
source/input/windows/keyboard.cpp
source/input/windows/keys.cpp

index cbba914dd451fd133043e1f70f356a7f76c83b39..e6882fe917dd3183089460107fe8c24e162e0bf0 100644 (file)
@@ -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);
index 6501196d1fa1cdfe3df245c0a5a520ff1427da82..601146ed43aaba6e1622986b5cd085e21892d6b7 100644 (file)
@@ -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,