Added SDL_GameControllerGetSensorDataRate() to get the sensor update rate for a controller.

This commit is contained in:
Sam Lantinga 2021-07-29 06:43:39 -07:00
parent ce8261dd6d
commit a186a503e7
12 changed files with 88 additions and 71 deletions

View file

@ -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.
*/