X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=87011a9732167f4aafd2c45b73f4d1e61b6e9a96;hb=e913fbf7e7caa3234df0de282363ee4d6bb727e1;hp=20c6e3432e3dff614ea005e59cda0fb70c92a371;hpb=f1dae0af49fa331f6fedc6cbdf59eed0909ae391;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index 20c6e343..87011a97 100644 --- a/src/events.c +++ b/src/events.c @@ -247,6 +247,13 @@ void HandleOtherEvents(Event *event) break; #if defined(TARGET_SDL) +#if defined(TARGET_SDL2) + case SDL_CONTROLLERDEVICEADDED: + case SDL_CONTROLLERDEVICEREMOVED: + case SDL_CONTROLLERAXISMOTION: + case SDL_CONTROLLERBUTTONDOWN: + case SDL_CONTROLLERBUTTONUP: +#endif case SDL_JOYAXISMOTION: case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: @@ -1233,7 +1240,11 @@ void HandleButton(int mx, int my, int button, int button_nr) } #endif - HandleGlobalAnimClicks(mx, my, button); + if (HandleGlobalAnimClicks(mx, my, button)) + { + /* do not handle this button event anymore */ + mx = my = -32; /* force mouse event to be outside screen tiles */ + } if (button_hold && game_status == GAME_MODE_PLAYING && tape.pausing) return; @@ -1699,6 +1710,15 @@ void HandleKey(Key key, int key_status) return; } + if (HandleGlobalAnimClicks(-1, -1, (key == KSYM_space || + key == KSYM_Return || + key == KSYM_Escape))) + { + /* do not handle this key event anymore */ + if (key != KSYM_Escape) /* always allow ESC key to be handled */ + return; + } + if (game_status == GAME_MODE_PLAYING && AllPlayersGone && (key == KSYM_Return || key == setup.shortcut.toggle_pause)) { @@ -1917,23 +1937,30 @@ static int HandleJoystickForAllPlayers() { int i; int result = 0; + boolean no_joysticks_configured = TRUE; + boolean use_as_joystick_nr = (game_status != GAME_MODE_PLAYING); + static byte joy_action_last[MAX_PLAYERS]; + + for (i = 0; i < MAX_PLAYERS; i++) + if (setup.input[i].use_joystick) + no_joysticks_configured = FALSE; + + /* if no joysticks configured, map connected joysticks to players */ + if (no_joysticks_configured) + use_as_joystick_nr = TRUE; for (i = 0; i < MAX_PLAYERS; i++) { byte joy_action = 0; - /* - if (!setup.input[i].use_joystick) - continue; - */ - - joy_action = Joystick(i); + joy_action = JoystickExt(i, use_as_joystick_nr); result |= joy_action; - if (!setup.input[i].use_joystick) - continue; + if ((setup.input[i].use_joystick || no_joysticks_configured) && + joy_action != joy_action_last[i]) + stored_player[i].action = joy_action; - stored_player[i].action = joy_action; + joy_action_last[i] = joy_action; } return result; @@ -1953,6 +1980,12 @@ void HandleJoystick() int dx = (left ? -1 : right ? 1 : 0); int dy = (up ? -1 : down ? 1 : 0); + if (HandleGlobalAnimClicks(-1, -1, newbutton)) + { + /* do not handle this button event anymore */ + return; + } + switch (game_status) { case GAME_MODE_TITLE: