mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-17 22:18:43 +02:00
Removed SDL_SensorGetDataWithTimestamp() and SDL_GameControllerGetSensorDataWithTimestamp()
If you care about timestamps you'll also want to catch all of the sensor events instead of just polling the current state. For example, Nintendo Switch controllers generate 3 sensor events with distinct values for each polling interval.
This commit is contained in:
@@ -2431,14 +2431,6 @@ float SDL_GameControllerGetSensorDataRate(SDL_GameController *gamecontroller, SD
|
||||
* Get the current state of a game controller sensor.
|
||||
*/
|
||||
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;
|
||||
@@ -2453,9 +2445,6 @@ int SDL_GameControllerGetSensorDataWithTimestamp(SDL_GameController *gamecontrol
|
||||
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->sensor_timestamp;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2981,7 +2981,6 @@ int SDL_PrivateJoystickSensor(Uint64 timestamp, SDL_Joystick *joystick, SDL_Sens
|
||||
|
||||
/* Update internal sensor state */
|
||||
SDL_memcpy(sensor->data, data, num_values * sizeof(*data));
|
||||
sensor->sensor_timestamp = sensor_timestamp;
|
||||
|
||||
/* Post the event, if desired */
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
|
||||
@@ -63,7 +63,6 @@ typedef struct _SDL_JoystickSensorInfo
|
||||
SDL_bool enabled;
|
||||
float rate;
|
||||
float data[3]; /* If this needs to expand, update SDL_ControllerSensorEvent */
|
||||
Uint64 sensor_timestamp;
|
||||
} SDL_JoystickSensorInfo;
|
||||
|
||||
struct _SDL_Joystick
|
||||
|
||||
Reference in New Issue
Block a user