hedgewars/uKeys.pas
changeset 2152 a2811690da1b
parent 2008 fc2fb5c938c3
child 2162 2bce91404d49
equal deleted inserted replaced
2151:541d3a475442 2152:a2811690da1b
    60 KbdKeyPressed:= false;
    60 KbdKeyPressed:= false;
    61 Trusted:= (CurrentTeam <> nil)
    61 Trusted:= (CurrentTeam <> nil)
    62           and (not CurrentTeam^.ExtDriven)
    62           and (not CurrentTeam^.ExtDriven)
    63           and (CurrentHedgehog^.BotLevel = 0);
    63           and (CurrentHedgehog^.BotLevel = 0);
    64 
    64 
       
    65 {$IFDEF SDL13}
       
    66 pkbd:= SDL_GetKeyboardState(nil);
       
    67 {$ELSE}
    65 pkbd:= SDL_GetKeyState(nil);
    68 pkbd:= SDL_GetKeyState(nil);
       
    69 {$ENDIF}
    66 i:= SDL_GetMouseState(nil, nil);
    70 i:= SDL_GetMouseState(nil, nil);
    67 pkbd^[1]:= (i and 1);
    71 pkbd^[1]:= (i and 1);
    68 pkbd^[2]:= ((i shr 1) and 1);
    72 pkbd^[2]:= ((i shr 1) and 1);
       
    73 {$IFDEF DARWIN}
       
    74 //    normal right click     ||      ctrl (left/right) + left click	  
       
    75 pkbd^[3]:= ((i shr 2) and 1) or ((i and 1) and (pkbd^[306] or pkbd^[305]));
       
    76 {$ELSE}
    69 pkbd^[3]:= ((i shr 2) and 1);
    77 pkbd^[3]:= ((i shr 2) and 1);
       
    78 {$ENDIF}
       
    79 
    70 for i:= 1 to cKeyMaxIndex do
    80 for i:= 1 to cKeyMaxIndex do
    71 if CurrentBinds[i][0] <> #0 then
    81 if CurrentBinds[i][0] <> #0 then
    72 	begin
    82 	begin
    73 	if (i > 3) and (pkbd^[i] <> 0) then KbdKeyPressed:= true;
    83 	if (i > 3) and (pkbd^[i] <> 0) then KbdKeyPressed:= true;
    74 	if (tkbd[i] = 0) and (pkbd^[i] <> 0) then ParseCommand(CurrentBinds[i], Trusted)
    84 	if (tkbd[i] = 0) and (pkbd^[i] <> 0) then ParseCommand(CurrentBinds[i], Trusted)
    86 
    96 
    87 procedure ResetKbd;
    97 procedure ResetKbd;
    88 var i, t: LongInt;
    98 var i, t: LongInt;
    89     pkbd: PByteArray;
    99     pkbd: PByteArray;
    90 begin
   100 begin
       
   101 {$IFDEF SDL13}
       
   102 pkbd:= PByteArray(SDL_GetKeyboardState(@i));
       
   103 {$ELSE}
    91 pkbd:= PByteArray(SDL_GetKeyState(@i));
   104 pkbd:= PByteArray(SDL_GetKeyState(@i));
       
   105 {$ENDIF}
    92 TryDo(i < cKeyMaxIndex, 'SDL keys number is more than expected (' + inttostr(i) + ')', true);
   106 TryDo(i < cKeyMaxIndex, 'SDL keys number is more than expected (' + inttostr(i) + ')', true);
    93 for t:= 0 to Pred(i) do
   107 for t:= 0 to Pred(i) do
    94     tkbd[i]:= pkbd^[i]
   108     tkbd[i]:= pkbd^[i]
    95 end;
   109 end;
    96 
   110