diff options
| author | 3gg <3gg@shellblade.net> | 2025-12-27 12:03:39 -0800 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-12-27 12:03:39 -0800 |
| commit | 5a079a2d114f96d4847d1ee305d5b7c16eeec50e (patch) | |
| tree | 8926ab44f168acf787d8e19608857b3af0f82758 /contrib/SDL-3.2.8/src/sensor/SDL_syssensor.h | |
Initial commit
Diffstat (limited to 'contrib/SDL-3.2.8/src/sensor/SDL_syssensor.h')
| -rw-r--r-- | contrib/SDL-3.2.8/src/sensor/SDL_syssensor.h | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/sensor/SDL_syssensor.h b/contrib/SDL-3.2.8/src/sensor/SDL_syssensor.h new file mode 100644 index 0000000..1ce63e5 --- /dev/null +++ b/contrib/SDL-3.2.8/src/sensor/SDL_syssensor.h | |||
| @@ -0,0 +1,110 @@ | |||
| 1 | /* | ||
| 2 | Simple DirectMedia Layer | ||
| 3 | Copyright (C) 1997-2025 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 | #include "SDL_internal.h" | ||
| 22 | |||
| 23 | #ifndef SDL_syssensor_c_h_ | ||
| 24 | #define SDL_syssensor_c_h_ | ||
| 25 | |||
| 26 | // This is the system specific header for the SDL sensor API | ||
| 27 | |||
| 28 | #include "SDL_sensor_c.h" | ||
| 29 | |||
| 30 | #define _guarded SDL_GUARDED_BY(SDL_sensor_lock) | ||
| 31 | |||
| 32 | // The SDL sensor structure | ||
| 33 | struct SDL_Sensor | ||
| 34 | { | ||
| 35 | SDL_SensorID instance_id _guarded; // Device instance, monotonically increasing from 0 | ||
| 36 | char *name _guarded; // Sensor name - system dependent | ||
| 37 | SDL_SensorType type _guarded; // Type of the sensor | ||
| 38 | int non_portable_type _guarded; // Platform dependent type of the sensor | ||
| 39 | |||
| 40 | float data[16] _guarded; // The current state of the sensor | ||
| 41 | |||
| 42 | struct SDL_SensorDriver *driver _guarded; | ||
| 43 | |||
| 44 | struct sensor_hwdata *hwdata _guarded; // Driver dependent information | ||
| 45 | |||
| 46 | SDL_PropertiesID props _guarded; | ||
| 47 | |||
| 48 | int ref_count _guarded; // Reference count for multiple opens | ||
| 49 | |||
| 50 | struct SDL_Sensor *next _guarded; // pointer to next sensor we have allocated | ||
| 51 | }; | ||
| 52 | |||
| 53 | #undef _guarded | ||
| 54 | |||
| 55 | typedef struct SDL_SensorDriver | ||
| 56 | { | ||
| 57 | /* Function to scan the system for sensors. | ||
| 58 | * sensor 0 should be the system default sensor. | ||
| 59 | * This function should return 0, or -1 on an unrecoverable fatal error. | ||
| 60 | */ | ||
| 61 | bool (*Init)(void); | ||
| 62 | |||
| 63 | // Function to return the number of sensors available right now | ||
| 64 | int (*GetCount)(void); | ||
| 65 | |||
| 66 | // Function to check to see if the available sensors have changed | ||
| 67 | void (*Detect)(void); | ||
| 68 | |||
| 69 | // Function to get the device-dependent name of a sensor | ||
| 70 | const char *(*GetDeviceName)(int device_index); | ||
| 71 | |||
| 72 | // Function to get the type of a sensor | ||
| 73 | SDL_SensorType (*GetDeviceType)(int device_index); | ||
| 74 | |||
| 75 | // Function to get the platform dependent type of a sensor | ||
| 76 | int (*GetDeviceNonPortableType)(int device_index); | ||
| 77 | |||
| 78 | // Function to get the current instance id of the sensor located at device_index | ||
| 79 | SDL_SensorID (*GetDeviceInstanceID)(int device_index); | ||
| 80 | |||
| 81 | /* Function to open a sensor for use. | ||
| 82 | The sensor to open is specified by the device index. | ||
| 83 | It returns 0, or -1 if there is an error. | ||
| 84 | */ | ||
| 85 | bool (*Open)(SDL_Sensor *sensor, int device_index); | ||
| 86 | |||
| 87 | /* Function to update the state of a sensor - called as a device poll. | ||
| 88 | * This function shouldn't update the sensor structure directly, | ||
| 89 | * but instead should call SDL_SendSensorUpdate() to deliver events | ||
| 90 | * and update sensor device state. | ||
| 91 | */ | ||
| 92 | void (*Update)(SDL_Sensor *sensor); | ||
| 93 | |||
| 94 | // Function to close a sensor after use | ||
| 95 | void (*Close)(SDL_Sensor *sensor); | ||
| 96 | |||
| 97 | // Function to perform any system-specific sensor related cleanup | ||
| 98 | void (*Quit)(void); | ||
| 99 | |||
| 100 | } SDL_SensorDriver; | ||
| 101 | |||
| 102 | // The available sensor drivers | ||
| 103 | extern SDL_SensorDriver SDL_ANDROID_SensorDriver; | ||
| 104 | extern SDL_SensorDriver SDL_COREMOTION_SensorDriver; | ||
| 105 | extern SDL_SensorDriver SDL_WINDOWS_SensorDriver; | ||
| 106 | extern SDL_SensorDriver SDL_DUMMY_SensorDriver; | ||
| 107 | extern SDL_SensorDriver SDL_VITA_SensorDriver; | ||
| 108 | extern SDL_SensorDriver SDL_N3DS_SensorDriver; | ||
| 109 | |||
| 110 | #endif // SDL_syssensor_h_ | ||
