mirror of
https://github.com/encounter/SDL.git
synced 2025-12-11 22:44:17 +00:00
Added microsecond timestamp to sensor values for PS4 and PS5 controllers using the HIDAPI driver
This commit is contained in:
@@ -474,6 +474,7 @@ typedef struct SDL_ControllerSensorEvent
|
||||
SDL_JoystickID which; /**< The joystick instance id */
|
||||
Sint32 sensor; /**< The type of the sensor, one of the values of ::SDL_SensorType */
|
||||
float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */
|
||||
Uint64 timestamp_us; /**< The timestamp of the sensor reading in microseconds, if the hardware provides this information. */
|
||||
} SDL_ControllerSensorEvent;
|
||||
|
||||
/**
|
||||
@@ -565,6 +566,7 @@ typedef struct SDL_SensorEvent
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Sint32 which; /**< The instance ID of the sensor */
|
||||
float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData() */
|
||||
Uint64 timestamp_us; /**< The timestamp of the sensor reading in microseconds, if the hardware provides this information. */
|
||||
} SDL_SensorEvent;
|
||||
|
||||
/**
|
||||
|
||||
@@ -895,6 +895,23 @@ 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 microseconds of the current sensor reading if available, or 0 if not
|
||||
* \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 2.26.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.
|
||||
*
|
||||
|
||||
@@ -267,7 +267,22 @@ extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetInstanceID(SDL_Sensor *sensor)
|
||||
*
|
||||
* \since This function is available since SDL 2.0.9.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor * sensor, float *data, int num_values);
|
||||
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 microseconds of the current sensor reading if available, or 0 if not
|
||||
* \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 2.0.9.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SensorGetDataWithTimestamp(SDL_Sensor *sensor, Uint64 *timestamp, float *data, int num_values);
|
||||
|
||||
/**
|
||||
* Close a sensor previously opened with SDL_SensorOpen().
|
||||
@@ -276,7 +291,7 @@ extern DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor * sensor, float *data,
|
||||
*
|
||||
* \since This function is available since SDL 2.0.9.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SensorClose(SDL_Sensor * sensor);
|
||||
extern DECLSPEC void SDLCALL SDL_SensorClose(SDL_Sensor *sensor);
|
||||
|
||||
/**
|
||||
* Update the current state of the open sensors.
|
||||
|
||||
Reference in New Issue
Block a user