1 /+ 2 + Copyright 2022 – 2023 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 string[][] ret; 38 static if(sdlSupport >= SDLSupport.v2_0_9){ 39 ret ~= makeFnBinds([ 40 [q{int}, q{SDL_NumSensors}, q{}], 41 [q{const(char)*}, q{SDL_SensorGetDeviceName}, q{int device_index}], 42 [q{SDL_SensorType}, q{SDL_SensorGetDeviceType}, q{int device_index}], 43 [q{int}, q{SDL_SensorGetDeviceNonPortableType}, q{int device_index}], 44 [q{SDL_SensorID}, q{SDL_SensorGetDeviceInstanceID}, q{int device_index}], 45 [q{SDL_Sensor*}, q{SDL_SensorOpen}, q{int device_index}], 46 [q{SDL_Sensor*}, q{SDL_SensorFromInstanceID}, q{SDL_SensorID instance_id}], 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 num_values}], 51 [q{void}, q{SDL_SensorClose}, q{SDL_Sensor* sensor}], 52 [q{void}, q{SDL_SensorUpdate}, q{}], 53 ]); 54 } 55 static if(sdlSupport >= SDLSupport.v2_0_14){ 56 ret ~= makeFnBinds([ 57 [q{void}, q{SDL_LockSensors}, q{}], 58 [q{void}, q{SDL_UnlockSensors}, q{}], 59 ]); 60 } 61 static if(sdlSupport >= SDLSupport.v2_26){ 62 ret ~= makeFnBinds([ 63 [q{int}, q{SDL_SensorGetDataWithTimestamp}, q{SDL_Sensor* sensor, ulong* timestamp, float* data, int num_values}], 64 ]); 65 } 66 return ret; 67 }()));