Pass the event timestamp for joystick events

This allows the application to get more fine grained information about controller event timing, and group events that happened together.
This commit is contained in:
Sam Lantinga 2022-12-03 11:15:50 -08:00
parent f32cdfa096
commit 73f4aeee6a
36 changed files with 950 additions and 839 deletions

View file

@ -927,6 +927,7 @@ static void DARWIN_JoystickUpdate(SDL_Joystick *joystick)
recElement *element;
SInt32 value, range;
int i, goodRead = SDL_FALSE;
Uint64 timestamp = SDL_GetTicksNS();
if (device == NULL) {
return;
@ -945,7 +946,7 @@ static void DARWIN_JoystickUpdate(SDL_Joystick *joystick)
while (element) {
goodRead = GetHIDScaledCalibratedState(device, element, -32768, 32767, &value);
if (goodRead) {
SDL_PrivateJoystickAxis(joystick, i, value);
SDL_PrivateJoystickAxis(timestamp, joystick, i, value);
}
element = element->pNext;
@ -960,7 +961,7 @@ static void DARWIN_JoystickUpdate(SDL_Joystick *joystick)
if (value > 1) { /* handle pressure-sensitive buttons */
value = 1;
}
SDL_PrivateJoystickButton(joystick, i, value);
SDL_PrivateJoystickButton(timestamp, joystick, i, value);
}
element = element->pNext;
@ -1016,7 +1017,7 @@ static void DARWIN_JoystickUpdate(SDL_Joystick *joystick)
break;
}
SDL_PrivateJoystickHat(joystick, i, pos);
SDL_PrivateJoystickHat(timestamp, joystick, i, pos);
}
element = element->pNext;