1#ifndef SDL3PP_SENSOR_H_
2#define SDL3PP_SENSOR_H_
4#include <SDL3/SDL_sensor.h>
5#include "SDL3pp_error.h"
6#include "SDL3pp_properties.h"
7#include "SDL3pp_stdinc.h"
8#include "SDL3pp_version.h"
126#if SDL_VERSION_ATLEAST(3, 2, 22)
258 void GetData(
float* data,
int num_values);
284 auto data = SDL_GetSensors(&count);
300 return SDL_GetSensorNameForID(instance_id);
315 return SDL_GetSensorTypeForID(instance_id);
331 return SDL_GetSensorNonPortableTypeForID(instance_id);
346 :
Sensor(SDL_OpenSensor(instance_id))
361 return {SDL_GetSensorFromID(instance_id)};
375 return {
CheckError(SDL_GetSensorProperties(sensor))};
394 return SDL_GetSensorName(sensor);
409 return SDL_GetSensorType(sensor);
424 return SDL_GetSensorNonPortableType(sensor);
462 CheckError(SDL_GetSensorData(sensor, data, num_values));
Base class for SDL memory allocated array wrap.
Definition SDL3pp_ownPtr.h:44
constexpr RawPointer get() const noexcept
Definition SDL3pp_resource.h:53
constexpr RawPointer release() noexcept
Definition SDL3pp_resource.h:56
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:199
ResourceRef< Properties > PropertiesRef
Reference for Properties.
Definition SDL3pp_properties.h:54
ResourceRef< Sensor > SensorRef
Reference for Sensor.
Definition SDL3pp_sensor.h:37
void GetSensorData(SensorRef sensor, float *data, int num_values)
Get the current state of an opened sensor.
Definition SDL3pp_sensor.h:460
SensorRef GetSensorFromID(SensorID instance_id)
Return the Sensor associated with an instance ID.
Definition SDL3pp_sensor.h:359
SensorID GetSensorID(SensorRef sensor)
Get the instance ID of a sensor.
Definition SDL3pp_sensor.h:441
constexpr SensorType SENSOR_GYRO
Gyroscope.
Definition SDL3pp_sensor.h:112
Uint32 SensorID
This is a unique ID for a sensor for the time it is connected to the system, and is never reused for ...
Definition SDL3pp_sensor.h:47
OwnArray< SensorID > GetSensors()
Get a list of currently connected sensors.
Definition SDL3pp_sensor.h:281
const char * GetSensorName(SensorRef sensor)
Get the implementation dependent name of a sensor.
Definition SDL3pp_sensor.h:392
int GetNonPortableType()
Get the platform dependent type of a sensor.
Definition SDL3pp_sensor.h:427
void GetData(float *data, int num_values)
Get the current state of an opened sensor.
Definition SDL3pp_sensor.h:465
void UpdateSensors()
Update the current state of the open sensors.
Definition SDL3pp_sensor.h:491
constexpr SensorType SENSOR_ACCEL
Accelerometer.
Definition SDL3pp_sensor.h:110
constexpr SensorType SENSOR_INVALID
Returned for an invalid sensor.
Definition SDL3pp_sensor.h:104
constexpr SensorType SENSOR_ACCEL_L
Accelerometer for left Joy-Con controller and Wii nunchuk.
Definition SDL3pp_sensor.h:115
SensorType GetSensorType(SensorRef sensor)
Get the type of a sensor.
Definition SDL3pp_sensor.h:407
Sensor OpenSensor(SensorID instance_id)
Open a sensor for use.
Definition SDL3pp_sensor.h:343
SensorType GetType()
Get the type of a sensor.
Definition SDL3pp_sensor.h:412
constexpr SensorType SENSOR_UNKNOWN
Unknown sensor type.
Definition SDL3pp_sensor.h:107
SDL_Sensor * SensorRaw
Alias to raw representation for Sensor.
Definition SDL3pp_sensor.h:30
int GetSensorNonPortableType(SensorRef sensor)
Get the platform dependent type of a sensor.
Definition SDL3pp_sensor.h:422
SensorType GetSensorTypeForID(SensorID instance_id)
Get the type of a sensor.
Definition SDL3pp_sensor.h:313
PropertiesRef GetSensorProperties(SensorRef sensor)
Get the properties associated with a sensor.
Definition SDL3pp_sensor.h:373
SDL_SensorType SensorType
The different sensors defined by SDL.
Definition SDL3pp_sensor.h:102
void CloseSensor(SensorRaw sensor)
Close a sensor previously opened with OpenSensor().
Definition SDL3pp_sensor.h:477
constexpr float STANDARD_GRAVITY
A constant to represent standard gravity for accelerometer sensors.
Definition SDL3pp_sensor.h:271
constexpr SensorType SENSOR_ACCEL_R
Accelerometer for right Joy-Con controller.
Definition SDL3pp_sensor.h:120
constexpr SensorType SENSOR_COUNT
SENSOR_COUNT.
Definition SDL3pp_sensor.h:128
SensorID GetID()
Get the instance ID of a sensor.
Definition SDL3pp_sensor.h:446
const char * GetSensorNameForID(SensorID instance_id)
Get the implementation dependent name of a sensor.
Definition SDL3pp_sensor.h:298
void Close()
Close a sensor previously opened with OpenSensor().
Definition SDL3pp_sensor.h:479
constexpr SensorType SENSOR_GYRO_R
Gyroscope for right Joy-Con controller.
Definition SDL3pp_sensor.h:123
int GetSensorNonPortableTypeForID(SensorID instance_id)
Get the platform dependent type of a sensor.
Definition SDL3pp_sensor.h:329
const char * GetName()
Get the implementation dependent name of a sensor.
Definition SDL3pp_sensor.h:397
PropertiesRef GetProperties()
Get the properties associated with a sensor.
Definition SDL3pp_sensor.h:378
constexpr SensorType SENSOR_GYRO_L
Gyroscope for left Joy-Con controller.
Definition SDL3pp_sensor.h:117
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition SDL3pp_stdinc.h:290
Main include header for the SDL3pp library.
A non-owning reference wrapper for a given resource.
Definition SDL3pp_resource.h:156
The opaque structure used to identify an opened SDL sensor.
Definition SDL3pp_sensor.h:140
constexpr Sensor(const Sensor &other)=delete
Copy constructor.
constexpr Sensor & operator=(Sensor &&other) noexcept
Assignment operator.
Definition SDL3pp_sensor.h:183
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
Sensor & operator=(const Sensor &other)=delete
Assignment operator.
~Sensor()
Destructor.
Definition SDL3pp_sensor.h:180
constexpr Sensor(SensorRaw resource) noexcept
Constructs from raw Sensor.
Definition SDL3pp_sensor.h:150
constexpr Sensor(Sensor &&other) noexcept
Move constructor.
Definition SDL3pp_sensor.h:159