mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-04 17:06:25 +00:00
Added SDL_GameControllerGetSensorDataRate() to get the sensor update rate for a controller.
This commit is contained in:
@@ -2181,6 +2181,29 @@ SDL_bool SDL_GameControllerIsSensorEnabled(SDL_GameController *gamecontroller, S
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the data rate of a game controller sensor.
|
||||
*/
|
||||
float
|
||||
SDL_GameControllerGetSensorDataRate(SDL_GameController *gamecontroller, SDL_SensorType type)
|
||||
{
|
||||
SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller);
|
||||
int i;
|
||||
|
||||
if (!joystick) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
for (i = 0; i < joystick->nsensors; ++i) {
|
||||
SDL_JoystickSensorInfo *sensor = &joystick->sensors[i];
|
||||
|
||||
if (sensor->type == type) {
|
||||
return sensor->rate;
|
||||
}
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the current state of a game controller sensor.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user