1 module nudsfml.window.sensor; 2 3 import bindbc.sfml.window; 4 5 import nudsfml.system.vector3; 6 7 /** 8 * Give access to the real-time state of the sensors. 9 */ 10 final abstract class Sensor { 11 /// Sensor type 12 enum Type{ 13 /// Measures the raw acceleration (m/s²) 14 Accelerometer, 15 /// Measures the raw rotation rates (°/s) 16 Gyroscope, 17 /// Measures the ambient magnetic field (micro-teslas) 18 Magnetometer, 19 /** 20 * Measures the direction and intensity of gravity, independent of 21 * device acceleration (m/s²) 22 */ 23 Gravity, 24 /** 25 * Measures the direction and intensity of device cceleration, 26 * independent of the gravity (m/s²) 27 */ 28 UserAcceleration, 29 /// Measures the absolute 3D orientation (°) 30 Orientation, 31 /// Keep last - the total number of sensor types 32 Count 33 } 34 35 /** 36 * Check if a sensor is available on the underlying platform. 37 * 38 * Params: 39 * sensor = Sensor to check 40 * 41 * Returns: true if the sensor is available, false otherwise. 42 */ 43 static bool isAvailable (Type sensor){ 44 return false; //sfSensor_isAvailable(cast(sfSensorType)sensor)>0; 45 } 46 47 /** 48 * Enable or disable a sensor. 49 * 50 * All sensors are disabled by default, to avoid consuming too much battery 51 * power. Once a sensor is enabled, it starts sending events of the 52 * corresponding type. 53 * 54 * This function does nothing if the sensor is unavailable. 55 * 56 * Params: 57 * sensor = Sensor to enable 58 * enabled = true to enable, false to disable 59 */ 60 static void setEnabled (Type sensor, bool enabled) { 61 //sfSensor_setEnabled(cast(sfSensorType)sensor, enabled); 62 } 63 64 /** 65 * Get the current sensor value. 66 * 67 * Params: 68 * sensor = Sensor to read 69 * 70 * Returns: The current sensor value. 71 */ 72 static Vector3f getValue (Type sensor){ 73 Vector3f getValue ;//= cast(Vector3f)sfSensor_getValue(cast(sfSensorType)sensor); 74 return getValue; 75 } 76 }