My Project
SDL_sensor.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 
29 #ifndef SDL_sensor_h_
30 #define SDL_sensor_h_
31 
32 #include "SDL_stdinc.h"
33 #include "SDL_error.h"
34 
35 #include "begin_code.h"
36 /* Set up for C function definitions, even when using C++ */
37 #ifdef __cplusplus
38 /* *INDENT-OFF* */
39 extern "C" {
40 /* *INDENT-ON* */
41 #endif
42 
51 struct _SDL_Sensor;
52 typedef struct _SDL_Sensor SDL_Sensor;
53 
60 typedef Sint32 SDL_SensorID;
61 
62 /* The different sensors defined by SDL
63  *
64  * Additional sensors may be available, using platform dependent semantics.
65  *
66  * Hare are the additional Android sensors:
67  * https://developer.android.com/reference/android/hardware/SensorEvent.html#values
68  */
69 typedef enum
70 {
76 
99 #define SDL_STANDARD_GRAVITY 9.80665f
100 
125 /* Function prototypes */
126 
137 extern DECLSPEC void SDLCALL SDL_LockSensors(void);
138 extern DECLSPEC void SDLCALL SDL_UnlockSensors(void);
139 
143 extern DECLSPEC int SDLCALL SDL_NumSensors(void);
144 
152 extern DECLSPEC const char *SDLCALL SDL_SensorGetDeviceName(int device_index);
153 
161 extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetDeviceType(int device_index);
162 
170 extern DECLSPEC int SDLCALL SDL_SensorGetDeviceNonPortableType(int device_index);
171 
179 extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetDeviceInstanceID(int device_index);
180 
188 extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorOpen(int device_index);
189 
193 extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorFromInstanceID(SDL_SensorID instance_id);
194 
200 extern DECLSPEC const char *SDLCALL SDL_SensorGetName(SDL_Sensor *sensor);
201 
209 extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetType(SDL_Sensor *sensor);
210 
218 extern DECLSPEC int SDLCALL SDL_SensorGetNonPortableType(SDL_Sensor *sensor);
219 
227 extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetInstanceID(SDL_Sensor *sensor);
228 
240 extern DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor * sensor, float *data, int num_values);
241 
245 extern DECLSPEC void SDLCALL SDL_SensorClose(SDL_Sensor * sensor);
246 
254 extern DECLSPEC void SDLCALL SDL_SensorUpdate(void);
255 
256 
257 /* Ends C function definitions when using C++ */
258 #ifdef __cplusplus
259 /* *INDENT-OFF* */
260 }
261 /* *INDENT-ON* */
262 #endif
263 #include "close_code.h"
264 
265 #endif /* SDL_sensor_h_ */
266 
267 /* vi: set ts=4 sw=4 expandtab: */
DECLSPEC void SDLCALL SDL_LockSensors(void)
Sint32 SDL_SensorID
Definition: SDL_sensor.h:60
DECLSPEC SDL_Sensor *SDLCALL SDL_SensorOpen(int device_index)
Open a sensor for use.
DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetDeviceType(int device_index)
Get the type of a sensor.
DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor *sensor, float *data, int num_values)
DECLSPEC void SDLCALL SDL_SensorUpdate(void)
DECLSPEC int SDLCALL SDL_NumSensors(void)
Count the number of sensors attached to the system right now.
DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetType(SDL_Sensor *sensor)
Get the type of a sensor.
DECLSPEC void SDLCALL SDL_SensorClose(SDL_Sensor *sensor)
DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetDeviceInstanceID(int device_index)
Get the instance ID of a sensor.
DECLSPEC int SDLCALL SDL_SensorGetDeviceNonPortableType(int device_index)
Get the platform dependent type of a sensor.
SDL_SensorType
Definition: SDL_sensor.h:70
@ SDL_SENSOR_INVALID
Definition: SDL_sensor.h:71
@ SDL_SENSOR_GYRO
Definition: SDL_sensor.h:74
@ SDL_SENSOR_UNKNOWN
Definition: SDL_sensor.h:72
@ SDL_SENSOR_ACCEL
Definition: SDL_sensor.h:73
DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetInstanceID(SDL_Sensor *sensor)
Get the instance ID of a sensor.
DECLSPEC int SDLCALL SDL_SensorGetNonPortableType(SDL_Sensor *sensor)
Get the platform dependent type of a sensor.
DECLSPEC SDL_Sensor *SDLCALL SDL_SensorFromInstanceID(SDL_SensorID instance_id)
DECLSPEC const char *SDLCALL SDL_SensorGetDeviceName(int device_index)
Get the implementation dependent name of a sensor.
DECLSPEC const char *SDLCALL SDL_SensorGetName(SDL_Sensor *sensor)
Get the implementation dependent name of a sensor.