summaryrefslogtreecommitdiffstats
path: root/client/windows/platform.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'client/windows/platform.cpp')
-rw-r--r--client/windows/platform.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/client/windows/platform.cpp b/client/windows/platform.cpp
index 24c9ca93..6b218404 100644
--- a/client/windows/platform.cpp
+++ b/client/windows/platform.cpp
@@ -444,7 +444,7 @@ static void toggle_modifier(int key)
SendInput(2, inputs, sizeof(INPUT));
}
-uint32_t Platform::get_keyboard_modifiers()
+uint32_t Platform::get_keyboard_lock_modifiers()
{
uint32_t modifiers = 0;
if ((GetKeyState(VK_SCROLL) & 1)) {
@@ -459,7 +459,7 @@ uint32_t Platform::get_keyboard_modifiers()
return modifiers;
}
-void Platform::set_keyboard_modifiers(uint32_t modifiers)
+void Platform::set_keyboard_lock_modifiers(uint32_t modifiers)
{
if (((modifiers >> SCROLL_LOCK_MODIFIER_SHIFT) & 1) != (GetKeyState(VK_SCROLL) & 1)) {
toggle_modifier(VK_SCROLL);
@@ -474,6 +474,23 @@ void Platform::set_keyboard_modifiers(uint32_t modifiers)
}
}
+#define KEY_BIT(keymap, key, bit) (keymap[key] & 0x80 ? bit : 0)
+
+uint32_t Platform::get_keyboard_modifiers()
+{
+ BYTE keymap[256];
+
+ if (!GetKeyboardState(keymap)) {
+ return 0;
+ }
+ return KEY_BIT(keymap, VK_LSHIFT, L_SHIFT_MODIFIER) |
+ KEY_BIT(keymap, VK_RSHIFT, R_SHIFT_MODIFIER) |
+ KEY_BIT(keymap, VK_LCONTROL, L_CTRL_MODIFIER) |
+ KEY_BIT(keymap, VK_RCONTROL, R_CTRL_MODIFIER) |
+ KEY_BIT(keymap, VK_LMENU, L_ALT_MODIFIER) |
+ KEY_BIT(keymap, VK_RMENU, R_ALT_MODIFIER);
+}
+
class WinBaseLocalCursor: public LocalCursor {
public:
WinBaseLocalCursor() : _handle (0) {}