460 |
460 |
461 procedure ControllerAxisEvent(joy, axis: Byte; value: Integer); |
461 procedure ControllerAxisEvent(joy, axis: Byte; value: Integer); |
462 var |
462 var |
463 k: LongInt; |
463 k: LongInt; |
464 begin |
464 begin |
465 SDL_GetKeyState(@k); |
465 SDL_GetKeyboardState(@k); |
466 k:= k + joy * (ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + ControllerNumButtons[joy]*2); |
466 k:= k + joy * (ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + ControllerNumButtons[joy]*2); |
467 ProcessKey(k + axis*2, value > 20000); |
467 ProcessKey(k + axis*2, value > 20000); |
468 ProcessKey(k + (axis*2)+1, value < -20000); |
468 ProcessKey(k + (axis*2)+1, value < -20000); |
469 end; |
469 end; |
470 |
470 |
471 procedure ControllerHatEvent(joy, hat, value: Byte); |
471 procedure ControllerHatEvent(joy, hat, value: Byte); |
472 var |
472 var |
473 k: LongInt; |
473 k: LongInt; |
474 begin |
474 begin |
475 SDL_GetKeyState(@k); |
475 SDL_GetKeyboardState(@k); |
476 k:= k + joy * (ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + ControllerNumButtons[joy]*2); |
476 k:= k + joy * (ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + ControllerNumButtons[joy]*2); |
477 ProcessKey(k + ControllerNumAxes[joy]*2 + hat*4 + 0, (value and SDL_HAT_UP) <> 0); |
477 ProcessKey(k + ControllerNumAxes[joy]*2 + hat*4 + 0, (value and SDL_HAT_UP) <> 0); |
478 ProcessKey(k + ControllerNumAxes[joy]*2 + hat*4 + 1, (value and SDL_HAT_RIGHT)<> 0); |
478 ProcessKey(k + ControllerNumAxes[joy]*2 + hat*4 + 1, (value and SDL_HAT_RIGHT)<> 0); |
479 ProcessKey(k + ControllerNumAxes[joy]*2 + hat*4 + 2, (value and SDL_HAT_DOWN) <> 0); |
479 ProcessKey(k + ControllerNumAxes[joy]*2 + hat*4 + 2, (value and SDL_HAT_DOWN) <> 0); |
480 ProcessKey(k + ControllerNumAxes[joy]*2 + hat*4 + 3, (value and SDL_HAT_LEFT) <> 0); |
480 ProcessKey(k + ControllerNumAxes[joy]*2 + hat*4 + 3, (value and SDL_HAT_LEFT) <> 0); |
482 |
482 |
483 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean); |
483 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean); |
484 var |
484 var |
485 k: LongInt; |
485 k: LongInt; |
486 begin |
486 begin |
487 SDL_GetKeyState(@k); |
487 SDL_GetKeyboardState(@k); |
488 k:= k + joy * (ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + ControllerNumButtons[joy]*2); |
488 k:= k + joy * (ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + ControllerNumButtons[joy]*2); |
489 ProcessKey(k + ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + button, pressed); |
489 ProcessKey(k + ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + button, pressed); |
490 end; |
490 end; |
491 |
491 |
492 procedure loadBinds(cmd, s: shortstring); |
492 procedure loadBinds(cmd, s: shortstring); |