From 3146e4ea4d668de5e31b66253b40bb3039b904a0 Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 17 Mar 2012 22:43:53 +0000 Subject: [PATCH] Fixed check if alt key is pressed. --- linux/system.cpp | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/linux/system.cpp b/linux/system.cpp index f7c70d9a..342b5676 100644 --- a/linux/system.cpp +++ b/linux/system.cpp @@ -86,22 +86,35 @@ void Sys_FinishMemoryRender(void* param) // Misc stuff // FIXME: should have a table of LC_KEY_* defined -bool Sys_KeyDown (int key) +bool Sys_KeyDown(int Key) { - char keys[32]; - int x; + char keys[32]; + int x; - XQueryKeymap (GDK_DISPLAY (), keys); + XQueryKeymap(GDK_DISPLAY(), keys); - x = XKeysymToKeycode (GDK_DISPLAY (), XK_Control_L); - if (keys[x/8] & (1 << (x % 8))) - return true; + if (Key == KEY_CONTROL) + { + x = XKeysymToKeycode(GDK_DISPLAY(), XK_Control_L); + if (keys[x/8] & (1 << (x % 8))) + return true; - x = XKeysymToKeycode (GDK_DISPLAY (), XK_Control_R); - if (keys[x/8] & (1 << (x % 8))) - return true; + x = XKeysymToKeycode(GDK_DISPLAY(), XK_Control_R); + if (keys[x/8] & (1 << (x % 8))) + return true; + } + else if (Key == KEY_ALT) + { + x = XKeysymToKeycode(GDK_DISPLAY(), XK_Alt_L); + if (keys[x/8] & (1 << (x % 8))) + return true; - return false; + x = XKeysymToKeycode(GDK_DISPLAY(), XK_Alt_R); + if (keys[x/8] & (1 << (x % 8))) + return true; + } + + return false; }