|
SDL3pp
A slim C++ wrapper for SDL3
|
SDL sensor management. More...
Classes | |
| struct | SDL::Sensor |
| The opaque structure used to identify an opened SDL sensor. More... | |
Typedefs | |
| using | SDL::SensorRaw = SDL_Sensor* |
| Alias to raw representation for Sensor. | |
| using | SDL::SensorRef = ResourceRef<Sensor> |
| Reference for Sensor. | |
| using | SDL::SensorID = Uint32 |
| This is a unique ID for a sensor for the time it is connected to the system, and is never reused for the lifetime of the application. | |
| using | SDL::SensorType = SDL_SensorType |
| The different sensors defined by SDL. | |
Functions | |
| OwnArray< SensorID > | SDL::GetSensors () |
| Get a list of currently connected sensors. | |
| const char * | SDL::GetSensorNameForID (SensorID instance_id) |
| Get the implementation dependent name of a sensor. | |
| SensorType | SDL::GetSensorTypeForID (SensorID instance_id) |
| Get the type of a sensor. | |
| int | SDL::GetSensorNonPortableTypeForID (SensorID instance_id) |
| Get the platform dependent type of a sensor. | |
| Sensor | SDL::OpenSensor (SensorID instance_id) |
| Open a sensor for use. | |
| SensorRef | SDL::GetSensorFromID (SensorID instance_id) |
| Return the Sensor associated with an instance ID. | |
| PropertiesRef | SDL::GetSensorProperties (SensorRef sensor) |
| Get the properties associated with a sensor. | |
| const char * | SDL::GetSensorName (SensorRef sensor) |
| Get the implementation dependent name of a sensor. | |
| SensorType | SDL::GetSensorType (SensorRef sensor) |
| Get the type of a sensor. | |
| int | SDL::GetSensorNonPortableType (SensorRef sensor) |
| Get the platform dependent type of a sensor. | |
| SensorID | SDL::GetSensorID (SensorRef sensor) |
| Get the instance ID of a sensor. | |
| void | SDL::GetSensorData (SensorRef sensor, float *data, int num_values) |
| Get the current state of an opened sensor. | |
| void | SDL::CloseSensor (SensorRaw sensor) |
| Close a sensor previously opened with OpenSensor(). | |
| void | SDL::UpdateSensors () |
| Update the current state of the open sensors. | |
| SDL::Sensor::Sensor (SensorID instance_id) | |
| Open a sensor for use. | |
| PropertiesRef | SDL::Sensor::GetProperties () |
| Get the properties associated with a sensor. | |
| const char * | SDL::Sensor::GetName () |
| Get the implementation dependent name of a sensor. | |
| SensorType | SDL::Sensor::GetType () |
| Get the type of a sensor. | |
| int | SDL::Sensor::GetNonPortableType () |
| Get the platform dependent type of a sensor. | |
| SensorID | SDL::Sensor::GetID () |
| Get the instance ID of a sensor. | |
| void | SDL::Sensor::GetData (float *data, int num_values) |
| Get the current state of an opened sensor. | |
| void | SDL::Sensor::Close () |
| Close a sensor previously opened with OpenSensor(). | |
Variables | |
| constexpr SensorType | SDL::SENSOR_INVALID |
| Returned for an invalid sensor. | |
| constexpr SensorType | SDL::SENSOR_UNKNOWN |
| Unknown sensor type. | |
| constexpr SensorType | SDL::SENSOR_ACCEL = SDL_SENSOR_ACCEL |
| Accelerometer. | |
| constexpr SensorType | SDL::SENSOR_GYRO = SDL_SENSOR_GYRO |
| Gyroscope. | |
| constexpr SensorType | SDL::SENSOR_ACCEL_L = SDL_SENSOR_ACCEL_L |
| Accelerometer for left Joy-Con controller and Wii nunchuk. | |
| constexpr SensorType | SDL::SENSOR_GYRO_L |
| Gyroscope for left Joy-Con controller. | |
| constexpr SensorType | SDL::SENSOR_ACCEL_R |
| Accelerometer for right Joy-Con controller. | |
| constexpr SensorType | SDL::SENSOR_GYRO_R |
| Gyroscope for right Joy-Con controller. | |
| constexpr SensorType | SDL::SENSOR_COUNT = SDL_SENSOR_COUNT |
| SENSOR_COUNT. | |
| constexpr float | SDL::STANDARD_GRAVITY = SDL_STANDARD_GRAVITY |
| A constant to represent standard gravity for accelerometer sensors. | |
SDL sensor management.
These APIs grant access to gyros and accelerometers on various platforms.
In order to use these functions, Init() must have been called with the INIT_SENSOR flag. This causes SDL to scan the system for sensors, and load appropriate drivers.
| using SDL::SensorID = Uint32 |
This is a unique ID for a sensor for the time it is connected to the system, and is never reused for the lifetime of the application.
The value 0 is an invalid ID.
| using SDL::SensorRef = ResourceRef<Sensor> |
Reference for Sensor.
This does not take ownership!
| using SDL::SensorType = SDL_SensorType |
The different sensors defined by SDL.
Additional sensors may be available, using platform dependent semantics.
Here are the additional Android sensors:
https://developer.android.com/reference/android/hardware/SensorEvent.html#values
Accelerometer sensor notes:
The accelerometer returns the current acceleration in SI meters per second squared. This measurement includes the force of gravity, so a device at rest will have an value of STANDARD_GRAVITY away from the center of the earth, which is a positive Y value.
For phones and tablets held in natural orientation and game controllers held in front of you, the axes are defined as follows:
The accelerometer axis data is not changed when the device is rotated.
Gyroscope sensor notes:
The gyroscope returns the current rate of rotation in radians per second. The rotation is positive in the counter-clockwise direction. That is, an observer looking from a positive location on one of the axes would see positive rotation on that axis when it appeared to be rotating counter-clockwise.
For phones and tablets held in natural orientation and game controllers held in front of you, the axes are defined as follows:
The gyroscope axis data is not changed when the device is rotated.
|
inline |
Close a sensor previously opened with OpenSensor().
|
inline |
Close a sensor previously opened with OpenSensor().
| sensor | the Sensor object to close. |
|
inline |
Get the current state of an opened sensor.
The number of values and interpretation of the data is sensor dependent.
| data | a pointer filled with the current sensor state. |
| num_values | the number of values to write to data. |
| Error | on failure. |
|
inline |
|
inline |
Get the implementation dependent name of a sensor.
|
inline |
Get the platform dependent type of a sensor.
|
inline |
|
inline |
Get the current state of an opened sensor.
The number of values and interpretation of the data is sensor dependent.
| sensor | the Sensor object to query. |
| data | a pointer filled with the current sensor state. |
| num_values | the number of values to write to data. |
| Error | on failure. |
Return the Sensor associated with an instance ID.
| instance_id | the sensor instance ID. |
|
inline |
Get the implementation dependent name of a sensor.
| sensor | the Sensor object. |
|
inline |
Get the implementation dependent name of a sensor.
This can be called before any sensors are opened.
| instance_id | the sensor instance ID. |
|
inline |
|
inline |
Get the platform dependent type of a sensor.
This can be called before any sensors are opened.
| instance_id | the sensor instance ID. |
|
inline |
Get a list of currently connected sensors.
|
inline |
Get the type of a sensor.
| sensor | the Sensor object to inspect. |
|
inline |
Get the type of a sensor.
This can be called before any sensors are opened.
| instance_id | the sensor instance ID. |
|
inline |
Get the type of a sensor.
Open a sensor for use.
| instance_id | the sensor instance ID. |
|
inline |
Open a sensor for use.
| instance_id | the sensor instance ID. |
|
inline |
Update the current state of the open sensors.
This is called automatically by the event loop if sensor events are enabled.
This needs to be called from the thread that initialized the sensor subsystem.
|
constexpr |
Accelerometer for right Joy-Con controller.
|
constexpr |
Gyroscope for left Joy-Con controller.
|
constexpr |
Gyroscope for right Joy-Con controller.
|
constexpr |
Returned for an invalid sensor.
|
constexpr |
Unknown sensor type.
|
constexpr |
A constant to represent standard gravity for accelerometer sensors.
The accelerometer returns the current acceleration in SI meters per second squared. This measurement includes the force of gravity, so a device at rest will have an value of STANDARD_GRAVITY away from the center of the earth, which is a positive Y value.