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.
main
Sam Lantinga 2022-12-04 09:21:14 -08:00
parent b8760a3ffe
commit b4da4ed95a
12 changed files with 16 additions and 72 deletions

View File

@ -13,16 +13,18 @@ General:
* The preprocessor symbol __IPHONEOS__ has been renamed __IOS__
* Removed the following functions from the API, see docs/README-migration.md for details:
* SDL_CalculateGammaRamp()
* SDL_CreateRGBSurface()
* SDL_CreateRGBSurfaceFrom()
* SDL_CreateRGBSurfaceWithFormat()
* SDL_CreateRGBSurfaceWithFormatFrom()
* SDL_GameControllerGetSensorDataWithTimestamp()
* SDL_GetRevisionNumber()
* SDL_GetWindowBrightness()
* SDL_GetWindowGammaRamp()
* SDL_RWFromFP()
* SDL_SensorGetDataWithTimestamp()
* SDL_SetWindowBrightness()
* SDL_SetWindowGammaRamp()
* SDL_CreateRGBSurface()
* SDL_CreateRGBSurfaceWithFormat()
* SDL_CreateRGBSurfaceFrom()
* SDL_CreateRGBSurfaceWithFormatFrom()
* Removed the following hints from the API, see docs/README-migration.md for details:
* SDL_HINT_IDLE_TIMER_DISABLED
* SDL_HINT_VIDEO_X11_FORCE_EGL

View File

@ -40,6 +40,11 @@ The `timestamp_us` member of the sensor events has been renamed `sensor_timestam
You should set the `event.common.timestamp` field before passing an event to `SDL_PushEvent()`. If the timestamp is 0 it will be filled in with `SDL_GetTicksNS()`.
## SDL_gamecontroller.h
Removed SDL_GameControllerGetSensorDataWithTimestamp(), if you want timestamps for the sensor data, you should use the sensor_timestamp member of SDL_CONTROLLERSENSORUPDATE events.
## SDL_platform.h
The preprocessor symbol __MACOSX__ has been renamed __MACOS__, and __IPHONEOS__ has been renamed __IOS__
@ -163,6 +168,11 @@ SDL_RWFromFP(void *fp, SDL_bool autoclose)
```
## SDL_sensor.h
Removed SDL_SensorGetDataWithTimestamp(), if you want timestamps for the sensor data, you should use the sensor_timestamp member of SDL_SENSORUPDATE events.
## SDL_stdinc.h
The standard C headers like stdio.h and stdlib.h are no longer included, you should include them directly in your project if you use non-SDL C runtime functions.

View File

