hedgewars/uKeys.pas
changeset 3347 5d0ac8197eb7
parent 3221 3e6586c1ab4f
child 3407 dcc129c4352e
equal deleted inserted replaced
3346:967fd96f7373 3347:5d0ac8197eb7
    58     ControllerHats: array[0..5] of array[0..19] of Byte;
    58     ControllerHats: array[0..5] of array[0..19] of Byte;
    59     ControllerButtons: array[0..5] of array[0..19] of Byte;
    59     ControllerButtons: array[0..5] of array[0..19] of Byte;
    60 
    60 
    61     DefaultBinds, CurrentBinds: TBinds;
    61     DefaultBinds, CurrentBinds: TBinds;
    62 
    62 
       
    63     coeff: LongInt;
    63 {$IFDEF IPHONEOS}
    64 {$IFDEF IPHONEOS}
    64     leftClick: boolean;
    65     leftClick: boolean;
    65     middleClick: boolean;
    66     middleClick: boolean;
    66     rightClick: boolean;
    67     rightClick: boolean;
    67 
    68 
    78     chatAction: boolean;
    79     chatAction: boolean;
    79     pauseAction: boolean;
    80     pauseAction: boolean;
    80     switchAction: boolean;
    81     switchAction: boolean;
    81 
    82 
    82     theJoystick: PSDL_Joystick;
    83     theJoystick: PSDL_Joystick;
       
    84     
       
    85     cursorUp: boolean;
       
    86     cursorDown: boolean;
       
    87     cursorLeft: boolean;
       
    88     cursorRight: boolean;
    83     
    89     
    84 procedure setiPhoneBinds;
    90 procedure setiPhoneBinds;
    85 {$ENDIF}
    91 {$ENDIF}
    86 implementation
    92 implementation
    87 uses uTeams, uConsole, uMisc, uStore;
    93 uses uTeams, uConsole, uMisc, uStore;
   110           and (not CurrentTeam^.ExtDriven)
   116           and (not CurrentTeam^.ExtDriven)
   111           and (CurrentHedgehog^.BotLevel = 0);
   117           and (CurrentHedgehog^.BotLevel = 0);
   112 
   118 
   113 // move cursor/camera
   119 // move cursor/camera
   114 // TODO: Scale on screen dimensions and/or axis value (game controller)?
   120 // TODO: Scale on screen dimensions and/or axis value (game controller)?
   115 movecursor(5 * CursorMovementX, 5 * CursorMovementY);
   121 movecursor(coeff * CursorMovementX, coeff * CursorMovementY);
   116 
   122 
   117 k:= SDL_GetMouseState(nil, nil);
   123 k:= SDL_GetMouseState(nil, nil);
   118 
   124 
   119 {$IFDEF IPHONEOS}
   125 {$IFDEF IPHONEOS}
   120 SDL_GetKeyState(@j);
   126 SDL_GetKeyState(@j);
   324 DefaultBinds[KeyNameToCode('wheeldown')]:= 'zoomin';
   330 DefaultBinds[KeyNameToCode('wheeldown')]:= 'zoomin';
   325 
   331 
   326 DefaultBinds[KeyNameToCode('f12')]:= 'fullscr';
   332 DefaultBinds[KeyNameToCode('f12')]:= 'fullscr';
   327 
   333 
   328 
   334 
   329 
       
   330 DefaultBinds[ 1]:= '/put';
   335 DefaultBinds[ 1]:= '/put';
   331 DefaultBinds[ 3]:= 'ammomenu';
   336 DefaultBinds[ 3]:= 'ammomenu';
   332 DefaultBinds[ 8]:= 'hjump';
   337 DefaultBinds[ 8]:= 'hjump';
   333 DefaultBinds[ 9]:= 'switch';
   338 DefaultBinds[ 9]:= 'switch';
   334 DefaultBinds[13]:= 'ljump';
   339 DefaultBinds[13]:= 'ljump';
   338 DefaultBinds[24]:= '+down';
   343 DefaultBinds[24]:= '+down';
   339 DefaultBinds[25]:= '+left';
   344 DefaultBinds[25]:= '+left';
   340 DefaultBinds[26]:= '+right';
   345 DefaultBinds[26]:= '+right';
   341 DefaultBinds[44]:= 'chat';
   346 DefaultBinds[44]:= 'chat';
   342 DefaultBinds[55]:= 'pause';
   347 DefaultBinds[55]:= 'pause';
       
   348 DefaultBinds[66]:= '+cur_u';
       
   349 DefaultBinds[67]:= '+cur_d';
       
   350 DefaultBinds[68]:= '+cur_l';
       
   351 DefaultBinds[69]:= '+cur_r';
   343 {$ELSE}
   352 {$ELSE}
   344 DefaultBinds[KeyNameToCode('up')]:= '+up';
   353 DefaultBinds[KeyNameToCode('up')]:= '+up';
   345 DefaultBinds[KeyNameToCode('down')]:= '+down';
   354 DefaultBinds[KeyNameToCode('down')]:= '+down';
   346 DefaultBinds[KeyNameToCode('left')]:= '+left';
   355 DefaultBinds[KeyNameToCode('left')]:= '+left';
   347 DefaultBinds[KeyNameToCode('right')]:= '+right';
   356 DefaultBinds[KeyNameToCode('right')]:= '+right';
   380     tkbdn[32]:= ord(spaceKey);
   389     tkbdn[32]:= ord(spaceKey);
   381 
   390 
   382     tkbdn[44]:= ord(chatAction);
   391     tkbdn[44]:= ord(chatAction);
   383     tkbdn[55]:= ord(pauseAction);
   392     tkbdn[55]:= ord(pauseAction);
   384     //tkbdn[100]:= ord(switchAction);
   393     //tkbdn[100]:= ord(switchAction);
       
   394     
       
   395     tkbdn[66]:= ord(cursorUp);
       
   396     tkbdn[67]:= ord(cursorDown);
       
   397     tkbdn[68]:= ord(cursorLeft);
       
   398     tkbdn[69]:= ord(cursorRight);
   385     
   399     
   386     leftClick:= false;
   400     leftClick:= false;
   387     middleClick:= false;
   401     middleClick:= false;
   388     rightClick:= false;
   402     rightClick:= false;
   389 
   403 
   492 
   506 
   493 procedure initModule;
   507 procedure initModule;
   494 begin
   508 begin
   495     wheelUp:= false;
   509     wheelUp:= false;
   496     wheelDown:= false;
   510     wheelDown:= false;
       
   511     coeff:= 5;
   497 {$IFDEF IPHONEOS}
   512 {$IFDEF IPHONEOS}
   498     // this function is called by HW_allKeysUp so be careful
   513     // this function is called by HW_allKeysUp so be careful
       
   514     
       
   515     // mouse emulation
   499     leftClick:= false;
   516     leftClick:= false;
   500     middleClick:= false;
   517     middleClick:= false;
   501     rightClick:= false;
   518     rightClick:= false;
   502 
   519 
       
   520     // arrow key emulation
   503     upKey:= false;
   521     upKey:= false;
   504     downKey:= false;
   522     downKey:= false;
   505     rightKey:= false;
   523     rightKey:= false;
   506     leftKey:= false;
   524     leftKey:= false;
   507 
   525 
       
   526     // action key emulation
   508     backspaceKey:= false;
   527     backspaceKey:= false;
   509     spaceKey:= false;
   528     spaceKey:= false;
   510     enterKey:= false;
   529     enterKey:= false;
   511     tabKey:= false;
   530     tabKey:= false;
   512     
   531 
       
   532     // other key emulation
   513     chatAction:= false;
   533     chatAction:= false;
   514     pauseAction:= false;
   534     pauseAction:= false;
   515     switchAction:= false;
   535     switchAction:= false;
       
   536 
       
   537     // cursor emulation
       
   538     cursorUp:= false;
       
   539     cursorDown:= false;
       
   540     cursorLeft:= false;
       
   541     cursorRight:= false;
       
   542     
   516 {$ENDIF}
   543 {$ENDIF}
   517 end;
   544 end;
   518 
   545 
   519 procedure freeModule;
   546 procedure freeModule;
   520 begin
   547 begin