hedgewars/uInputHandler.pas
changeset 7140 29948153fda2
parent 7118 dcdbb6fcc924
child 7141 ea6ad9a97fca
equal deleted inserted replaced
7139:a47fd17ba463 7140:29948153fda2
    62 procedure ProcessKey(code: LongInt; KeyDown: boolean);
    62 procedure ProcessKey(code: LongInt; KeyDown: boolean);
    63 var
    63 var
    64     Trusted: boolean;
    64     Trusted: boolean;
    65     s      : string;
    65     s      : string;
    66 begin
    66 begin
       
    67 
       
    68 if(tkbd[code] = ord(KeyDown)) then exit;
       
    69 tkbd[code]:= ord(KeyDown);
       
    70 
       
    71 
    67 hideAmmoMenu:= false;
    72 hideAmmoMenu:= false;
    68 Trusted:= (CurrentTeam <> nil)
    73 Trusted:= (CurrentTeam <> nil)
    69           and (not CurrentTeam^.ExtDriven)
    74           and (not CurrentTeam^.ExtDriven)
    70           and (CurrentHedgehog^.BotLevel = 0);
    75           and (CurrentHedgehog^.BotLevel = 0);
    71 
    76 
    72 tkbd[code]:= ord(KeyDown);
    77 
    73 
    78 
    74 // ctrl/cmd + q to close engine and frontend
    79 // ctrl/cmd + q to close engine and frontend
    75 if(KeyDown and (code = quitKeyCode)) then
    80 if(KeyDown and (code = quitKeyCode)) then
    76     begin
    81     begin
    77 {$IFDEF DARWIN}
    82 {$IFDEF DARWIN}
    84 
    89 
    85 if CurrentBinds[code][0] <> #0 then
    90 if CurrentBinds[code][0] <> #0 then
    86     begin
    91     begin
    87     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;
    92     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;
    88 
    93 
    89     if (KeyDown) then
    94     if KeyDown then
    90         begin
    95         begin
    91         ParseCommand(CurrentBinds[code], Trusted);
    96         ParseCommand(CurrentBinds[code], Trusted);
    92         if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
    97         if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
    93             ParseCommand('gencmd R', true)
    98             ParseCommand('gencmd R', true)
    94         end
    99         end
    95     else if (CurrentBinds[code][1] = '+') and not KeyDown then
   100     else if (CurrentBinds[code][1] = '+') then
    96         begin
   101         begin
    97         s:= CurrentBinds[code];
   102         s:= CurrentBinds[code];
    98         s[1]:= '-';
   103         s[1]:= '-';
    99         ParseCommand(s, Trusted);
   104         ParseCommand(s, Trusted);
   100         if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
   105         if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
   101             ParseCommand('gencmd R', true)
   106             ParseCommand('gencmd R', true)
   102         end;
   107         end;
   103     end
   108     end
   104 
       
   105 end;
   109 end;
   106 
   110 
   107 procedure ProcessKey(event: TSDL_KeyboardEvent); inline;
   111 procedure ProcessKey(event: TSDL_KeyboardEvent); inline;
   108 begin
   112 begin
   109     ProcessKey(event.keysym.sym, event.type_ = SDL_KEYDOWN);
   113     ProcessKey(event.keysym.sym, event.type_ = SDL_KEYDOWN);