hedgewars/uKeys.pas
changeset 2591 c6597b65caea
parent 2590 e7e87e3c67db
child 2599 c7153d2348f3
equal deleted inserted replaced
2590:e7e87e3c67db 2591:c6597b65caea
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    17  *)
    17  *)
    18 
    18 
    19 unit uKeys;
    19 unit uKeys;
    20 interface
    20 interface
    21 uses uConsts;
    21 uses uConsts, SDLh;
    22 {$INCLUDE options.inc}
    22 {$INCLUDE options.inc}
    23 
    23 
    24 type TBinds = array[0..cKeyMaxIndex] of shortstring;
    24 type TBinds = array[0..cKeyMaxIndex] of shortstring;
    25 type TKeyboardState = array[0..cKeyMaxIndex] of Byte;
    25 type TKeyboardState = array[0..cKeyMaxIndex] of Byte;
    26 
    26 
    37 procedure ControllerClose;
    37 procedure ControllerClose;
    38 procedure ControllerAxisEvent(joy, axis: Byte; value: Integer);
    38 procedure ControllerAxisEvent(joy, axis: Byte; value: Integer);
    39 procedure ControllerHatEvent(joy, hat, value: Byte);
    39 procedure ControllerHatEvent(joy, hat, value: Byte);
    40 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean);
    40 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean);
    41 
    41 
    42 var hideAmmoMenu: boolean;
    42 var	hideAmmoMenu: boolean;
    43 	wheelUp: boolean = false;
    43 	wheelUp: boolean = false;
    44 	wheelDown: boolean = false;
    44 	wheelDown: boolean = false;
    45 {$IFDEF TOUCHINPUT}
    45 {$IFDEF TOUCHINPUT}
    46         leftClick: boolean = false;
    46         leftClick: boolean = false;
    47         middleClick: boolean = false;
    47         middleClick: boolean = false;
    48         rightClick: boolean = false;
    48         rightClick: boolean = false;
    49 
    49 
    50 upKey: boolean = false;
    50 	upKey: boolean = false;
    51 downKey: boolean = false;
    51 	downKey: boolean = false;
    52 rightKey: boolean = false;
    52 	rightKey: boolean = false;
    53 leftKey: boolean = false;
    53 	leftKey: boolean = false;
    54 
    54 
    55 backspaceKey: boolean = false;
    55 	backspaceKey: boolean = false;
    56 spaceKey: boolean = false;
    56 	spaceKey: boolean = false;
    57 enterKey: boolean = false;
    57 	enterKey: boolean = false;
    58 tabKey: boolean = false;
    58 	tabKey: boolean = false;
    59 
    59 
    60 isAttacking: boolean = false;
    60 	isAttacking: boolean = false;
    61 isWalking: boolean = false;
    61 	isWalking: boolean = false;
    62 
    62 {$ENDIF}
       
    63 {$IFDEF IPHONEOS}
       
    64 	theJoystick: PSDL_Joystick;
    63 {$ENDIF}
    65 {$ENDIF}
    64 	ControllerNumControllers: Integer;
    66 	ControllerNumControllers: Integer;
    65     ControllerEnabled: Integer;
    67 	ControllerEnabled: Integer;
    66     ControllerNumAxes: array[0..5] of Integer;
    68 	ControllerNumAxes: array[0..5] of Integer;
    67     //ControllerNumBalls: array[0..5] of Integer;
    69 	//ControllerNumBalls: array[0..5] of Integer;
    68 	ControllerNumHats: array[0..5] of Integer;
    70 	ControllerNumHats: array[0..5] of Integer;
    69 	ControllerNumButtons: array[0..5] of Integer;
    71 	ControllerNumButtons: array[0..5] of Integer;
    70 	ControllerAxes: array[0..5] of array[0..19] of Integer;
    72 	ControllerAxes: array[0..5] of array[0..19] of Integer;
    71 	//ControllerBalls: array[0..5] of array[0..19] of array[0..1] of Integer;
    73 	//ControllerBalls: array[0..5] of array[0..19] of array[0..1] of Integer;
    72 	ControllerHats: array[0..5] of array[0..19] of Byte;
    74 	ControllerHats: array[0..5] of array[0..19] of Byte;
    73 	ControllerButtons: array[0..5] of array[0..19] of Byte;
    75 	ControllerButtons: array[0..5] of array[0..19] of Byte;
    74 
    76 
    75 implementation
    77 implementation
    76 uses SDLh, uTeams, uConsole, uMisc, uStore;
    78 uses uTeams, uConsole, uMisc, uStore;
    77 const KeyNumber = 1024;
    79 const KeyNumber = 1024;
    78 
    80 
    79 var tkbd, tkbdn: TKeyboardState;
    81 var tkbd, tkbdn: TKeyboardState;
    80     KeyNames: array [0..cKeyMaxIndex] of string[15];
    82     KeyNames: array [0..cKeyMaxIndex] of string[15];
    81     DefaultBinds, CurrentBinds: TBinds;
    83     DefaultBinds, CurrentBinds: TBinds;
   398 begin
   400 begin
   399 tkbd[13]:= 1;
   401 tkbd[13]:= 1;
   400 tkbd[271]:= 1;
   402 tkbd[271]:= 1;
   401 end;
   403 end;
   402 
   404 
   403 var Controller: array [0..5] of PSDLJoystick;
   405 var Controller: array [0..5] of PSDL_Joystick;
   404 	
   406 	
   405 procedure ControllerInit;
   407 procedure ControllerInit;
   406 var i, j: Integer;
   408 var i, j: Integer;
   407 begin
   409 begin
   408 ControllerEnabled:= 0;
   410 ControllerEnabled:= 0;
   454 	// enable event generation/controller updating
   456 	// enable event generation/controller updating
   455 	SDL_JoystickEventState(1);
   457 	SDL_JoystickEventState(1);
   456 	end
   458 	end
   457 else	
   459 else	
   458 	WriteLnToConsole('Not using any game controller');
   460 	WriteLnToConsole('Not using any game controller');
       
   461 {$IFDEF IPHONEOS}
       
   462 theJoystick:= Controller[0];
       
   463 {$ENDIF}
   459 end;
   464 end;
   460 
   465 
   461 procedure ControllerClose;
   466 procedure ControllerClose;
   462 var j: Integer;
   467 var j: Integer;
   463 begin
   468 begin