2018-08-21 12:11:34 -07:00
|
|
|
/*
|
|
|
|
|
Simple DirectMedia Layer
|
2026-01-01 09:39:50 -08:00
|
|
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
2018-08-21 12:11:34 -07:00
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
|
freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
|
appreciated but is not required.
|
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
|
misrepresented as being the original software.
|
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
|
*/
|
2022-11-29 18:34:15 -08:00
|
|
|
#include "SDL_internal.h"
|
2018-08-21 12:11:34 -07:00
|
|
|
|
|
|
|
|
#ifdef SDL_SENSOR_ANDROID
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// This is the system specific header for the SDL sensor API
|
2018-08-21 12:11:34 -07:00
|
|
|
#include <android/sensor.h>
|
|
|
|
|
|
|
|
|
|
#include "SDL_androidsensor.h"
|
|
|
|
|
#include "../SDL_syssensor.h"
|
|
|
|
|
#include "../SDL_sensor_c.h"
|
2023-06-20 01:17:44 -07:00
|
|
|
#include "../../thread/SDL_systhread.h"
|
2018-08-21 12:11:34 -07:00
|
|
|
|
|
|
|
|
#ifndef LOOPER_ID_USER
|
2022-11-30 12:51:59 -08:00
|
|
|
#define LOOPER_ID_USER 3
|
2018-08-21 12:11:34 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
ASensorRef asensor;
|
|
|
|
|
SDL_SensorID instance_id;
|
2023-06-20 01:17:44 -07:00
|
|
|
ASensorEventQueue *event_queue;
|
|
|
|
|
SDL_Sensor *sensor;
|
2018-08-21 12:11:34 -07:00
|
|
|
} SDL_AndroidSensor;
|
|
|
|
|
|
2023-06-20 01:17:44 -07:00
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
SDL_AtomicInt running;
|
|
|
|
|
SDL_Thread *thread;
|
|
|
|
|
SDL_Semaphore *sem;
|
|
|
|
|
} SDL_AndroidSensorThreadContext;
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
static ASensorManager *SDL_sensor_manager;
|
|
|
|
|
static ALooper *SDL_sensor_looper;
|
2023-06-20 01:17:44 -07:00
|
|
|
static SDL_AndroidSensorThreadContext SDL_sensor_thread_context;
|
|
|
|
|
static SDL_AndroidSensor *SDL_sensors SDL_GUARDED_BY(SDL_sensors_lock);
|
2018-08-21 12:11:34 -07:00
|
|
|
static int SDL_sensors_count;
|
|
|
|
|
|
2023-06-20 01:17:44 -07:00
|
|
|
static int SDLCALL SDL_ANDROID_SensorThread(void *data)
|
|
|
|
|
{
|
|
|
|
|
SDL_AndroidSensorThreadContext *ctx = (SDL_AndroidSensorThreadContext *)data;
|
|
|
|
|
int i, events;
|
|
|
|
|
ASensorEvent event;
|
|
|
|
|
struct android_poll_source *source;
|
|
|
|
|
|
2024-10-04 08:57:03 -07:00
|
|
|
SDL_SetCurrentThreadPriority(SDL_THREAD_PRIORITY_HIGH);
|
2023-06-20 01:17:44 -07:00
|
|
|
|
|
|
|
|
SDL_sensor_looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
|
2024-07-24 12:39:30 -07:00
|
|
|
SDL_SignalSemaphore(ctx->sem);
|
2023-06-20 01:17:44 -07:00
|
|
|
|
2024-09-16 23:21:31 -07:00
|
|
|
while (SDL_GetAtomicInt(&ctx->running)) {
|
2023-06-20 01:17:44 -07:00
|
|
|
Uint64 timestamp = SDL_GetTicksNS();
|
2024-05-16 07:52:32 -07:00
|
|
|
|
2024-05-16 07:53:18 -07:00
|
|
|
if (ALooper_pollOnce(-1, NULL, &events, (void **)&source) == LOOPER_ID_USER) {
|
2024-05-16 07:52:32 -07:00
|
|
|
SDL_LockSensors();
|
|
|
|
|
for (i = 0; i < SDL_sensors_count; ++i) {
|
|
|
|
|
if (!SDL_sensors[i].event_queue) {
|
|
|
|
|
continue;
|
2023-06-20 01:17:44 -07:00
|
|
|
}
|
|
|
|
|
|
2024-05-16 07:52:32 -07:00
|
|
|
SDL_zero(event);
|
|
|
|
|
while (ASensorEventQueue_getEvents(SDL_sensors[i].event_queue, &event, 1) > 0) {
|
|
|
|
|
SDL_SendSensorUpdate(timestamp, SDL_sensors[i].sensor, timestamp, event.data, SDL_arraysize(event.data));
|
|
|
|
|
}
|
2023-06-20 01:17:44 -07:00
|
|
|
}
|
2024-05-16 07:52:32 -07:00
|
|
|
SDL_UnlockSensors();
|
2023-06-20 01:17:44 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_sensor_looper = NULL;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void SDL_ANDROID_StopSensorThread(SDL_AndroidSensorThreadContext *ctx)
|
|
|
|
|
{
|
2024-09-16 23:21:31 -07:00
|
|
|
SDL_SetAtomicInt(&ctx->running, false);
|
2023-06-20 01:17:44 -07:00
|
|
|
|
|
|
|
|
if (ctx->thread) {
|
|
|
|
|
int result;
|
|
|
|
|
|
|
|
|
|
if (SDL_sensor_looper) {
|
|
|
|
|
ALooper_wake(SDL_sensor_looper);
|
|
|
|
|
}
|
|
|
|
|
SDL_WaitThread(ctx->thread, &result);
|
|
|
|
|
ctx->thread = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ctx->sem) {
|
|
|
|
|
SDL_DestroySemaphore(ctx->sem);
|
|
|
|
|
ctx->sem = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
static bool SDL_ANDROID_StartSensorThread(SDL_AndroidSensorThreadContext *ctx)
|
2023-06-20 01:17:44 -07:00
|
|
|
{
|
|
|
|
|
ctx->sem = SDL_CreateSemaphore(0);
|
|
|
|
|
if (!ctx->sem) {
|
|
|
|
|
SDL_ANDROID_StopSensorThread(ctx);
|
2024-08-22 17:33:49 -07:00
|
|
|
return false;
|
2023-06-20 01:17:44 -07:00
|
|
|
}
|
|
|
|
|
|
2024-09-16 23:21:31 -07:00
|
|
|
SDL_SetAtomicInt(&ctx->running, true);
|
2024-05-21 01:46:48 -04:00
|
|
|
ctx->thread = SDL_CreateThread(SDL_ANDROID_SensorThread, "Sensors", ctx);
|
2023-06-20 01:17:44 -07:00
|
|
|
if (!ctx->thread) {
|
|
|
|
|
SDL_ANDROID_StopSensorThread(ctx);
|
2024-08-22 17:33:49 -07:00
|
|
|
return false;
|
2023-06-20 01:17:44 -07:00
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Wait for the sensor thread to start
|
2023-06-20 01:17:44 -07:00
|
|
|
SDL_WaitSemaphore(ctx->sem);
|
|
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
return true;
|
2023-06-20 01:17:44 -07:00
|
|
|
}
|
|
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
static bool SDL_ANDROID_SensorInit(void)
|
2018-08-21 12:11:34 -07:00
|
|
|
{
|
|
|
|
|
int i, sensors_count;
|
|
|
|
|
ASensorList sensors;
|
|
|
|
|
|
|
|
|
|
SDL_sensor_manager = ASensorManager_getInstance();
|
2023-11-09 22:29:15 +01:00
|
|
|
if (!SDL_sensor_manager) {
|
2018-08-21 12:11:34 -07:00
|
|
|
return SDL_SetError("Couldn't create sensor manager");
|
|
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// FIXME: Is the sensor list dynamic?
|
2018-08-21 12:11:34 -07:00
|
|
|
sensors_count = ASensorManager_getSensorList(SDL_sensor_manager, &sensors);
|
|
|
|
|
if (sensors_count > 0) {
|
|
|
|
|
SDL_sensors = (SDL_AndroidSensor *)SDL_calloc(sensors_count, sizeof(*SDL_sensors));
|
2023-11-09 22:29:15 +01:00
|
|
|
if (!SDL_sensors) {
|
2024-08-22 17:33:49 -07:00
|
|
|
return false;
|
2018-08-21 12:11:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < sensors_count; ++i) {
|
|
|
|
|
SDL_sensors[i].asensor = sensors[i];
|
2023-10-23 09:46:09 -07:00
|
|
|
SDL_sensors[i].instance_id = SDL_GetNextObjectID();
|
2018-08-21 12:11:34 -07:00
|
|
|
}
|
|
|
|
|
SDL_sensors_count = sensors_count;
|
|
|
|
|
}
|
2023-06-20 01:17:44 -07:00
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
if (!SDL_ANDROID_StartSensorThread(&SDL_sensor_thread_context)) {
|
|
|
|
|
return false;
|
2023-06-20 01:17:44 -07:00
|
|
|
}
|
2024-08-22 17:33:49 -07:00
|
|
|
return true;
|
2018-08-21 12:11:34 -07:00
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
static int SDL_ANDROID_SensorGetCount(void)
|
2018-08-21 12:11:34 -07:00
|
|
|
{
|
|
|
|
|
return SDL_sensors_count;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
static void SDL_ANDROID_SensorDetect(void)
|
2018-08-21 12:11:34 -07:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
static const char *SDL_ANDROID_SensorGetDeviceName(int device_index)
|
2018-08-21 12:11:34 -07:00
|
|
|
{
|
|
|
|
|
return ASensor_getName(SDL_sensors[device_index].asensor);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
static SDL_SensorType SDL_ANDROID_SensorGetDeviceType(int device_index)
|
2018-08-21 12:11:34 -07:00
|
|
|
{
|
|
|
|
|
switch (ASensor_getType(SDL_sensors[device_index].asensor)) {
|
|
|
|
|
case 0x00000001:
|
|
|
|
|
return SDL_SENSOR_ACCEL;
|
|
|
|
|
case 0x00000004:
|
|
|
|
|
return SDL_SENSOR_GYRO;
|
|
|
|
|
default:
|
|
|
|
|
return SDL_SENSOR_UNKNOWN;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
static int SDL_ANDROID_SensorGetDeviceNonPortableType(int device_index)
|
2018-08-21 12:11:34 -07:00
|
|
|
{
|
|
|
|
|
return ASensor_getType(SDL_sensors[device_index].asensor);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
static SDL_SensorID SDL_ANDROID_SensorGetDeviceInstanceID(int device_index)
|
2018-08-21 12:11:34 -07:00
|
|
|
{
|
|
|
|
|
return SDL_sensors[device_index].instance_id;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
static bool SDL_ANDROID_SensorOpen(SDL_Sensor *sensor, int device_index)
|
2018-08-21 12:11:34 -07:00
|
|
|
{
|
2020-03-23 12:10:05 -07:00
|
|
|
int delay_us, min_delay_us;
|
2018-08-21 12:11:34 -07:00
|
|
|
|
2023-08-08 22:08:40 -07:00
|
|
|
SDL_LockSensors();
|
2023-06-20 01:17:44 -07:00
|
|
|
{
|
|
|
|
|
SDL_sensors[device_index].sensor = sensor;
|
|
|
|
|
SDL_sensors[device_index].event_queue = ASensorManager_createEventQueue(SDL_sensor_manager, SDL_sensor_looper, LOOPER_ID_USER, NULL, NULL);
|
|
|
|
|
if (!SDL_sensors[device_index].event_queue) {
|
2023-08-08 22:08:40 -07:00
|
|
|
SDL_UnlockSensors();
|
2023-06-20 01:17:44 -07:00
|
|
|
return SDL_SetError("Couldn't create sensor event queue");
|
|
|
|
|
}
|
2018-08-21 12:11:34 -07:00
|
|
|
|
2023-06-20 01:17:44 -07:00
|
|
|
if (ASensorEventQueue_enableSensor(SDL_sensors[device_index].event_queue, SDL_sensors[device_index].asensor) < 0) {
|
|
|
|
|
ASensorManager_destroyEventQueue(SDL_sensor_manager, SDL_sensors[device_index].event_queue);
|
|
|
|
|
SDL_sensors[device_index].event_queue = NULL;
|
2023-08-08 22:08:40 -07:00
|
|
|
SDL_UnlockSensors();
|
2023-06-20 01:17:44 -07:00
|
|
|
return SDL_SetError("Couldn't enable sensor");
|
|
|
|
|
}
|
2018-08-21 12:11:34 -07:00
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Use 60 Hz update rate if possible
|
|
|
|
|
// FIXME: Maybe add a hint for this?
|
2023-06-20 01:17:44 -07:00
|
|
|
delay_us = 1000000 / 60;
|
|
|
|
|
min_delay_us = ASensor_getMinDelay(SDL_sensors[device_index].asensor);
|
|
|
|
|
if (delay_us < min_delay_us) {
|
|
|
|
|
delay_us = min_delay_us;
|
|
|
|
|
}
|
|
|
|
|
ASensorEventQueue_setEventRate(SDL_sensors[device_index].event_queue, SDL_sensors[device_index].asensor, delay_us);
|
2020-03-23 12:10:05 -07:00
|
|
|
}
|
2023-08-08 22:08:40 -07:00
|
|
|
SDL_UnlockSensors();
|
2018-08-21 12:11:34 -07:00
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
return true;
|
2018-08-21 12:11:34 -07:00
|
|
|
}
|
2022-11-30 12:51:59 -08:00
|
|
|
|
|
|
|
|
static void SDL_ANDROID_SensorUpdate(SDL_Sensor *sensor)
|
2018-08-21 12:11:34 -07:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
static void SDL_ANDROID_SensorClose(SDL_Sensor *sensor)
|
2018-08-21 12:11:34 -07:00
|
|
|
{
|
2023-06-20 01:17:44 -07:00
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < SDL_sensors_count; ++i) {
|
|
|
|
|
if (SDL_sensors[i].sensor == sensor) {
|
2023-08-08 22:08:40 -07:00
|
|
|
SDL_LockSensors();
|
2023-06-20 01:17:44 -07:00
|
|
|
{
|
|
|
|
|
ASensorEventQueue_disableSensor(SDL_sensors[i].event_queue, SDL_sensors[i].asensor);
|
|
|
|
|
ASensorManager_destroyEventQueue(SDL_sensor_manager, SDL_sensors[i].event_queue);
|
|
|
|
|
SDL_sensors[i].event_queue = NULL;
|
|
|
|
|
SDL_sensors[i].sensor = NULL;
|
|
|
|
|
}
|
2023-08-08 22:08:40 -07:00
|
|
|
SDL_UnlockSensors();
|
2023-06-20 01:17:44 -07:00
|
|
|
break;
|
|
|
|
|
}
|
2018-08-21 12:11:34 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
static void SDL_ANDROID_SensorQuit(void)
|
2018-08-21 12:11:34 -07:00
|
|
|
{
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// All sensors are closed, but we need to unblock the sensor thread
|
2023-08-08 23:01:55 -07:00
|
|
|
SDL_AssertSensorsLocked();
|
|
|
|
|
SDL_UnlockSensors();
|
2023-06-20 01:17:44 -07:00
|
|
|
SDL_ANDROID_StopSensorThread(&SDL_sensor_thread_context);
|
2023-08-08 23:01:55 -07:00
|
|
|
SDL_LockSensors();
|
2023-06-20 01:17:44 -07:00
|
|
|
|
2018-08-21 12:11:34 -07:00
|
|
|
if (SDL_sensors) {
|
|
|
|
|
SDL_free(SDL_sensors);
|
|
|
|
|
SDL_sensors = NULL;
|
|
|
|
|
SDL_sensors_count = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
SDL_SensorDriver SDL_ANDROID_SensorDriver = {
|
2018-08-21 12:11:34 -07:00
|
|
|
SDL_ANDROID_SensorInit,
|
|
|
|
|
SDL_ANDROID_SensorGetCount,
|
|
|
|
|
SDL_ANDROID_SensorDetect,
|
|
|
|
|
SDL_ANDROID_SensorGetDeviceName,
|
|
|
|
|
SDL_ANDROID_SensorGetDeviceType,
|
|
|
|
|
SDL_ANDROID_SensorGetDeviceNonPortableType,
|
|
|
|
|
SDL_ANDROID_SensorGetDeviceInstanceID,
|
|
|
|
|
SDL_ANDROID_SensorOpen,
|
|
|
|
|
SDL_ANDROID_SensorUpdate,
|
|
|
|
|
SDL_ANDROID_SensorClose,
|
|
|
|
|
SDL_ANDROID_SensorQuit,
|
|
|
|
|
};
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
#endif // SDL_SENSOR_ANDROID
|