equal
deleted
inserted
replaced
43 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean); |
43 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean); |
44 |
44 |
45 implementation |
45 implementation |
46 uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug; |
46 uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug; |
47 |
47 |
48 var tkbd: TKeyboardState; |
48 var tkbd: array[0..cKeyMaxIndex] of boolean; |
49 quitKeyCode: Byte; |
49 quitKeyCode: Byte; |
50 KeyNames: array [0..cKeyMaxIndex] of string[15]; |
50 KeyNames: array [0..cKeyMaxIndex] of string[15]; |
51 CurrentBinds: TBinds; |
51 CurrentBinds: TBinds; |
52 |
52 |
53 function KeyNameToCode(name: shortstring): word; |
53 function KeyNameToCode(name: shortstring): word; |
63 var |
63 var |
64 Trusted: boolean; |
64 Trusted: boolean; |
65 s : string; |
65 s : string; |
66 begin |
66 begin |
67 |
67 |
68 if(tkbd[code] = ord(KeyDown)) then exit; |
68 if not(tkbd[code] xor KeyDown) then exit; |
69 tkbd[code]:= ord(KeyDown); |
69 tkbd[code]:= KeyDown; |
70 |
70 |
71 |
71 |
72 hideAmmoMenu:= false; |
72 hideAmmoMenu:= false; |
73 Trusted:= (CurrentTeam <> nil) |
73 Trusted:= (CurrentTeam <> nil) |
74 and (not CurrentTeam^.ExtDriven) |
74 and (not CurrentTeam^.ExtDriven) |
78 |
78 |
79 // ctrl/cmd + q to close engine and frontend |
79 // ctrl/cmd + q to close engine and frontend |
80 if(KeyDown and (code = quitKeyCode)) then |
80 if(KeyDown and (code = quitKeyCode)) then |
81 begin |
81 begin |
82 {$IFDEF DARWIN} |
82 {$IFDEF DARWIN} |
83 if ((tkbd[KeyNameToCode('left_meta')] = 1) or (tkbd[KeyNameToCode('right_meta')] = 1)) then |
83 if tkbd[KeyNameToCode('left_meta')] or tkbd[KeyNameToCode('right_meta')] then |
84 {$ELSE} |
84 {$ELSE} |
85 if ((tkbd[KeyNameToCode('left_ctrl')] = 1) or (tkbd[KeyNameToCode('right_ctrl')] = 1)) then |
85 if tkbd[KeyNameToCode('left_ctrl')] or tkbd[KeyNameToCode('right_ctrl')] then |
86 {$ENDIF} |
86 {$ENDIF} |
87 ParseCommand('halt', true); |
87 ParseCommand('halt', true); |
88 end; |
88 end; |
89 |
89 |
90 if CurrentBinds[code][0] <> #0 then |
90 if CurrentBinds[code][0] <> #0 then |
91 begin |
91 begin |
92 if (code > 3) and (KeyDown) and not ((CurrentBinds[code] = 'put') or (CurrentBinds[code] = 'ammomenu') or (CurrentBinds[code] = '+cur_u') or (CurrentBinds[code] = '+cur_d') or (CurrentBinds[code] = '+cur_l') or (CurrentBinds[code] = '+cur_r')) then hideAmmoMenu:= true; |
92 if (code > 3) and KeyDown and not ((CurrentBinds[code] = 'put') or (CurrentBinds[code] = 'ammomenu') or (CurrentBinds[code] = '+cur_u') or (CurrentBinds[code] = '+cur_d') or (CurrentBinds[code] = '+cur_l') or (CurrentBinds[code] = '+cur_r')) then hideAmmoMenu:= true; |
93 |
93 |
94 if KeyDown then |
94 if KeyDown then |
95 begin |
95 begin |
96 ParseCommand(CurrentBinds[code], Trusted); |
96 ParseCommand(CurrentBinds[code], Trusted); |
97 if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then |
97 if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then |
131 |
131 |
132 procedure ResetKbd; |
132 procedure ResetKbd; |
133 var t: LongInt; |
133 var t: LongInt; |
134 begin |
134 begin |
135 for t:= 0 to cKeyMaxIndex do |
135 for t:= 0 to cKeyMaxIndex do |
136 if(tkbd[t] <> 0) then |
136 if tkbd[t] then |
137 ProcessKey(t, False); |
137 ProcessKey(t, False); |
138 end; |
138 end; |
139 |
139 |
140 procedure InitKbdKeyTable; |
140 procedure InitKbdKeyTable; |
141 var i, j, k, t: LongInt; |
141 var i, j, k, t: LongInt; |
253 CurrentBinds:= DefaultBinds; |
253 CurrentBinds:= DefaultBinds; |
254 end; |
254 end; |
255 |
255 |
256 procedure FreezeEnterKey; |
256 procedure FreezeEnterKey; |
257 begin |
257 begin |
258 tkbd[3]:= 1; |
258 tkbd[3]:= True; |
259 tkbd[13]:= 1; |
259 tkbd[13]:= True; |
260 tkbd[27]:= 1; |
260 tkbd[27]:= True; |
261 tkbd[271]:= 1; |
261 tkbd[271]:= True; |
262 end; |
262 end; |
263 |
263 |
264 var Controller: array [0..5] of PSDL_Joystick; |
264 var Controller: array [0..5] of PSDL_Joystick; |
265 |
265 |
266 procedure ControllerInit; |
266 procedure ControllerInit; |