Path: blob/master/thirdparty/sdl/sensor/SDL_syssensor.h
10278 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2025 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/20#include "SDL_internal.h"2122#ifndef SDL_syssensor_c_h_23#define SDL_syssensor_c_h_2425// This is the system specific header for the SDL sensor API2627#include "SDL_sensor_c.h"2829#define _guarded SDL_GUARDED_BY(SDL_sensor_lock)3031// The SDL sensor structure32struct SDL_Sensor33{34SDL_SensorID instance_id _guarded; // Device instance, monotonically increasing from 035char *name _guarded; // Sensor name - system dependent36SDL_SensorType type _guarded; // Type of the sensor37int non_portable_type _guarded; // Platform dependent type of the sensor3839float data[16] _guarded; // The current state of the sensor4041struct SDL_SensorDriver *driver _guarded;4243struct sensor_hwdata *hwdata _guarded; // Driver dependent information4445SDL_PropertiesID props _guarded;4647int ref_count _guarded; // Reference count for multiple opens4849struct SDL_Sensor *next _guarded; // pointer to next sensor we have allocated50};5152#undef _guarded5354typedef struct SDL_SensorDriver55{56/* Function to scan the system for sensors.57* sensor 0 should be the system default sensor.58* This function should return 0, or -1 on an unrecoverable fatal error.59*/60bool (*Init)(void);6162// Function to return the number of sensors available right now63int (*GetCount)(void);6465// Function to check to see if the available sensors have changed66void (*Detect)(void);6768// Function to get the device-dependent name of a sensor69const char *(*GetDeviceName)(int device_index);7071// Function to get the type of a sensor72SDL_SensorType (*GetDeviceType)(int device_index);7374// Function to get the platform dependent type of a sensor75int (*GetDeviceNonPortableType)(int device_index);7677// Function to get the current instance id of the sensor located at device_index78SDL_SensorID (*GetDeviceInstanceID)(int device_index);7980/* Function to open a sensor for use.81The sensor to open is specified by the device index.82It returns 0, or -1 if there is an error.83*/84bool (*Open)(SDL_Sensor *sensor, int device_index);8586/* Function to update the state of a sensor - called as a device poll.87* This function shouldn't update the sensor structure directly,88* but instead should call SDL_SendSensorUpdate() to deliver events89* and update sensor device state.90*/91void (*Update)(SDL_Sensor *sensor);9293// Function to close a sensor after use94void (*Close)(SDL_Sensor *sensor);9596// Function to perform any system-specific sensor related cleanup97void (*Quit)(void);9899} SDL_SensorDriver;100101// The available sensor drivers102extern SDL_SensorDriver SDL_ANDROID_SensorDriver;103extern SDL_SensorDriver SDL_COREMOTION_SensorDriver;104extern SDL_SensorDriver SDL_WINDOWS_SensorDriver;105extern SDL_SensorDriver SDL_DUMMY_SensorDriver;106extern SDL_SensorDriver SDL_VITA_SensorDriver;107extern SDL_SensorDriver SDL_N3DS_SensorDriver;108109#endif // SDL_syssensor_h_110111112