15 * along with this program; if not, write to the Free Software |
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 |
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 |
21 |
21 unit uKeys; |
22 unit uKeys; |
22 interface |
23 interface |
23 uses uConsts, SDLh; |
24 uses uConsts, SDLh; |
24 |
25 |
38 procedure ControllerClose; |
39 procedure ControllerClose; |
39 procedure ControllerAxisEvent(joy, axis: Byte; value: Integer); |
40 procedure ControllerAxisEvent(joy, axis: Byte; value: Integer); |
40 procedure ControllerHatEvent(joy, hat, value: Byte); |
41 procedure ControllerHatEvent(joy, hat, value: Byte); |
41 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean); |
42 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean); |
42 |
43 |
|
44 {$IFDEF IPHONEOS} |
|
45 procedure HW_click; cdecl; export; |
|
46 procedure HW_zoomIn; cdecl; export; |
|
47 procedure HW_zoomOut; cdecl; export; |
|
48 procedure HW_ammoMenu; cdecl; export; |
|
49 {$ENDIF} |
|
50 |
43 var hideAmmoMenu: boolean; |
51 var hideAmmoMenu: boolean; |
44 wheelUp: boolean = false; |
52 wheelUp: boolean = false; |
45 wheelDown: boolean = false; |
53 wheelDown: boolean = false; |
46 {$IFDEF TOUCHINPUT} |
54 {$IFDEF TOUCHINPUT} |
47 leftClick: boolean = false; |
55 leftClick: boolean = false; |
48 middleClick: boolean = false; |
56 middleClick: boolean = false; |
49 rightClick: boolean = false; |
57 rightClick: boolean = false; |
50 |
58 |
51 upKey: boolean = false; |
59 upKey: boolean = false; |
52 downKey: boolean = false; |
60 downKey: boolean = false; |
53 rightKey: boolean = false; |
61 rightKey: boolean = false; |
54 leftKey: boolean = false; |
62 leftKey: boolean = false; |
81 |
89 |
82 var tkbd, tkbdn: TKeyboardState; |
90 var tkbd, tkbdn: TKeyboardState; |
83 KeyNames: array [0..cKeyMaxIndex] of string[15]; |
91 KeyNames: array [0..cKeyMaxIndex] of string[15]; |
84 DefaultBinds, CurrentBinds: TBinds; |
92 DefaultBinds, CurrentBinds: TBinds; |
85 |
93 |
|
94 {$IFDEF IPHONEOS} |
|
95 // these are called by the touch functions present in SDL_uikitview.m |
|
96 procedure HW_click; cdecl; export; |
|
97 begin |
|
98 WriteLnToConsole('HW - general click'); |
|
99 leftClick:= true; |
|
100 exit |
|
101 end; |
|
102 |
|
103 procedure HW_zoomIn; cdecl; export; |
|
104 begin |
|
105 WriteLnToConsole('HW - zooming in'); |
|
106 wheelUp:= true; |
|
107 exit |
|
108 end; |
|
109 |
|
110 procedure HW_zoomOut; cdecl; export; |
|
111 begin |
|
112 WriteLnToConsole('HW - zooming out'); |
|
113 wheelDown:= true; |
|
114 exit |
|
115 end; |
|
116 |
|
117 procedure HW_ammoMenu; cdecl; export; |
|
118 begin |
|
119 WriteLnToConsole('HW - opening ammomenu'); |
|
120 rightClick:= true; |
|
121 exit |
|
122 end; |
|
123 {$ENDIF} |
|
124 |
86 function KeyNameToCode(name: string): word; |
125 function KeyNameToCode(name: string): word; |
87 var Result: Word; |
126 var code: Word; |
88 begin |
127 begin |
89 Result:= cKeyMaxIndex; |
128 code:= cKeyMaxIndex; |
90 while (Result > 0) and (KeyNames[Result] <> name) do dec(Result); |
129 while (code > 0) and (KeyNames[code] <> name) do dec(code); |
91 KeyNameToCode:= Result |
130 KeyNameToCode:= code; |
92 end; |
131 end; |
|
132 |
93 |
133 |
94 procedure ProcessKbd; |
134 procedure ProcessKbd; |
95 var i, j, k: LongInt; |
135 var i, j, k: LongInt; |
96 s: shortstring; |
136 s: shortstring; |
97 pkbd: PByteArray; |
137 pkbd: PByteArray; |
126 tkbdn[1]:= (k and 1); |
166 tkbdn[1]:= (k and 1); |
127 tkbdn[3]:= ((k shr 2) and 1); |
167 tkbdn[3]:= ((k shr 2) and 1); |
128 {$ENDIF} |
168 {$ENDIF} |
129 tkbdn[2]:= ((k shr 1) and 1); |
169 tkbdn[2]:= ((k shr 1) and 1); |
130 |
170 |
131 // mouse wheels (see event loop in project file) |
171 // mouse wheels |
132 tkbdn[4]:= ord(wheelDown); |
172 tkbdn[4]:= ord(wheelDown); |
133 tkbdn[5]:= ord(wheelUp); |
173 tkbdn[5]:= ord(wheelUp); |
134 wheelUp:= false; |
174 wheelUp:= false; |
135 wheelDown:= false; |
175 wheelDown:= false; |
136 {$IFDEF TOUCHINPUT} |
176 {$IFDEF TOUCHINPUT} |