mirror of https://github.com/encounter/SDL.git
Delay delivery of the pause button release on MFI controllers so it doesn't happen in the same frame as the button press
This commit is contained in:
parent
92847022f5
commit
129431b4f4
|
@ -31,6 +31,7 @@
|
|||
#include "SDL_joystick.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "../SDL_sysjoystick.h"
|
||||
#include "../SDL_joystick_c.h"
|
||||
#include "../steam/SDL_steamcontroller.h"
|
||||
|
@ -559,6 +560,8 @@ SDL_SYS_MFIJoystickUpdate(SDL_Joystick * joystick)
|
|||
Uint8 hatstate = SDL_HAT_CENTERED;
|
||||
int i;
|
||||
int updateplayerindex = 0;
|
||||
const Uint8 pausebutton = joystick->nbuttons - 1; /* The pause button is always last. */
|
||||
const Uint32 PAUSE_RELEASE_DELAY_MS = 100;
|
||||
|
||||
if (controller.extendedGamepad) {
|
||||
GCExtendedGamepad *gamepad = controller.extendedGamepad;
|
||||
|
@ -647,17 +650,21 @@ SDL_SYS_MFIJoystickUpdate(SDL_Joystick * joystick)
|
|||
}
|
||||
|
||||
for (i = 0; i < joystick->hwdata->num_pause_presses; i++) {
|
||||
/* The pause button is always last. */
|
||||
Uint8 pausebutton = joystick->nbuttons - 1;
|
||||
|
||||
SDL_PrivateJoystickButton(joystick, pausebutton, SDL_PRESSED);
|
||||
SDL_PrivateJoystickButton(joystick, pausebutton, SDL_RELEASED);
|
||||
|
||||
joystick->hwdata->pause_button_down_time = SDL_GetTicks();
|
||||
if (!joystick->hwdata->pause_button_down_time) {
|
||||
joystick->hwdata->pause_button_down_time = 1;
|
||||
}
|
||||
updateplayerindex = YES;
|
||||
}
|
||||
|
||||
joystick->hwdata->num_pause_presses = 0;
|
||||
|
||||
if (joystick->hwdata->pause_button_down_time &&
|
||||
SDL_TICKS_PASSED(SDL_GetTicks(), joystick->hwdata->pause_button_down_time + PAUSE_RELEASE_DELAY_MS)) {
|
||||
SDL_PrivateJoystickButton(joystick, pausebutton, SDL_RELEASED);
|
||||
joystick->hwdata->pause_button_down_time = 0;
|
||||
}
|
||||
|
||||
if (updateplayerindex && controller.playerIndex == -1) {
|
||||
BOOL usedPlayerIndexSlots[4] = {NO, NO, NO, NO};
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ typedef struct joystick_hwdata
|
|||
|
||||
GCController __unsafe_unretained *controller;
|
||||
int num_pause_presses;
|
||||
Uint32 pause_button_down_time;
|
||||
|
||||
char *name;
|
||||
SDL_Joystick *joystick;
|
||||
|
|
Loading…
Reference in New Issue