203 LocalMessage:= LocalMessage and not(gmSwitch) |
203 LocalMessage:= LocalMessage and not(gmSwitch) |
204 end |
204 end |
205 end |
205 end |
206 end; |
206 end; |
207 |
207 |
208 {$IFDEF SDL2} |
|
209 procedure ProcessKey(event: TSDL_KeyboardEvent); inline; |
208 procedure ProcessKey(event: TSDL_KeyboardEvent); inline; |
210 var code: LongInt; |
209 var code: LongInt; |
211 begin |
210 begin |
212 code:= event.keysym.scancode; |
211 code:= event.keysym.scancode; |
213 //writelntoconsole('[KEY] '+inttostr(code)+ ' -> ''' +KeyNames[code] + ''', type = '+inttostr(event.type_)); |
212 //writelntoconsole('[KEY] '+inttostr(code)+ ' -> ''' +KeyNames[code] + ''', type = '+inttostr(event.type_)); |
214 ProcessKey(code, event.type_ = SDL_KEYDOWN); |
213 ProcessKey(code, event.type_ = SDL_KEYDOWN); |
215 end; |
214 end; |
216 {$ELSE} |
|
217 procedure ProcessKey(event: TSDL_KeyboardEvent); inline; |
|
218 var code: LongInt; |
|
219 begin |
|
220 code:= event.keysym.sym; |
|
221 //MaskModifier(code, event.keysym.modifier); |
|
222 ProcessKey(code, event.type_ = SDL_KEYDOWN); |
|
223 end; |
|
224 {$ENDIF} |
|
225 |
215 |
226 procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean); |
216 procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean); |
227 begin |
217 begin |
228 //writelntoconsole('[MOUSE] '+inttostr(event.button)); |
218 //writelntoconsole('[MOUSE] '+inttostr(event.button)); |
229 case event.button of |
219 case event.button of |
309 |
299 |
310 loadBinds('dbind', cPathz[ptData] + '/settings.ini'); |
300 loadBinds('dbind', cPathz[ptData] + '/settings.ini'); |
311 end; |
301 end; |
312 |
302 |
313 |
303 |
314 {$IFDEF SDL2} |
|
315 procedure InitKbdKeyTable; |
304 procedure InitKbdKeyTable; |
316 var i, j, k, t: LongInt; |
305 var i, j, k, t: LongInt; |
317 s: string[15]; |
306 s: string[15]; |
318 begin |
307 begin |
319 KeyNames[cKeyMaxIndex ]:= 'mousel'; |
308 KeyNames[cKeyMaxIndex ]:= 'mousel'; |
360 end; |
349 end; |
361 end; |
350 end; |
362 |
351 |
363 InitDefaultBinds |
352 InitDefaultBinds |
364 end; |
353 end; |
365 {$ELSE} |
|
366 procedure InitKbdKeyTable; |
|
367 var i, j, k, t: LongInt; |
|
368 s: string[15]; |
|
369 begin |
|
370 //TODO in sdl13 this overrides some values (A and B) change indices to some other values at the back perhaps? |
|
371 KeyNames[1]:= 'mousel'; |
|
372 KeyNames[2]:= 'mousem'; |
|
373 KeyNames[3]:= 'mouser'; |
|
374 KeyNames[4]:= 'wheelup'; |
|
375 KeyNames[5]:= 'wheeldown'; |
|
376 |
|
377 for i:= 6 to cKeyMaxIndex do |
|
378 begin |
|
379 s:= shortstring(sdl_getkeyname(i)); |
|
380 //AddFileLog('uInputHandler - ' + IntToStr(i) + ': ' + s + ' ' + IntToStr(cKeyMaxIndex)); |
|
381 if s = 'unknown key' then KeyNames[i]:= '' |
|
382 else |
|
383 begin |
|
384 for t:= 1 to Length(s) do |
|
385 if s[t] = ' ' then |
|
386 s[t]:= '_'; |
|
387 KeyNames[i]:= LowerCase(s) |
|
388 end; |
|
389 end; |
|
390 |
|
391 |
|
392 // get the size of keyboard array |
|
393 SDL_GetKeyState(@k); |
|
394 |
|
395 // Controller(s) |
|
396 for j:= 0 to Pred(ControllerNumControllers) do |
|
397 begin |
|
398 for i:= 0 to Pred(ControllerNumAxes[j]) do |
|
399 begin |
|
400 keynames[k + 0]:= 'j' + IntToStr(j) + 'a' + IntToStr(i) + 'u'; |
|
401 keynames[k + 1]:= 'j' + IntToStr(j) + 'a' + IntToStr(i) + 'd'; |
|
402 inc(k, 2); |
|
403 end; |
|
404 for i:= 0 to Pred(ControllerNumHats[j]) do |
|
405 begin |
|
406 keynames[k + 0]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'u'; |
|
407 keynames[k + 1]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'r'; |
|
408 keynames[k + 2]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'd'; |
|
409 keynames[k + 3]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'l'; |
|
410 inc(k, 4); |
|
411 end; |
|
412 for i:= 0 to Pred(ControllerNumButtons[j]) do |
|
413 begin |
|
414 keynames[k]:= 'j' + IntToStr(j) + 'b' + IntToStr(i); |
|
415 inc(k, 1); |
|
416 end; |
|
417 end; |
|
418 |
|
419 InitDefaultBinds |
|
420 end; |
|
421 {$ENDIF} |
|
422 |
354 |
423 |
355 |
424 |
356 |
425 {$IFNDEF MOBILE} |
357 {$IFNDEF MOBILE} |
426 procedure SetBinds(var binds: TBinds); |
358 procedure SetBinds(var binds: TBinds); |