Convert ticks to 64-bit, added nanosecond precision to the API

Fixes https://github.com/libsdl-org/SDL/issues/5512
Fixes https://github.com/libsdl-org/SDL/issues/6731
This commit is contained in:
Sam Lantinga 2022-12-02 01:17:17 -08:00
parent 764b899a13
commit 8121bbd083
96 changed files with 938 additions and 1243 deletions

View file

@ -128,7 +128,7 @@ struct _SDL_GameController
SDL_ExtendedGameControllerBind *bindings;
SDL_ExtendedGameControllerBind **last_match_axis;
Uint8 *last_hat_mask;
Uint32 guide_button_down;
Uint64 guide_button_down;
struct _SDL_GameController *next; /* pointer to next game controller we have allocated */
};
@ -2901,7 +2901,7 @@ static int SDL_PrivateGameControllerButton(SDL_GameController *gamecontroller, S
#endif /* !SDL_EVENTS_DISABLED */
if (button == SDL_CONTROLLER_BUTTON_GUIDE) {
Uint32 now = SDL_GetTicks();
Uint64 now = SDL_GetTicks();
if (state == SDL_PRESSED) {
gamecontroller->guide_button_down = now;
@ -2910,7 +2910,7 @@ static int SDL_PrivateGameControllerButton(SDL_GameController *gamecontroller, S
return 0;
}
} else {
if (!SDL_TICKS_PASSED(now, gamecontroller->guide_button_down + SDL_MINIMUM_GUIDE_BUTTON_DELAY_MS)) {
if (now < (gamecontroller->guide_button_down + SDL_MINIMUM_GUIDE_BUTTON_DELAY_MS)) {
gamecontroller->joystick->delayed_guide_button = SDL_TRUE;
return 0;
}