@ -895,25 +895,6 @@ extern DECLSPEC float SDLCALL SDL_GameControllerGetSensorDataRate(SDL_GameContro
*/
extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorType type, float *data, int num_values);
/**
* Get the current state of a game controller sensor with the timestamp of the
* last update.
*
* The number of values and interpretation of the data is sensor dependent.
* See SDL_sensor.h for the details for each type of sensor.
*
* \param gamecontroller The controller to query
* \param type The type of sensor to query
* \param timestamp A pointer filled with the timestamp in nanoseconds of the
* current sensor reading, which may not be synchronized with the system clock
* \param data A pointer filled with the current sensor state
* \param num_values The number of values to write to data
* \return 0 or -1 if an error occurred.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorDataWithTimestamp(SDL_GameController *gamecontroller, SDL_SensorType type, Uint64 *timestamp, float *data, int num_values);
/**
* Start a rumble effect on a game controller.
*

View File

@ -269,23 +269,6 @@ extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetInstanceID(SDL_Sensor *sensor)
*/
extern DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor *sensor, float *data, int num_values);
/**
* Get the current state of an opened sensor with the timestamp of the last
* update.
*
* The number of values and interpretation of the data is sensor dependent.
*
* \param sensor The SDL_Sensor object to query
* \param timestamp A pointer filled with the timestamp in nanoseconds of the
* current sensor reading, which may not be synchronized with the system clock
* \param data A pointer filled with the current sensor state
* \param num_values The number of values to write to data
* \returns 0 or -1 if an error occurred.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_SensorGetDataWithTimestamp(SDL_Sensor *sensor, Uint64 *timestamp, float *data, int num_values);
/**
* Close a sensor previously opened with SDL_SensorOpen().
*

View File

@ -676,7 +676,6 @@ SDL3_0.0.0 {
SDL_SensorGetNonPortableType;
SDL_SensorGetInstanceID;
SDL_SensorGetData;
SDL_SensorGetDataWithTimestamp;
SDL_SensorClose;
SDL_SensorUpdate;
SDL_SetHintWithPriority;
@ -816,7 +815,6 @@ SDL3_0.0.0 {
SDL_GameControllerIsSensorEnabled;
SDL_GameControllerGetSensorDataRate;
SDL_GameControllerGetSensorData;
SDL_GameControllerGetSensorDataWithTimestamp;
SDL_GameControllerRumble;
SDL_GameControllerRumbleTriggers;
SDL_GameControllerHasLED;

View File

@ -878,8 +878,6 @@
#define SDL_SetPrimarySelectionText SDL_SetPrimarySelectionText_REAL
#define SDL_GetPrimarySelectionText SDL_GetPrimarySelectionText_REAL
#define SDL_HasPrimarySelectionText SDL_HasPrimarySelectionText_REAL
#define SDL_GameControllerGetSensorDataWithTimestamp SDL_GameControllerGetSensorDataWithTimestamp_REAL
#define SDL_SensorGetDataWithTimestamp SDL_SensorGetDataWithTimestamp_REAL
#define SDL_ResetHints SDL_ResetHints_REAL
#define SDL_strcasestr SDL_strcasestr_REAL
#define SDL_EGL_GetProcAddress SDL_EGL_GetProcAddress_REAL

View File

@ -952,8 +952,6 @@ SDL_DYNAPI_PROC(void,SDL_GetJoystickGUIDInfo,(SDL_JoystickGUID a, Uint16 *b, Uin
SDL_DYNAPI_PROC(int,SDL_SetPrimarySelectionText,(const char *a),(a),return)
SDL_DYNAPI_PROC(char*,SDL_GetPrimarySelectionText,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_HasPrimarySelectionText,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GameControllerGetSensorDataWithTimestamp,(SDL_GameController *a, SDL_SensorType b, Uint64 *c, float *d, int e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_SensorGetDataWithTimestamp,(SDL_Sensor *a, Uint64 *b, float *c, int d),(a,b,c,d),return)
SDL_DYNAPI_PROC(void,SDL_ResetHints,(void),(),)
SDL_DYNAPI_PROC(char*,SDL_strcasestr,(const char *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(void*,SDL_EGL_GetProcAddress,(const char *a),(a),return)

View File

@ -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;
}
}

View File

@ -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

View File

@ -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

View File

@ -368,14 +368,6 @@ SDL_SensorGetInstanceID(SDL_Sensor *sensor)
* Get the current state of this sensor
*/
int SDL_SensorGetData(SDL_Sensor *sensor, float *data, int num_values)
{
return SDL_SensorGetDataWithTimestamp(sensor, NULL, data, num_values);
}
/*
* Get the current state of this sensor
*/
int SDL_SensorGetDataWithTimestamp(SDL_Sensor *sensor, Uint64 *timestamp, float *data, int num_values)
{
if (!SDL_PrivateSensorValid(sensor)) {
return -1;
@ -383,9 +375,6 @@ int SDL_SensorGetDataWithTimestamp(SDL_Sensor *sensor, Uint64 *timestamp, float
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;
}
@ -484,7 +473,6 @@ int SDL_PrivateSensorUpdate(Uint64 timestamp, SDL_Sensor *sensor, Uint64 sensor_
/* Update internal sensor state */
num_values = SDL_min(num_values, SDL_arraysize(sensor->data));
SDL_memcpy(sensor->data, data, num_values * sizeof(*data));
sensor->sensor_timestamp = sensor_timestamp;
/* Post the event, if desired */
posted = 0;

View File

@ -35,7 +35,6 @@ struct _SDL_Sensor
SDL_SensorType type; /* Type of the sensor */
int non_portable_type; /* Platform dependent type of the sensor */
Uint64 sensor_timestamp; /* The timestamp of the last sensor update */
float data[16]; /* The current state of the sensor */
struct _SDL_SensorDriver *driver;