equal
deleted
inserted
replaced
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 {$INCLUDE "options.inc"} |
19 {$INCLUDE "options.inc"} |
20 {$IFDEF IPHONEOS} {$MODE OBJFPC} {$ENDIF} |
20 {$IFDEF IPHONEOS} {$MODE OBJFPC} {$ENDIF} |
|
21 // TODO: insert the above line in options.inc |
21 |
22 |
22 unit uKeys; |
23 unit uKeys; |
23 interface |
24 interface |
24 uses uConsts, SDLh; |
25 uses uConsts, SDLh; |
25 |
26 |
44 {$IFDEF IPHONEOS} |
45 {$IFDEF IPHONEOS} |
45 procedure HW_click; cdecl; export; |
46 procedure HW_click; cdecl; export; |
46 procedure HW_zoomIn; cdecl; export; |
47 procedure HW_zoomIn; cdecl; export; |
47 procedure HW_zoomOut; cdecl; export; |
48 procedure HW_zoomOut; cdecl; export; |
48 procedure HW_ammoMenu; cdecl; export; |
49 procedure HW_ammoMenu; cdecl; export; |
|
50 procedure HW_allKeysUp; cdecl; export; |
|
51 procedure HW_walkLeft; cdecl; export; |
|
52 procedure HW_walkRight; cdecl; export; |
|
53 procedure HW_aimUp; cdecl; export; |
|
54 procedure HW_aimDown; cdecl; export; |
|
55 procedure HW_shoot; cdecl; export; |
|
56 |
49 {$ENDIF} |
57 {$ENDIF} |
50 |
58 |
51 var hideAmmoMenu: boolean; |
59 var hideAmmoMenu: boolean; |
52 wheelUp: boolean = false; |
60 wheelUp: boolean = false; |
53 wheelDown: boolean = false; |
61 wheelDown: boolean = false; |
91 KeyNames: array [0..cKeyMaxIndex] of string[15]; |
99 KeyNames: array [0..cKeyMaxIndex] of string[15]; |
92 DefaultBinds, CurrentBinds: TBinds; |
100 DefaultBinds, CurrentBinds: TBinds; |
93 |
101 |
94 {$IFDEF IPHONEOS} |
102 {$IFDEF IPHONEOS} |
95 // these are called by the touch functions present in SDL_uikitview.m |
103 // these are called by the touch functions present in SDL_uikitview.m |
|
104 // they emulate user interaction from mouse or keyboard |
96 procedure HW_click; cdecl; export; |
105 procedure HW_click; cdecl; export; |
97 begin |
106 begin |
98 WriteLnToConsole('HW - general click'); |
107 WriteLnToConsole('HW - left click'); |
99 leftClick:= true; |
108 leftClick:= true; |
100 exit |
109 exit |
101 end; |
110 end; |
102 |
111 |
103 procedure HW_zoomIn; cdecl; export; |
112 procedure HW_zoomIn; cdecl; export; |
114 exit |
123 exit |
115 end; |
124 end; |
116 |
125 |
117 procedure HW_ammoMenu; cdecl; export; |
126 procedure HW_ammoMenu; cdecl; export; |
118 begin |
127 begin |
119 WriteLnToConsole('HW - opening ammomenu'); |
128 WriteLnToConsole('HW - right click'); |
120 rightClick:= true; |
129 rightClick:= true; |
|
130 exit |
|
131 end; |
|
132 |
|
133 procedure HW_allKeysUp; cdecl; export; |
|
134 begin |
|
135 WriteLnToConsole('HW - resetting keyboard'); |
|
136 |
|
137 upKey:= false; |
|
138 downKey:= false; |
|
139 leftKey:= false; |
|
140 rightKey:= false; |
|
141 spaceKey:= false; |
|
142 exit |
|
143 end; |
|
144 |
|
145 procedure HW_walkLeft; cdecl; export; |
|
146 begin |
|
147 WriteLnToConsole('HW - walking left'); |
|
148 leftKey:= true; |
|
149 exit |
|
150 end; |
|
151 |
|
152 procedure HW_walkRight; cdecl; export; |
|
153 begin |
|
154 WriteLnToConsole('HW - walking right'); |
|
155 rightKey:= true; |
|
156 exit |
|
157 end; |
|
158 |
|
159 procedure HW_aimUp; cdecl; export; |
|
160 begin |
|
161 WriteLnToConsole('HW - aiming upwards'); |
|
162 upKey:= true; |
|
163 exit |
|
164 end; |
|
165 |
|
166 procedure HW_aimDown; cdecl; export; |
|
167 begin |
|
168 WriteLnToConsole('HW - aiming downwards'); |
|
169 downKey:= true; |
|
170 exit |
|
171 end; |
|
172 |
|
173 procedure HW_shoot; cdecl; export; |
|
174 begin |
|
175 WriteLnToConsole('HW - shooting'); |
|
176 spaceKey:= true; |
121 exit |
177 exit |
122 end; |
178 end; |
123 {$ENDIF} |
179 {$ENDIF} |
124 |
180 |
125 function KeyNameToCode(name: string): word; |
181 function KeyNameToCode(name: string): word; |
189 tkbdn[ 8]:= ord(backspaceKey); |
245 tkbdn[ 8]:= ord(backspaceKey); |
190 tkbdn[ 9]:= ord(tabKey); |
246 tkbdn[ 9]:= ord(tabKey); |
191 tkbdn[13]:= ord(enterKey); |
247 tkbdn[13]:= ord(enterKey); |
192 tkbdn[32]:= ord(spaceKey); |
248 tkbdn[32]:= ord(spaceKey); |
193 |
249 |
194 upKey:= false; |
|
195 downKey:= false; |
|
196 if isWalking = false then rightKey:= false; |
|
197 if isWalking = false then leftKey:= false; |
|
198 |
|
199 if isAttacking = false then spaceKey:= false; |
|
200 tabKey:= false; |
250 tabKey:= false; |
201 enterKey:= false; |
251 enterKey:= false; |
202 backspaceKey:= false; |
252 backspaceKey:= false; |
203 |
253 |
204 {$ENDIF} |
254 {$ENDIF} |
296 tkbdn[ 8]:= ord(backspaceKey); |
346 tkbdn[ 8]:= ord(backspaceKey); |
297 tkbdn[ 9]:= ord(tabKey); |
347 tkbdn[ 9]:= ord(tabKey); |
298 tkbdn[13]:= ord(enterKey); |
348 tkbdn[13]:= ord(enterKey); |
299 tkbdn[32]:= ord(spaceKey); |
349 tkbdn[32]:= ord(spaceKey); |
300 |
350 |
301 upKey:= false; |
|
302 downKey:= false; |
|
303 tabKey:= false; |
351 tabKey:= false; |
304 if isWalking = false then rightKey:= false; |
|
305 if isWalking = false then leftKey:= false; |
|
306 |
|
307 if isAttacking = false then spaceKey:= false; |
|
308 enterKey:= false; |
352 enterKey:= false; |
309 backspaceKey:= false; |
353 backspaceKey:= false; |
310 {$ENDIF} |
354 {$ENDIF} |
311 |
355 |
312 // Controller(s) |
356 // Controller(s) |