mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-04 08:56:25 +00:00
Added microsecond timestamp to sensor values for PS4 and PS5 controllers using the HIDAPI driver
This commit is contained in:
@@ -2440,6 +2440,15 @@ SDL_GameControllerGetSensorDataRate(SDL_GameController *gamecontroller, SDL_Sens
|
||||
*/
|
||||
int
|
||||
SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorType type, float *data, int num_values)
|
||||
{
|
||||
return SDL_GameControllerGetSensorDataWithTimestamp(gamecontroller, type, NULL, data, num_values);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the current state of a game controller sensor.
|
||||
*/
|
||||
int
|
||||
SDL_GameControllerGetSensorDataWithTimestamp(SDL_GameController *gamecontroller, SDL_SensorType type, Uint64 *timestamp, float *data, int num_values)
|
||||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
int i;
|
||||
@@ -2454,6 +2463,9 @@ SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorTy
|
||||
if (sensor->type == type) {
|
||||
num_values = SDL_min(num_values, SDL_arraysize(sensor->data));
|
||||
SDL_memcpy(data, sensor->data, num_values*sizeof(*data));
|
||||
if (timestamp) {
|
||||
*timestamp = sensor->timestamp_us;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user