equal
deleted
inserted
replaced
28 function KeyNameToCode(name: shortstring): LongInt; inline; |
28 function KeyNameToCode(name: shortstring): LongInt; inline; |
29 function KeyNameToCode(name: shortstring; Modifier: shortstring): LongInt; |
29 function KeyNameToCode(name: shortstring; Modifier: shortstring): LongInt; |
30 //procedure MaskModifier(var code: LongInt; modifier: LongWord); |
30 //procedure MaskModifier(var code: LongInt; modifier: LongWord); |
31 procedure MaskModifier(Modifier: shortstring; var code: LongInt); |
31 procedure MaskModifier(Modifier: shortstring; var code: LongInt); |
32 procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean); |
32 procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean); |
|
33 procedure ProcessMouseWheel(x, y: LongInt); |
33 procedure ProcessKey(event: TSDL_KeyboardEvent); inline; |
34 procedure ProcessKey(event: TSDL_KeyboardEvent); inline; |
34 procedure ProcessKey(code: LongInt; KeyDown: boolean); |
35 procedure ProcessKey(code: LongInt; KeyDown: boolean); |
35 |
36 |
36 procedure ResetKbd; |
37 procedure ResetKbd; |
37 procedure FreezeEnterKey; |
38 procedure FreezeEnterKey; |
80 |
81 |
81 function KeyNameToCode(name: shortstring; Modifier: shortstring): LongInt; |
82 function KeyNameToCode(name: shortstring; Modifier: shortstring): LongInt; |
82 var code: LongInt; |
83 var code: LongInt; |
83 begin |
84 begin |
84 name:= LowerCase(name); |
85 name:= LowerCase(name); |
85 code:= cKeyMaxIndex; |
86 code:= 0; |
86 while (code > 0) and (KeyNames[code] <> name) do dec(code); |
87 while (code <= cKeyMaxIndex) and (KeyNames[code] <> name) do inc(code); |
87 |
88 |
88 MaskModifier(Modifier, code); |
89 MaskModifier(Modifier, code); |
89 KeyNameToCode:= code; |
90 KeyNameToCode:= code; |
90 end; |
91 end; |
91 (* |
92 (* |
164 ParseCommand('forcequit', true); |
165 ParseCommand('forcequit', true); |
165 end; |
166 end; |
166 |
167 |
167 if CurrentBinds[code][0] <> #0 then |
168 if CurrentBinds[code][0] <> #0 then |
168 begin |
169 begin |
169 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')) and (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) then bShowAmmoMenu:= false; |
170 if (code < cKeyMaxIndex - 2) // means not mouse buttons |
|
171 and KeyDown |
|
172 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')) |
|
173 and (CurrentTeam <> nil) |
|
174 and (not CurrentTeam^.ExtDriven) |
|
175 then bShowAmmoMenu:= false; |
170 |
176 |
171 if KeyDown then |
177 if KeyDown then |
172 begin |
178 begin |
173 ParseCommand(CurrentBinds[code], Trusted); |
179 ParseCommand(CurrentBinds[code], Trusted); |
174 if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then |
180 if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then |
188 {$IFDEF SDL2} |
194 {$IFDEF SDL2} |
189 procedure ProcessKey(event: TSDL_KeyboardEvent); inline; |
195 procedure ProcessKey(event: TSDL_KeyboardEvent); inline; |
190 var code: LongInt; |
196 var code: LongInt; |
191 begin |
197 begin |
192 code:= event.keysym.scancode; |
198 code:= event.keysym.scancode; |
193 |
199 //writelntoconsole('[KEY] '+inttostr(code)+ ' -> ''' +KeyNames[code] + ''', type = '+inttostr(event.type_)); |
194 ProcessKey(code, event.type_ = SDL_KEYDOWN); |
200 ProcessKey(code, event.type_ = SDL_KEYDOWN); |
195 end; |
201 end; |
196 {$ELSE} |
202 {$ELSE} |
197 procedure ProcessKey(event: TSDL_KeyboardEvent); inline; |
203 procedure ProcessKey(event: TSDL_KeyboardEvent); inline; |
198 var code: LongInt; |
204 var code: LongInt; |
203 end; |
209 end; |
204 {$ENDIF} |
210 {$ENDIF} |
205 |
211 |
206 procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean); |
212 procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean); |
207 begin |
213 begin |
208 case event.button of |
214 //writelntoconsole('[MOUSE] '+inttostr(event.button)); |
209 SDL_BUTTON_LEFT: |
215 case event.button of |
210 ProcessKey(KeyNameToCode('mousel'), ButtonDown); |
216 SDL_BUTTON_LEFT: |
211 SDL_BUTTON_MIDDLE: |
217 ProcessKey(KeyNameToCode('mousel'), ButtonDown); |
212 ProcessKey(KeyNameToCode('mousem'), ButtonDown); |
218 SDL_BUTTON_MIDDLE: |
213 SDL_BUTTON_RIGHT: |
219 ProcessKey(KeyNameToCode('mousem'), ButtonDown); |
214 ProcessKey(KeyNameToCode('mouser'), ButtonDown); |
220 SDL_BUTTON_RIGHT: |
215 SDL_BUTTON_WHEELDOWN: |
221 ProcessKey(KeyNameToCode('mouser'), ButtonDown); |
216 ProcessKey(KeyNameToCode('wheeldown'), ButtonDown); |
222 SDL_BUTTON_WHEELDOWN: |
217 SDL_BUTTON_WHEELUP: |
223 ProcessKey(KeyNameToCode('wheeldown'), ButtonDown); |
218 ProcessKey(KeyNameToCode('wheelup'), ButtonDown); |
224 SDL_BUTTON_WHEELUP: |
219 end; |
225 ProcessKey(KeyNameToCode('wheelup'), ButtonDown); |
|
226 end; |
|
227 end; |
|
228 |
|
229 procedure ProcessMouseWheel(x, y: LongInt); |
|
230 begin |
|
231 //writelntoconsole('[MOUSEWHEEL] '+inttostr(x)+', '+inttostr(y)); |
|
232 if y > 0 then |
|
233 ProcessKey(KeyNameToCode('wheelup'), true) |
|
234 else if y < 0 then |
|
235 ProcessKey(KeyNameToCode('wheeldown'), true); |
220 end; |
236 end; |
221 |
237 |
222 procedure ResetKbd; |
238 procedure ResetKbd; |
223 var t: LongInt; |
239 var t: LongInt; |
224 begin |
240 begin |