1 /+
2 +            Copyright 2022 – 2024 Aya Partridge
3 +          Copyright 2018 - 2022 Michael D. Parker
4 + Distributed under the Boost Software License, Version 1.0.
5 +     (See accompanying file LICENSE_1_0.txt or copy at
6 +           http://www.boost.org/LICENSE_1_0.txt)
7 +/
8 module sdl.sensor;
9 
10 import bindbc.sdl.config;
11 import bindbc.sdl.codegen;
12 
13 static if(sdlSupport >= SDLSupport.v2_0_9){
14 	struct SDL_Sensor;
15 	
16 	alias SDL_SensorID = int;
17 	
18 	alias SDL_SensorType = int;
19 	enum: SDL_SensorType{
20 		SDL_SENSOR_INVALID    = -1,
21 		SDL_SENSOR_UNKNOWN    = 0,
22 		SDL_SENSOR_ACCEL      = 1,
23 		SDL_SENSOR_GYRO       = 2,
24 	}
25 	static if(sdlSupport >= SDLSupport.v2_26)
26 	enum: SDL_SensorType{
27 		SDL_SENSOR_ACCEL_L    = 3,
28 		SDL_SENSOR_GYRO_L     = 4,
29 		SDL_SENSOR_ACCEL_R    = 5,
30 		SDL_SENSOR_GYRO_R     = 6,
31 	}
32 	
33 	enum SDL_STANDARD_GRAVITY = 9.80665f;
34 }
35 
36 mixin(joinFnBinds((){
37 	FnBind[] ret;
38 	if(sdlSupport >= SDLSupport.v2_0_9){
39 		FnBind[] add = [
40 			{q{int}, q{SDL_NumSensors}, q{}},
41 			{q{const(char)*}, q{SDL_SensorGetDeviceName}, q{int deviceIndex}},
42 			{q{SDL_SensorType}, q{SDL_SensorGetDeviceType}, q{int deviceIndex}},
43 			{q{int}, q{SDL_SensorGetDeviceNonPortableType}, q{int deviceIndex}},
44 			{q{SDL_SensorID}, q{SDL_SensorGetDeviceInstanceID}, q{int deviceIndex}},
45 			{q{SDL_Sensor*}, q{SDL_SensorOpen}, q{int deviceIndex}},
46 			{q{SDL_Sensor*}, q{SDL_SensorFromInstanceID}, q{SDL_SensorID instanceID}},
47 			{q{const(char)*}, q{SDL_SensorGetName}, q{SDL_Sensor* sensor}},
48 			{q{SDL_SensorType}, q{SDL_SensorGetType}, q{SDL_Sensor* sensor}},
49 			{q{int}, q{SDL_SensorGetNonPortableType}, q{SDL_Sensor* sensor}},
50 			{q{int}, q{SDL_SensorGetData}, q{SDL_Sensor* sensor, float* data, int numValues}},
51 			{q{void}, q{SDL_SensorClose}, q{SDL_Sensor* sensor}},
52 			{q{void}, q{SDL_SensorUpdate}, q{}},
53 		];
54 		ret ~= add;
55 	}
56 	if(sdlSupport >= SDLSupport.v2_0_14){
57 		FnBind[] add = [
58 			{q{void}, q{SDL_LockSensors}, q{}},
59 			{q{void}, q{SDL_UnlockSensors}, q{}},
60 		];
61 		ret ~= add;
62 	}
63 	if(sdlSupport >= SDLSupport.v2_26){
64 		FnBind[] add = [
65 			{q{int}, q{SDL_SensorGetDataWithTimestamp}, q{SDL_Sensor* sensor, ulong* timestamp, float* data, int numValues}},
66 		];
67 		ret ~= add;
68 	}
69 	return ret;
70 }()));