X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fevents.c;h=2472fdf5f8978b048af638730299206544445255;hp=69d7a2120a6fe78f2c7536f16954c2fb4908cc2d;hb=0d214d4e314f6f42df24be140bb433e980319767;hpb=b32084272306eebf14d2b63ea4dcd1a07994ed6f diff --git a/src/events.c b/src/events.c index 69d7a212..2472fdf5 100644 --- a/src/events.c +++ b/src/events.c @@ -1525,6 +1525,14 @@ void HandleKey(Key key, int key_status) int joy = 0; int i; +#if defined(TARGET_SDL2) + /* map special "play/pause" media key to default key for play/pause actions */ + if (key == KSYM_PlayPause) + key = KSYM_space; +#endif + + HandleSpecialGameControllerKeys(key, key_status); + if (game_status == GAME_MODE_PLAYING) { /* only needed for single-step tape recording mode */ @@ -2099,3 +2107,33 @@ void HandleSpecialGameControllerButtons(Event *event) } #endif } + +void HandleSpecialGameControllerKeys(Key key, int key_status) +{ +#if defined(TARGET_SDL2) +#if defined(KSYM_Rewind) && defined(KSYM_FastForward) + int button = SDL_CONTROLLER_BUTTON_INVALID; + + /* map keys to joystick buttons (special hack for Amazon Fire TV remote) */ + if (key == KSYM_Rewind) + button = SDL_CONTROLLER_BUTTON_A; + else if (key == KSYM_FastForward || key == KSYM_Menu) + button = SDL_CONTROLLER_BUTTON_B; + + if (button != SDL_CONTROLLER_BUTTON_INVALID) + { + Event event; + + event.type = (key_status == KEY_PRESSED ? SDL_CONTROLLERBUTTONDOWN : + SDL_CONTROLLERBUTTONUP); + + event.cbutton.which = 0; /* first joystick (Amazon Fire TV remote) */ + event.cbutton.button = button; + event.cbutton.state = (key_status == KEY_PRESSED ? SDL_PRESSED : + SDL_RELEASED); + + HandleJoystickEvent(&event); + } +#endif +#endif +}