1 
2 //          Copyright 2018 - 2021 Michael D. Parker
3 // Distributed under the Boost Software License, Version 1.0.
4 //    (See accompanying file LICENSE_1_0.txt or copy at
5 //          http://www.boost.org/LICENSE_1_0.txt)
6 
7 module bindbc.sdl.bind.sdlsensor;
8 
9 import bindbc.sdl.config;
10 
11 static if(sdlSupport >= SDLSupport.sdl209) {
12     struct SDL_Sensor;
13     alias int SDL_SensorID;
14 
15     enum SDL_SensorType {
16         SDL_SENSOR_INVALID = -1,
17         SDL_SENSOR_UNKNOWN,
18         SDL_SENSOR_ACCEL,
19         SDL_SENSOR_GYRO,
20     }
21     mixin(expandEnum!SDL_SensorType);
22 
23     enum SDL_STANDARD_GRAVITY = 9.80665f;
24 
25     static if(staticBinding) {
26         extern(C) @nogc nothrow {
27             int SDL_NumSensors();
28             const(char)* SDL_SensorGetDeviceName(int device_index);
29             SDL_SensorType SDL_SensorGetDeviceType(int device_index);
30             int SDL_SensorGetDeviceNonPortableType(int device_index);
31             SDL_SensorID SDL_SensorGetDeviceInstanceID(int device_index);
32             SDL_Sensor* SDL_SensorOpen(int device_index);
33             SDL_Sensor* SDL_SensorFromInstanceID(SDL_SensorID instance_id);
34             const(char)* SDL_SensorGetName(SDL_Sensor* sensor);
35             SDL_SensorType SDL_SensorGetType(SDL_Sensor* sensor);
36             int SDL_SensorGetNonPortableType(SDL_Sensor* sensor);
37             int SDL_SensorGetData(SDL_Sensor* sensor, float* data, int num_values);
38             void SDL_SensorClose(SDL_Sensor* sensor);
39             void SDL_SensorUpdate();
40         }
41     }
42     else {
43         extern(C) @nogc nothrow {
44             alias pSDL_NumSensors = int function();
45             alias pSDL_SensorGetDeviceName = const(char)* function(int device_index);
46             alias pSDL_SensorGetDeviceType = SDL_SensorType function(int device_index);
47             alias pSDL_SensorGetDeviceNonPortableType = int function(int device_index);
48             alias pSDL_SensorGetDeviceInstanceID = SDL_SensorID function(int device_index);
49             alias pSDL_SensorOpen = SDL_Sensor* function(int device_index);
50             alias pSDL_SensorFromInstanceID = SDL_Sensor* function(SDL_SensorID instance_id);
51             alias pSDL_SensorGetName = const(char)* function(SDL_Sensor* sensor);
52             alias pSDL_SensorGetType = SDL_SensorType function(SDL_Sensor* sensor);
53             alias pSDL_SensorGetNonPortableType = int function(SDL_Sensor* sensor);
54             alias pSDL_SensorGetData = int function(SDL_Sensor* sensor, float* data, int num_values);
55             alias pSDL_SensorClose = void function(SDL_Sensor* sensor);
56             alias pSDL_SensorUpdate = void function();
57         }
58 
59         __gshared {
60             pSDL_NumSensors SDL_NumSensors;
61             pSDL_SensorGetDeviceName SDL_SensorGetDeviceName;
62             pSDL_SensorGetDeviceType SDL_SensorGetDeviceType;
63             pSDL_SensorGetDeviceNonPortableType SDL_SensorGetDeviceNonPortableType;
64             pSDL_SensorGetDeviceInstanceID SDL_SensorGetDeviceInstanceID;
65             pSDL_SensorOpen SDL_SensorOpen;
66             pSDL_SensorFromInstanceID SDL_SensorFromInstanceID;
67             pSDL_SensorGetName SDL_SensorGetName;
68             pSDL_SensorGetType SDL_SensorGetType;
69             pSDL_SensorGetNonPortableType SDL_SensorGetNonPortableType;
70             pSDL_SensorGetData SDL_SensorGetData;
71             pSDL_SensorClose SDL_SensorClose;
72             pSDL_SensorUpdate SDL_SensorUpdate;
73         }
74     }
75 }