hedgewars/uKeys.pas
changeset 7006 6af78154dc62
parent 6852 9e724f4863a3
parent 7003 e118ee168577
child 7009 23131a8b4c3a
equal deleted inserted replaced
6852:9e724f4863a3 7006:6af78154dc62
     1 (*
       
     2  * Hedgewars, a free turn based strategy game
       
     3  * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or modify
       
     6  * it under the terms of the GNU General Public License as published by
       
     7  * the Free Software Foundation; version 2 of the License
       
     8  *
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12  * GNU General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU General Public License
       
    15  * along with this program; if not, write to the Free Software
       
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
       
    17  *)
       
    18 
       
    19 {$INCLUDE "options.inc"}
       
    20 
       
    21 unit uKeys;
       
    22 interface
       
    23 uses SDLh, uTypes;
       
    24 
       
    25 procedure initModule;
       
    26 procedure freeModule;
       
    27 
       
    28 function  KeyNameToCode(name: shortstring): word;
       
    29 procedure ProcessKbd;
       
    30 procedure ResetKbd;
       
    31 procedure FreezeEnterKey;
       
    32 procedure InitKbdKeyTable;
       
    33 
       
    34 procedure SetBinds(var binds: TBinds);
       
    35 procedure SetDefaultBinds;
       
    36 
       
    37 procedure ControllerInit;
       
    38 procedure ControllerClose;
       
    39 procedure ControllerAxisEvent(joy, axis: Byte; value: Integer);
       
    40 procedure ControllerHatEvent(joy, hat, value: Byte);
       
    41 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean);
       
    42 
       
    43 {$IFDEF MOBILE}
       
    44 procedure setiPhoneBinds;
       
    45 {$ENDIF}
       
    46 
       
    47 implementation
       
    48 uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug;
       
    49 
       
    50 var tkbd, tkbdn: TKeyboardState;
       
    51     KeyNames: array [0..cKeyMaxIndex] of string[15];
       
    52 
       
    53 function KeyNameToCode(name: shortstring): word;
       
    54 var code: Word;
       
    55 begin
       
    56     code:= cKeyMaxIndex;
       
    57     while (code > 0) and (KeyNames[code] <> name) do dec(code);
       
    58     KeyNameToCode:= code;
       
    59 end;
       
    60 
       
    61 
       
    62 procedure ProcessKbd;
       
    63 var  i, j, k: LongInt;
       
    64      s: shortstring;
       
    65      Trusted: boolean;
       
    66 {$IFNDEF MOBILE}pkbd: PByteArray;{$ENDIF}
       
    67 begin
       
    68 hideAmmoMenu:= false;
       
    69 Trusted:= (CurrentTeam <> nil)
       
    70           and (not CurrentTeam^.ExtDriven)
       
    71           and (CurrentHedgehog^.BotLevel = 0);
       
    72 
       
    73 // move cursor/camera
       
    74 // TODO: Scale on screen dimensions and/or axis value (game controller)?
       
    75 movecursor(5 * CursorMovementX, 5 * CursorMovementY);
       
    76 
       
    77 k:= SDL_GetMouseState(nil, nil);
       
    78 
       
    79 {$IFDEF MOBILE}
       
    80 SDL_GetKeyState(@j);
       
    81 {$ELSE}
       
    82 pkbd:= SDL_GetKeyState(@j);
       
    83 for i:= 6 to pred(j) do // first 6 will be overwritten
       
    84     tkbdn[i]:= pkbd^[i];
       
    85 {$ENDIF}
       
    86 
       
    87 // mouse buttons
       
    88 {$IFDEF DARWIN}
       
    89 tkbdn[1]:= ((k and 1) and not (tkbdn[306] or tkbdn[305]));
       
    90 tkbdn[3]:= ((k and 1) and (tkbdn[306] or tkbdn[305])) or (k and 4);
       
    91 {$ELSE}
       
    92 tkbdn[1]:= (k and 1);
       
    93 tkbdn[3]:= ((k shr 2) and 1);
       
    94 {$ENDIF}
       
    95 tkbdn[2]:= ((k shr 1) and 1);
       
    96 
       
    97 // mouse wheels
       
    98 tkbdn[4]:= ord(wheelDown);
       
    99 tkbdn[5]:= ord(wheelUp);
       
   100 wheelUp:= false;
       
   101 wheelDown:= false;
       
   102 
       
   103 {$IFDEF MOBILE}
       
   104 setiPhoneBinds();
       
   105 {$ELSE}
       
   106 // Controller(s)
       
   107 k:= j; // should we test k for hitting the limit? sounds rather unlikely to ever reach it
       
   108 for j:= 0 to Pred(ControllerNumControllers) do
       
   109     begin
       
   110     for i:= 0 to Pred(ControllerNumAxes[j]) do
       
   111         begin
       
   112         if ControllerAxes[j][i] > 20000 then
       
   113             tkbdn[k + 0]:= 1
       
   114         else
       
   115             tkbdn[k + 0]:= 0;
       
   116         if ControllerAxes[j][i] < -20000 then
       
   117             tkbdn[k + 1]:= 1
       
   118         else
       
   119             tkbdn[k + 1]:= 0;
       
   120         inc(k, 2);
       
   121         end;
       
   122     for i:= 0 to Pred(ControllerNumHats[j]) do
       
   123         begin
       
   124         tkbdn[k + 0]:= ControllerHats[j][i] and SDL_HAT_UP;
       
   125         tkbdn[k + 1]:= ControllerHats[j][i] and SDL_HAT_RIGHT;
       
   126         tkbdn[k + 2]:= ControllerHats[j][i] and SDL_HAT_DOWN;
       
   127         tkbdn[k + 3]:= ControllerHats[j][i] and SDL_HAT_LEFT;
       
   128         inc(k, 4);
       
   129         end;
       
   130     for i:= 0 to Pred(ControllerNumButtons[j]) do
       
   131         begin
       
   132         tkbdn[k]:= ControllerButtons[j][i];
       
   133         inc(k, 1);
       
   134         end;
       
   135     end;
       
   136 {$ENDIF}
       
   137 
       
   138 // ctrl/cmd + q to close engine and frontend
       
   139 {$IFDEF DARWIN}
       
   140     if ((tkbdn[KeyNameToCode('left_meta')] = 1) or (tkbdn[KeyNameToCode('right_meta')] = 1)) then
       
   141         {$ELSE}
       
   142     if ((tkbdn[KeyNameToCode('left_ctrl')] = 1) or (tkbdn[KeyNameToCode('right_ctrl')] = 1)) then
       
   143         {$ENDIF}
       
   144     begin
       
   145         if tkbdn[KeyNameToCode('q')] = 1 then ParseCommand ('halt', true)
       
   146     end;
       
   147 
       
   148 // now process strokes
       
   149 for i:= 0 to cKeyMaxIndex do
       
   150 if CurrentBinds[i][0] <> #0 then
       
   151     begin
       
   152     if (i > 3) and (tkbdn[i] <> 0) and not ((CurrentBinds[i] = 'put') or (CurrentBinds[i] = 'ammomenu') or (CurrentBinds[i] = '+cur_u') or (CurrentBinds[i] = '+cur_d') or (CurrentBinds[i] = '+cur_l') or (CurrentBinds[i] = '+cur_r')) then hideAmmoMenu:= true;
       
   153     if (tkbd[i] = 0) and (tkbdn[i] <> 0) then
       
   154         begin
       
   155         ParseCommand(CurrentBinds[i], Trusted);
       
   156         if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
       
   157             ParseCommand('gencmd R', true)
       
   158         end
       
   159     else if (CurrentBinds[i][1] = '+') and (tkbdn[i] = 0) and (tkbd[i] <> 0) then
       
   160         begin
       
   161         s:= CurrentBinds[i];
       
   162         s[1]:= '-';
       
   163         ParseCommand(s, Trusted);
       
   164         if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
       
   165             ParseCommand('gencmd R', true)
       
   166         end;
       
   167     tkbd[i]:= tkbdn[i]
       
   168     end
       
   169 end;
       
   170 
       
   171 procedure ResetKbd;
       
   172 var j, k, t: LongInt;
       
   173 {$IFNDEF MOBILE}
       
   174     i: LongInt;
       
   175     pkbd: PByteArray;
       
   176 {$ENDIF}
       
   177 begin
       
   178 
       
   179 k:= SDL_GetMouseState(nil, nil);
       
   180 {$IFNDEF MOBILE}pkbd:={$ENDIF}SDL_GetKeyState(@j);
       
   181 
       
   182 TryDo(j < cKeyMaxIndex, 'SDL keys number is more than expected (' + IntToStr(j) + ')', true);
       
   183 
       
   184 {$IFNDEF MOBILE}
       
   185 for i:= 1 to pred(j) do
       
   186     tkbdn[i]:= pkbd^[i];
       
   187 {$ENDIF}
       
   188 
       
   189 // mouse buttons
       
   190 {$IFDEF DARWIN}
       
   191 tkbdn[1]:= ((k and 1) and not (tkbdn[306] or tkbdn[305]));
       
   192 tkbdn[3]:= ((k and 1) and (tkbdn[306] or tkbdn[305])) or (k and 4);
       
   193 {$ELSE}
       
   194 tkbdn[1]:= (k and 1);
       
   195 tkbdn[3]:= ((k shr 2) and 1);
       
   196 {$ENDIF}
       
   197 tkbdn[2]:= ((k shr 1) and 1);
       
   198 
       
   199 // mouse wheels
       
   200 tkbdn[4]:= ord(wheelDown);
       
   201 tkbdn[5]:= ord(wheelUp);
       
   202 wheelUp:= false;
       
   203 wheelDown:= false;
       
   204 
       
   205 {$IFDEF MOBILE}
       
   206 setiPhoneBinds();
       
   207 {$ELSE}
       
   208 // Controller(s)
       
   209 k:= j; // should we test k for hitting the limit? sounds rather unlikely to ever reach it
       
   210 for j:= 0 to Pred(ControllerNumControllers) do
       
   211     begin
       
   212     for i:= 0 to Pred(ControllerNumAxes[j]) do
       
   213         begin
       
   214         if ControllerAxes[j][i] > 20000 then
       
   215             tkbdn[k + 0]:= 1
       
   216         else
       
   217             tkbdn[k + 0]:= 0;
       
   218         if ControllerAxes[j][i] < -20000 then
       
   219             tkbdn[k + 1]:= 1
       
   220         else
       
   221             tkbdn[k + 1]:= 0;
       
   222         inc(k, 2);
       
   223         end;
       
   224     for i:= 0 to Pred(ControllerNumHats[j]) do
       
   225         begin
       
   226         tkbdn[k + 0]:= ControllerHats[j][i] and SDL_HAT_UP;
       
   227         tkbdn[k + 1]:= ControllerHats[j][i] and SDL_HAT_RIGHT;
       
   228         tkbdn[k + 2]:= ControllerHats[j][i] and SDL_HAT_DOWN;
       
   229         tkbdn[k + 3]:= ControllerHats[j][i] and SDL_HAT_LEFT;
       
   230         inc(k, 4);
       
   231         end;
       
   232     for i:= 0 to Pred(ControllerNumButtons[j]) do
       
   233         begin
       
   234         tkbdn[k]:= ControllerButtons[j][i];
       
   235         inc(k, 1);
       
   236         end;
       
   237     end;
       
   238 {$ENDIF}
       
   239 
       
   240 // what is this final loop for?
       
   241 for t:= 0 to cKeyMaxIndex do
       
   242     tkbd[t]:= tkbdn[t]
       
   243 end;
       
   244 
       
   245 procedure InitKbdKeyTable;
       
   246 var i, j, k, t: LongInt;
       
   247     s: string[15];
       
   248 begin
       
   249 KeyNames[1]:= 'mousel';
       
   250 KeyNames[2]:= 'mousem';
       
   251 KeyNames[3]:= 'mouser';
       
   252 KeyNames[4]:= 'wheelup';
       
   253 KeyNames[5]:= 'wheeldown';
       
   254 
       
   255 for i:= 6 to cKeyMaxIndex do
       
   256     begin
       
   257     s:= shortstring(sdl_getkeyname(i));
       
   258     //writeln(stdout,IntToStr(i) + ': ' + s);
       
   259     if s = 'unknown key' then KeyNames[i]:= ''
       
   260     else 
       
   261         begin
       
   262         for t:= 1 to Length(s) do
       
   263             if s[t] = ' ' then
       
   264                 s[t]:= '_';
       
   265         KeyNames[i]:= s
       
   266         end;
       
   267     end;
       
   268 
       
   269 //for i:= 0 to cKeyMaxIndex do writeln(stdout,IntToStr(i) + ': ' + KeyNames[i]);
       
   270 
       
   271 // get the size of keyboard array
       
   272 SDL_GetKeyState(@k);
       
   273 
       
   274 // Controller(s)
       
   275 for j:= 0 to Pred(ControllerNumControllers) do
       
   276     begin
       
   277     for i:= 0 to Pred(ControllerNumAxes[j]) do
       
   278         begin
       
   279         keynames[k + 0]:= 'j' + IntToStr(j) + 'a' + IntToStr(i) + 'u';
       
   280         keynames[k + 1]:= 'j' + IntToStr(j) + 'a' + IntToStr(i) + 'd';
       
   281         inc(k, 2);
       
   282         end;
       
   283     for i:= 0 to Pred(ControllerNumHats[j]) do
       
   284         begin
       
   285         keynames[k + 0]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'u';
       
   286         keynames[k + 1]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'r';
       
   287         keynames[k + 2]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'd';
       
   288         keynames[k + 3]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'l';
       
   289         inc(k, 4);
       
   290         end;
       
   291     for i:= 0 to Pred(ControllerNumButtons[j]) do
       
   292         begin
       
   293         keynames[k]:= 'j' + IntToStr(j) + 'b' + IntToStr(i);
       
   294         inc(k, 1);
       
   295         end;
       
   296     end;
       
   297 
       
   298 DefaultBinds[ 27]:= 'quit';
       
   299 DefaultBinds[ 96]:= 'history';
       
   300 DefaultBinds[127]:= 'rotmask';
       
   301 
       
   302 //numpad
       
   303 //DefaultBinds[265]:= '+volup';
       
   304 //DefaultBinds[256]:= '+voldown';
       
   305 
       
   306 DefaultBinds[KeyNameToCode('0')]:= '+volup';
       
   307 DefaultBinds[KeyNameToCode('9')]:= '+voldown';
       
   308 DefaultBinds[KeyNameToCode('c')]:= 'capture';
       
   309 DefaultBinds[KeyNameToCode('h')]:= 'findhh';
       
   310 DefaultBinds[KeyNameToCode('p')]:= 'pause';
       
   311 DefaultBinds[KeyNameToCode('s')]:= '+speedup';
       
   312 DefaultBinds[KeyNameToCode('t')]:= 'chat';
       
   313 DefaultBinds[KeyNameToCode('y')]:= 'confirm';
       
   314 
       
   315 DefaultBinds[KeyNameToCode('mousem')]:= 'zoomreset';
       
   316 DefaultBinds[KeyNameToCode('wheelup')]:= 'zoomout';
       
   317 DefaultBinds[KeyNameToCode('wheeldown')]:= 'zoomin';
       
   318 
       
   319 DefaultBinds[KeyNameToCode('f12')]:= 'fullscr';
       
   320 
       
   321 
       
   322 DefaultBinds[ 1]:= '/put';
       
   323 DefaultBinds[ 3]:= 'ammomenu';
       
   324 DefaultBinds[ 8]:= 'hjump';
       
   325 DefaultBinds[ 9]:= 'switch';
       
   326 DefaultBinds[13]:= 'ljump';
       
   327 DefaultBinds[32]:= '+attack';
       
   328 {$IFDEF MOBILE}
       
   329 DefaultBinds[23]:= '+up';
       
   330 DefaultBinds[24]:= '+down';
       
   331 DefaultBinds[25]:= '+left';
       
   332 DefaultBinds[26]:= '+right';
       
   333 DefaultBinds[27]:= '+precise';
       
   334 DefaultBinds[44]:= 'chat';
       
   335 DefaultBinds[55]:= 'pause';
       
   336 {$ELSE}
       
   337 DefaultBinds[KeyNameToCode('up')]:= '+up';
       
   338 DefaultBinds[KeyNameToCode('down')]:= '+down';
       
   339 DefaultBinds[KeyNameToCode('left')]:= '+left';
       
   340 DefaultBinds[KeyNameToCode('right')]:= '+right';
       
   341 DefaultBinds[KeyNameToCode('left_shift')]:= '+precise';
       
   342 {$ENDIF}
       
   343 
       
   344 for i:= 1 to 10 do DefaultBinds[KeyNameToCode('f'+IntToStr(i))]:= 'slot '+IntToStr(i);
       
   345 for i:= 1 to 5  do DefaultBinds[KeyNameToCode(IntToStr(i))]:= 'timer '+IntToStr(i);
       
   346 
       
   347 SetDefaultBinds();
       
   348 end;
       
   349 
       
   350 procedure SetBinds(var binds: TBinds);
       
   351 begin
       
   352 {$IFDEF MOBILE}
       
   353     binds:= binds; // avoid hint
       
   354     CurrentBinds:= DefaultBinds;
       
   355 {$ELSE}
       
   356     CurrentBinds:= binds;
       
   357 {$ENDIF}
       
   358 end;
       
   359 
       
   360 procedure SetDefaultBinds;
       
   361 begin
       
   362     CurrentBinds:= DefaultBinds;
       
   363 end;
       
   364 
       
   365 {$IFDEF MOBILE}
       
   366 procedure setiPhoneBinds;
       
   367 begin
       
   368     tkbdn[ 1]:= ord(leftClick);
       
   369     tkbdn[ 2]:= ord(middleClick);
       
   370     tkbdn[ 3]:= ord(rightClick);
       
   371 
       
   372     tkbdn[23]:= ord(upKey);
       
   373     tkbdn[24]:= ord(downKey);
       
   374     tkbdn[25]:= ord(leftKey);
       
   375     tkbdn[26]:= ord(rightKey);
       
   376     tkbdn[27]:= ord(preciseKey);
       
   377 
       
   378     tkbdn[ 8]:= ord(backspaceKey);
       
   379     tkbdn[ 9]:= ord(tabKey);
       
   380     tkbdn[13]:= ord(enterKey);
       
   381     tkbdn[32]:= ord(spaceKey);
       
   382 
       
   383     tkbdn[44]:= ord(chatAction);
       
   384     tkbdn[55]:= ord(pauseAction);
       
   385 
       
   386     // set to false the keys that only need one stoke
       
   387     leftClick:= false;
       
   388     middleClick:= false;
       
   389     rightClick:= false;
       
   390 
       
   391     tabKey:= false;
       
   392     enterKey:= false;
       
   393     backspaceKey:= false;
       
   394 
       
   395     chatAction:= false;
       
   396     pauseAction:= false;
       
   397 end;
       
   398 {$ENDIF}
       
   399 
       
   400 procedure FreezeEnterKey;
       
   401 begin
       
   402     tkbd[3]:= 1;
       
   403     tkbd[13]:= 1;
       
   404     tkbd[27]:= 1;
       
   405     tkbd[271]:= 1;
       
   406 end;
       
   407 
       
   408 var Controller: array [0..5] of PSDL_Joystick;
       
   409 
       
   410 procedure ControllerInit;
       
   411 var i, j: Integer;
       
   412 begin
       
   413 ControllerEnabled:= 0;
       
   414 {$IFDEF MOBILE}
       
   415 exit; // joystick subsystem disabled on iPhone
       
   416 {$ENDIF}
       
   417 
       
   418 SDL_InitSubSystem(SDL_INIT_JOYSTICK);
       
   419 ControllerNumControllers:= SDL_NumJoysticks();
       
   420 
       
   421 if ControllerNumControllers > 6 then
       
   422     ControllerNumControllers:= 6;
       
   423 
       
   424 WriteLnToConsole('Number of game controllers: ' + IntToStr(ControllerNumControllers));
       
   425 
       
   426 if ControllerNumControllers > 0 then
       
   427     begin
       
   428     for j:= 0 to pred(ControllerNumControllers) do
       
   429         begin
       
   430         WriteLnToConsole('Using game controller: ' + SDL_JoystickName(j));
       
   431         Controller[j]:= SDL_JoystickOpen(j);
       
   432         if Controller[j] = nil then
       
   433             WriteLnToConsole('* Failed to open game controller!')
       
   434         else
       
   435             begin
       
   436             ControllerNumAxes[j]:= SDL_JoystickNumAxes(Controller[j]);
       
   437             //ControllerNumBalls[j]:= SDL_JoystickNumBalls(Controller[j]);
       
   438             ControllerNumHats[j]:= SDL_JoystickNumHats(Controller[j]);
       
   439             ControllerNumButtons[j]:= SDL_JoystickNumButtons(Controller[j]);
       
   440             WriteLnToConsole('* Number of axes: ' + IntToStr(ControllerNumAxes[j]));
       
   441             //WriteLnToConsole('* Number of balls: ' + IntToStr(ControllerNumBalls[j]));
       
   442             WriteLnToConsole('* Number of hats: ' + IntToStr(ControllerNumHats[j]));
       
   443             WriteLnToConsole('* Number of buttons: ' + IntToStr(ControllerNumButtons[j]));
       
   444             ControllerEnabled:= 1;
       
   445 
       
   446             if ControllerNumAxes[j] > 20 then
       
   447                 ControllerNumAxes[j]:= 20;
       
   448             //if ControllerNumBalls[j] > 20 then ControllerNumBalls[j]:= 20;
       
   449             
       
   450             if ControllerNumHats[j] > 20 then
       
   451                 ControllerNumHats[j]:= 20;
       
   452                 
       
   453             if ControllerNumButtons[j] > 20 then
       
   454                 ControllerNumButtons[j]:= 20;
       
   455 
       
   456             // reset all buttons/axes
       
   457             for i:= 0 to pred(ControllerNumAxes[j]) do
       
   458                 ControllerAxes[j][i]:= 0;
       
   459             (*for i:= 0 to pred(ControllerNumBalls[j]) do
       
   460                 begin
       
   461                 ControllerBalls[j][i][0]:= 0;
       
   462                 ControllerBalls[j][i][1]:= 0;
       
   463                 end;*)
       
   464             for i:= 0 to pred(ControllerNumHats[j]) do
       
   465                 ControllerHats[j][i]:= SDL_HAT_CENTERED;
       
   466             for i:= 0 to pred(ControllerNumButtons[j]) do
       
   467                 ControllerButtons[j][i]:= 0;
       
   468             end;
       
   469         end;
       
   470     // enable event generation/controller updating
       
   471     SDL_JoystickEventState(1);
       
   472     end
       
   473 else
       
   474     WriteLnToConsole('Not using any game controller');
       
   475 end;
       
   476 
       
   477 procedure ControllerClose;
       
   478 var j: Integer;
       
   479 begin
       
   480     if ControllerEnabled > 0 then
       
   481         for j:= 0 to pred(ControllerNumControllers) do
       
   482             SDL_JoystickClose(Controller[j]);
       
   483 end;
       
   484 
       
   485 procedure ControllerAxisEvent(joy, axis: Byte; value: Integer);
       
   486 begin
       
   487     ControllerAxes[joy][axis]:= value;
       
   488 end;
       
   489 
       
   490 procedure ControllerHatEvent(joy, hat, value: Byte);
       
   491 begin
       
   492     ControllerHats[joy][hat]:= value;
       
   493 end;
       
   494 
       
   495 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean);
       
   496 begin
       
   497     if pressed then
       
   498         ControllerButtons[joy][button]:= 1
       
   499     else
       
   500         ControllerButtons[joy][button]:= 0;
       
   501 end;
       
   502 
       
   503 procedure initModule;
       
   504 begin
       
   505     wheelUp:= false;
       
   506     wheelDown:= false;
       
   507 {$IFDEF HWLIBRARY}
       
   508     // this function is called by HW_allKeysUp so be careful
       
   509 
       
   510     // mouse emulation
       
   511     leftClick:= false;
       
   512     middleClick:= false;
       
   513     rightClick:= false;
       
   514 
       
   515     // arrow key emulation
       
   516     upKey:= false;
       
   517     downKey:= false;
       
   518     rightKey:= false;
       
   519     leftKey:= false;
       
   520     preciseKey:= false;
       
   521 
       
   522     // action key emulation
       
   523     backspaceKey:= false;
       
   524     spaceKey:= false;
       
   525     enterKey:= false;
       
   526     tabKey:= false;
       
   527 
       
   528     // other key emulation
       
   529     chatAction:= false;
       
   530     pauseAction:= false;
       
   531 {$ENDIF}
       
   532 end;
       
   533 
       
   534 procedure freeModule;
       
   535 begin
       
   536 
       
   537 end;
       
   538 
       
   539 end.