38 procedure ControllerClose; |
38 procedure ControllerClose; |
39 procedure ControllerAxisEvent(joy, axis: Byte; value: Integer); |
39 procedure ControllerAxisEvent(joy, axis: Byte; value: Integer); |
40 procedure ControllerHatEvent(joy, hat, value: Byte); |
40 procedure ControllerHatEvent(joy, hat, value: Byte); |
41 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean); |
41 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean); |
42 |
42 |
43 var hideAmmoMenu: boolean; |
|
44 wheelUp: boolean; |
|
45 wheelDown: boolean; |
|
46 |
|
47 ControllerNumControllers: Integer; |
|
48 ControllerEnabled: Integer; |
|
49 ControllerNumAxes: array[0..5] of Integer; |
|
50 //ControllerNumBalls: array[0..5] of Integer; |
|
51 ControllerNumHats: array[0..5] of Integer; |
|
52 ControllerNumButtons: array[0..5] of Integer; |
|
53 ControllerAxes: array[0..5] of array[0..19] of Integer; |
|
54 //ControllerBalls: array[0..5] of array[0..19] of array[0..1] of Integer; |
|
55 ControllerHats: array[0..5] of array[0..19] of Byte; |
|
56 ControllerButtons: array[0..5] of array[0..19] of Byte; |
|
57 |
|
58 DefaultBinds, CurrentBinds: TBinds; |
|
59 |
|
60 coeff: LongInt; |
|
61 {$IFDEF HWLIBRARY} |
|
62 leftClick: boolean; |
|
63 middleClick: boolean; |
|
64 rightClick: boolean; |
|
65 |
|
66 upKey: boolean; |
|
67 downKey: boolean; |
|
68 rightKey: boolean; |
|
69 leftKey: boolean; |
|
70 preciseKey: boolean; |
|
71 |
|
72 backspaceKey: boolean; |
|
73 spaceKey: boolean; |
|
74 enterKey: boolean; |
|
75 tabKey: boolean; |
|
76 |
|
77 chatAction: boolean; |
|
78 pauseAction: boolean; |
|
79 |
|
80 {$IFDEF IPHONEOS} |
43 {$IFDEF IPHONEOS} |
81 procedure setiPhoneBinds; |
44 procedure setiPhoneBinds; |
82 {$ENDIF} |
45 {$ENDIF} |
83 {$ENDIF} |
46 |
84 implementation |
47 implementation |
85 uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug; |
48 uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug; |
86 |
49 |
87 var tkbd, tkbdn: TKeyboardState; |
50 var tkbd, tkbdn: TKeyboardState; |
88 KeyNames: array [0..cKeyMaxIndex] of string[15]; |
51 KeyNames: array [0..cKeyMaxIndex] of string[15]; |
107 and (not CurrentTeam^.ExtDriven) |
70 and (not CurrentTeam^.ExtDriven) |
108 and (CurrentHedgehog^.BotLevel = 0); |
71 and (CurrentHedgehog^.BotLevel = 0); |
109 |
72 |
110 // move cursor/camera |
73 // move cursor/camera |
111 // TODO: Scale on screen dimensions and/or axis value (game controller)? |
74 // TODO: Scale on screen dimensions and/or axis value (game controller)? |
112 movecursor(coeff * CursorMovementX, coeff * CursorMovementY); |
75 movecursor(5 * CursorMovementX, 5 * CursorMovementY); |
113 |
76 |
114 k:= SDL_GetMouseState(nil, nil); |
77 k:= SDL_GetMouseState(nil, nil); |
115 |
78 |
116 {$IFDEF IPHONEOS} |
79 {$IFDEF IPHONEOS} |
117 SDL_GetKeyState(@j); |
80 SDL_GetKeyState(@j); |
162 for i:= 0 to Pred(ControllerNumButtons[j]) do |
124 for i:= 0 to Pred(ControllerNumButtons[j]) do |
163 begin |
125 begin |
164 tkbdn[k]:= ControllerButtons[j][i]; |
126 tkbdn[k]:= ControllerButtons[j][i]; |
165 inc(k, 1); |
127 inc(k, 1); |
166 end; |
128 end; |
|
129 end; |
|
130 {$ENDIF} |
|
131 |
|
132 // ctrl/cmd + w/q to close engine and/or frontend |
|
133 {$IFDEF DARWIN} |
|
134 if ((tkbdn[KeyNameToCode('left_meta')] = 1) or (tkbdn[KeyNameToCode('right_meta')] = 1)) then |
|
135 {$ELSE} |
|
136 if ((tkbdn[KeyNameToCode('left_ctrl')] = 1) or (tkbdn[KeyNameToCode('right_ctrl')] = 1)) then |
|
137 {$ENDIF} |
|
138 begin |
|
139 if tkbdn[KeyNameToCode('q')] = 1 then ParseCommand ('halt', true) |
|
140 else if tkbdn[KeyNameToCode('w')] = 1 then ParseCommand ('forcequit', true); |
167 end; |
141 end; |
168 |
142 |
169 // now process strokes |
143 // now process strokes |
170 for i:= 0 to cKeyMaxIndex do |
144 for i:= 0 to cKeyMaxIndex do |
171 if CurrentBinds[i][0] <> #0 then |
145 if CurrentBinds[i][0] <> #0 then |
348 DefaultBinds[KeyNameToCode('down')]:= '+down'; |
322 DefaultBinds[KeyNameToCode('down')]:= '+down'; |
349 DefaultBinds[KeyNameToCode('left')]:= '+left'; |
323 DefaultBinds[KeyNameToCode('left')]:= '+left'; |
350 DefaultBinds[KeyNameToCode('right')]:= '+right'; |
324 DefaultBinds[KeyNameToCode('right')]:= '+right'; |
351 DefaultBinds[KeyNameToCode('left_shift')]:= '+precise'; |
325 DefaultBinds[KeyNameToCode('left_shift')]:= '+precise'; |
352 {$ENDIF} |
326 {$ENDIF} |
|
327 DefaultBinds[1000]:= 'forcequit'; |
353 |
328 |
354 for i:= 1 to 10 do DefaultBinds[KeyNameToCode('f'+IntToStr(i))]:= 'slot '+IntToStr(i); |
329 for i:= 1 to 10 do DefaultBinds[KeyNameToCode('f'+IntToStr(i))]:= 'slot '+IntToStr(i); |
355 |
330 |
356 SetDefaultBinds(); |
331 SetDefaultBinds(); |
357 end; |
332 end; |