ignore keymodifers other than ctrl/alt/shift
authorXeli
Thu, 07 Jun 2012 22:40:28 +0200
changeset 7193 65a022bf6bde
parent 7192 e6c379b486d5
child 7195 9e6e8e5a4c2e
child 7196 4fba5519c37f
ignore keymodifers other than ctrl/alt/shift
hedgewars/SDLh.pas
hedgewars/uInputHandler.pas
--- a/hedgewars/SDLh.pas	Thu Jun 07 01:28:39 2012 +0200
+++ b/hedgewars/SDLh.pas	Thu Jun 07 22:40:28 2012 +0200
@@ -275,8 +275,8 @@
     KMOD_RSHIFT = $0002;
     KMOD_LCTRL  = $0040;
     KMOD_RCTRL  = $0080;
-    KMOD_LALT   = $0100;
-    KMOD_RALT   = $0200;
+    KMOD_LALT   = $0400;
+    KMOD_RALT   = $0800;
     KMOD_LMETA  = $0400;
     KMOD_RMETA  = $0800;
     KMOD_NUM    = $1000;
--- a/hedgewars/uInputHandler.pas	Thu Jun 07 01:28:39 2012 +0200
+++ b/hedgewars/uInputHandler.pas	Thu Jun 07 22:40:28 2012 +0200
@@ -47,6 +47,14 @@
 implementation
 uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug;
 
+const
+    LSHIFT = $0200;
+    RSHIFT = $0400;
+    LALT   = $0800;
+    RALT   = $1000;
+    LCTRL  = $2000;
+    RCTRL  = $4000; 
+
 var tkbd: array[0..cKbdMaxIndex] of boolean;
     quitKeyCode: Byte;
     KeyNames: array [0..cKeyMaxIndex] of string[15];
@@ -65,7 +73,12 @@
 
 procedure MaskModifier(var code: LongInt; Modifier: LongWord);
 begin
-    code:= code or (modifier shl 10);
+    if(Modifier and KMOD_LSHIFT) <> 0 then code:= code or LSHIFT; 
+    if(Modifier and KMOD_RSHIFT) <> 0 then code:= code or LSHIFT; 
+    if(Modifier and KMOD_LALT) <> 0 then code:= code or LALT; 
+    if(Modifier and KMOD_RALT) <> 0 then code:= code or LALT; 
+    if(Modifier and KMOD_LCTRL) <> 0 then code:= code or LCTRL; 
+    if(Modifier and KMOD_RCTRL) <> 0 then code:= code or LCTRL; 
 end;
 
 procedure MaskModifier(Modifier: shortstring; var code: LongInt);
@@ -84,12 +97,12 @@
     begin 
     mod_:= '';
     SplitByChar(Modifier, mod_, ':');
-    if (Modifier = 'lshift')                    then code:= code or (KMOD_LSHIFT shl 10);
-    if (Modifier = 'rshift')                    then code:= code or (KMOD_RSHIFT shl 10);
-    if (Modifier = 'lalt')                      then code:= code or (KMOD_LALT   shl 10);
-    if (Modifier = 'ralt')                      then code:= code or (KMOD_RALT   shl 10);
-    if (Modifier = 'lctrl') or (mod_ = 'lmeta') then code:= code or (KMOD_LCTRL  shl 10);
-    if (Modifier = 'rctrl') or (mod_ = 'rmeta') then code:= code or (KMOD_RCTRL  shl 10);
+    if (Modifier = 'lshift')                    then code:= code or LSHIFT;
+    if (Modifier = 'rshift')                    then code:= code or RSHIFT;
+    if (Modifier = 'lalt')                      then code:= code or LALT;
+    if (Modifier = 'ralt')                      then code:= code or RALT;
+    if (Modifier = 'lctrl') or (mod_ = 'lmeta') then code:= code or LCTRL;
+    if (Modifier = 'rctrl') or (mod_ = 'rmeta') then code:= code or RCTRL;
     Modifier:= mod_;
     end;
 end;
@@ -144,7 +157,6 @@
 begin
     code:= event.keysym.sym;
     MaskModifier(code, event.keysym.modifier);
-    
     ProcessKey(code, event.type_ = SDL_KEYDOWN);
 end;