hedgewars/uKeys.pas
changeset 109 ab0340f580c2
parent 42 72ffe21f027c
child 161 d8870bbf960e
equal deleted inserted replaced
108:08f1fe6f21f8 109:ab0340f580c2
    41 procedure ProcessKbdDemo;
    41 procedure ProcessKbdDemo;
    42 procedure InitKbdKeyTable;
    42 procedure InitKbdKeyTable;
    43 
    43 
    44 implementation
    44 implementation
    45 uses SDLh, uTeams, uConsole, uConsts, uMisc;
    45 uses SDLh, uTeams, uConsole, uConsts, uMisc;
    46 
    46 const KeyNumber = 1024;
    47 type TKeyboardState = array[0..322] of Byte;
    47 type TKeyboardState = array[0..cKeyMaxIndex] of Byte;
    48 var tkbd: TKeyboardState;
    48 var tkbd: TKeyboardState;
    49     KeyNames: array [0..cKeyMaxIndex] of string[15];
    49     KeyNames: array [0..cKeyMaxIndex] of string[15];
    50 
    50 
    51 function KeyNameToCode(name: string): word;
    51 function KeyNameToCode(name: string): word;
    52 begin
    52 begin
    99 procedure ResetKbd;
    99 procedure ResetKbd;
   100 var i, t: integer;
   100 var i, t: integer;
   101     pkbd: PByteArray;
   101     pkbd: PByteArray;
   102 begin
   102 begin
   103 pkbd:= PByteArray(SDL_GetKeyState(@i));
   103 pkbd:= PByteArray(SDL_GetKeyState(@i));
       
   104 TryDo(i < cKeyMaxIndex, 'SDL keys number is more than expected (' + inttostr(i) + ')', true);
   104 for t:= 0 to Pred(i) do
   105 for t:= 0 to Pred(i) do
   105     tkbd[i]:= pkbd^[i]
   106     tkbd[i]:= pkbd^[i]
   106 end;
   107 end;
   107 
   108 
   108 procedure InitKbdKeyTable;
   109 procedure InitKbdKeyTable;