Don't allow for multiple key up(or down) events, it will ignore the excess events
authorXeli
Mon, 28 May 2012 19:15:51 +0200
changeset 7140 29948153fda2
parent 7139 a47fd17ba463
child 7141 ea6ad9a97fca
Don't allow for multiple key up(or down) events, it will ignore the excess events
hedgewars/uInputHandler.pas
--- a/hedgewars/uInputHandler.pas	Mon May 28 12:21:54 2012 -0400
+++ b/hedgewars/uInputHandler.pas	Mon May 28 19:15:51 2012 +0200
@@ -64,12 +64,17 @@
     Trusted: boolean;
     s      : string;
 begin
+
+if(tkbd[code] = ord(KeyDown)) then exit;
+tkbd[code]:= ord(KeyDown);
+
+
 hideAmmoMenu:= false;
 Trusted:= (CurrentTeam <> nil)
           and (not CurrentTeam^.ExtDriven)
           and (CurrentHedgehog^.BotLevel = 0);
 
-tkbd[code]:= ord(KeyDown);
+
 
 // ctrl/cmd + q to close engine and frontend
 if(KeyDown and (code = quitKeyCode)) then
@@ -86,13 +91,13 @@
     begin
     if (code > 3) and (KeyDown) and not ((CurrentBinds[code] = 'put') or (CurrentBinds[code] = 'ammomenu') or (CurrentBinds[code] = '+cur_u') or (CurrentBinds[code] = '+cur_d') or (CurrentBinds[code] = '+cur_l') or (CurrentBinds[code] = '+cur_r')) then hideAmmoMenu:= true;
 
-    if (KeyDown) then
+    if KeyDown then
         begin
         ParseCommand(CurrentBinds[code], Trusted);
         if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
             ParseCommand('gencmd R', true)
         end
-    else if (CurrentBinds[code][1] = '+') and not KeyDown then
+    else if (CurrentBinds[code][1] = '+') then
         begin
         s:= CurrentBinds[code];
         s[1]:= '-';
@@ -101,7 +106,6 @@
             ParseCommand('gencmd R', true)
         end;
     end
-
 end;
 
 procedure ProcessKey(event: TSDL_KeyboardEvent); inline;