mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
update sdl to https://github.com/libsdl-org/SDL 22March 2022
This commit is contained in:
parent
ee4253c982
commit
2614274639
1225 changed files with 148950 additions and 51674 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -39,11 +39,14 @@ static SDL_SensorDriver *SDL_sensor_drivers[] = {
|
|||
&SDL_COREMOTION_SensorDriver,
|
||||
#endif
|
||||
#ifdef SDL_SENSOR_WINDOWS
|
||||
&SDL_WINDOWS_SensorDriver,
|
||||
&SDL_WINDOWS_SensorDriver,
|
||||
#endif
|
||||
#if defined(SDL_SENSOR_DUMMY) || defined(SDL_SENSOR_DISABLED)
|
||||
&SDL_DUMMY_SensorDriver
|
||||
#endif
|
||||
#if defined(SDL_SENSOR_VITA)
|
||||
&SDL_VITA_SensorDriver
|
||||
#endif
|
||||
};
|
||||
static SDL_Sensor *SDL_sensors = NULL;
|
||||
static SDL_bool SDL_updating_sensor = SDL_FALSE;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -100,6 +100,7 @@ extern SDL_SensorDriver SDL_ANDROID_SensorDriver;
|
|||
extern SDL_SensorDriver SDL_COREMOTION_SensorDriver;
|
||||
extern SDL_SensorDriver SDL_WINDOWS_SensorDriver;
|
||||
extern SDL_SensorDriver SDL_DUMMY_SensorDriver;
|
||||
extern SDL_SensorDriver SDL_VITA_SensorDriver;
|
||||
|
||||
#endif /* SDL_syssensor_h_ */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
219
Engine/lib/sdl/src/sensor/vita/SDL_vitasensor.c
Normal file
219
Engine/lib/sdl/src/sensor/vita/SDL_vitasensor.c
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "SDL_config.h"
|
||||
|
||||
#if defined(SDL_SENSOR_VITA)
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_sensor.h"
|
||||
#include "SDL_vitasensor.h"
|
||||
#include "../SDL_syssensor.h"
|
||||
#include <psp2/motion.h>
|
||||
|
||||
#if !defined(SCE_MOTION_MAX_NUM_STATES)
|
||||
#define SCE_MOTION_MAX_NUM_STATES 64
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SDL_SensorType type;
|
||||
SDL_SensorID instance_id;
|
||||
} SDL_VitaSensor;
|
||||
|
||||
static SDL_VitaSensor *SDL_sensors;
|
||||
static int SDL_sensors_count;
|
||||
|
||||
static int
|
||||
SDL_VITA_SensorInit(void)
|
||||
{
|
||||
sceMotionReset();
|
||||
sceMotionStartSampling();
|
||||
// not sure if these are needed, we are reading unfiltered state
|
||||
sceMotionSetAngleThreshold(0);
|
||||
sceMotionSetDeadband(SCE_FALSE);
|
||||
sceMotionSetTiltCorrection(SCE_FALSE);
|
||||
|
||||
SDL_sensors_count = 2;
|
||||
|
||||
SDL_sensors = (SDL_VitaSensor *)SDL_calloc(SDL_sensors_count, sizeof(*SDL_sensors));
|
||||
if (!SDL_sensors) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
SDL_sensors[0].type = SDL_SENSOR_ACCEL;
|
||||
SDL_sensors[0].instance_id = SDL_GetNextSensorInstanceID();
|
||||
SDL_sensors[1].type = SDL_SENSOR_GYRO;
|
||||
SDL_sensors[1].instance_id = SDL_GetNextSensorInstanceID();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_VITA_SensorGetCount(void)
|
||||
{
|
||||
return SDL_sensors_count;
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_VITA_SensorDetect(void)
|
||||
{
|
||||
}
|
||||
|
||||
static const char *
|
||||
SDL_VITA_SensorGetDeviceName(int device_index)
|
||||
{
|
||||
if (device_index < SDL_sensors_count) {
|
||||
switch (SDL_sensors[device_index].type) {
|
||||
case SDL_SENSOR_ACCEL:
|
||||
return "Accelerometer";
|
||||
case SDL_SENSOR_GYRO:
|
||||
return "Gyro";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static SDL_SensorType
|
||||
SDL_VITA_SensorGetDeviceType(int device_index)
|
||||
{
|
||||
if (device_index < SDL_sensors_count) {
|
||||
return SDL_sensors[device_index].type;
|
||||
}
|
||||
|
||||
return SDL_SENSOR_INVALID;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_VITA_SensorGetDeviceNonPortableType(int device_index)
|
||||
{
|
||||
if (device_index < SDL_sensors_count) {
|
||||
return SDL_sensors[device_index].type;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static SDL_SensorID
|
||||
SDL_VITA_SensorGetDeviceInstanceID(int device_index)
|
||||
{
|
||||
if (device_index < SDL_sensors_count) {
|
||||
return SDL_sensors[device_index].instance_id;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_VITA_SensorOpen(SDL_Sensor *sensor, int device_index)
|
||||
{
|
||||
struct sensor_hwdata *hwdata;
|
||||
|
||||
hwdata = (struct sensor_hwdata *)SDL_calloc(1, sizeof(*hwdata));
|
||||
if (hwdata == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
sensor->hwdata = hwdata;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_VITA_SensorUpdate(SDL_Sensor *sensor)
|
||||
{
|
||||
int err = 0;
|
||||
SceMotionSensorState motionState[SCE_MOTION_MAX_NUM_STATES];
|
||||
SDL_memset(motionState, 0, sizeof(motionState));
|
||||
|
||||
err = sceMotionGetSensorState(motionState, SCE_MOTION_MAX_NUM_STATES);
|
||||
if (err != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < SCE_MOTION_MAX_NUM_STATES; i++)
|
||||
{
|
||||
if (sensor->hwdata->counter < motionState[i].counter)
|
||||
{
|
||||
sensor->hwdata->counter = motionState[i].counter;
|
||||
switch (sensor->type)
|
||||
{
|
||||
case SDL_SENSOR_ACCEL:
|
||||
{
|
||||
float data[3];
|
||||
data[0] = motionState[i].accelerometer.x * SDL_STANDARD_GRAVITY;
|
||||
data[1] = motionState[i].accelerometer.y * SDL_STANDARD_GRAVITY;
|
||||
data[2] = motionState[i].accelerometer.z * SDL_STANDARD_GRAVITY;
|
||||
if (SDL_memcmp(data, sensor->hwdata->data, sizeof(data)) != 0) {
|
||||
SDL_PrivateSensorUpdate(sensor, data, SDL_arraysize(data));
|
||||
SDL_memcpy(sensor->hwdata->data, data, sizeof(data));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_SENSOR_GYRO:
|
||||
{
|
||||
float data[3];
|
||||
data[0] = motionState[i].gyro.x;
|
||||
data[1] = motionState[i].gyro.y;
|
||||
data[2] = motionState[i].gyro.z;
|
||||
if (SDL_memcmp(data, sensor->hwdata->data, sizeof(data)) != 0) {
|
||||
SDL_PrivateSensorUpdate(sensor, data, SDL_arraysize(data));
|
||||
SDL_memcpy(sensor->hwdata->data, data, sizeof(data));
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_VITA_SensorClose(SDL_Sensor *sensor)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_VITA_SensorQuit(void)
|
||||
{
|
||||
sceMotionStopSampling();
|
||||
}
|
||||
|
||||
SDL_SensorDriver SDL_VITA_SensorDriver =
|
||||
{
|
||||
SDL_VITA_SensorInit,
|
||||
SDL_VITA_SensorGetCount,
|
||||
SDL_VITA_SensorDetect,
|
||||
SDL_VITA_SensorGetDeviceName,
|
||||
SDL_VITA_SensorGetDeviceType,
|
||||
SDL_VITA_SensorGetDeviceNonPortableType,
|
||||
SDL_VITA_SensorGetDeviceInstanceID,
|
||||
SDL_VITA_SensorOpen,
|
||||
SDL_VITA_SensorUpdate,
|
||||
SDL_VITA_SensorClose,
|
||||
SDL_VITA_SensorQuit,
|
||||
};
|
||||
|
||||
#endif /* SDL_SENSOR_VITA */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
30
Engine/lib/sdl/src/sensor/vita/SDL_vitasensor.h
Normal file
30
Engine/lib/sdl/src/sensor/vita/SDL_vitasensor.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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.
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* The private structure used to keep track of a sensor */
|
||||
struct sensor_hwdata
|
||||
{
|
||||
float data[3];
|
||||
Uint32 counter;
|
||||
};
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -279,7 +279,7 @@ static int ConnectSensor(ISensor *sensor)
|
|||
|
||||
hr = ISensor_GetFriendlyName(sensor, &bstr_name);
|
||||
if (SUCCEEDED(hr) && bstr_name) {
|
||||
name = WIN_StringToUTF8(bstr_name);
|
||||
name = WIN_StringToUTF8W(bstr_name);
|
||||
} else {
|
||||
name = SDL_strdup("Unknown Sensor");
|
||||
}
|
||||
|
|
@ -294,6 +294,7 @@ static int ConnectSensor(ISensor *sensor)
|
|||
new_sensors = (SDL_Windows_Sensor *)SDL_realloc(SDL_sensors, (SDL_num_sensors + 1) * sizeof(SDL_Windows_Sensor));
|
||||
if (new_sensors == NULL) {
|
||||
SDL_UnlockSensors();
|
||||
SDL_free(name);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
|
|
@ -324,7 +325,10 @@ static int DisconnectSensor(ISensor *sensor)
|
|||
for (i = 0; i < SDL_num_sensors; ++i) {
|
||||
old_sensor = &SDL_sensors[i];
|
||||
if (sensor == old_sensor->sensor) {
|
||||
ISensor_SetEventSink(sensor, NULL);
|
||||
/* This call hangs for some reason:
|
||||
* https://github.com/libsdl-org/SDL/issues/5288
|
||||
*/
|
||||
/*ISensor_SetEventSink(sensor, NULL);*/
|
||||
ISensor_Release(sensor);
|
||||
SDL_free(old_sensor->name);
|
||||
--SDL_num_sensors;
|
||||
|
|
@ -351,12 +355,14 @@ SDL_WINDOWS_SensorInit(void)
|
|||
|
||||
hr = CoCreateInstance(&SDL_CLSID_SensorManager, NULL, CLSCTX_INPROC_SERVER, &SDL_IID_SensorManager, (LPVOID *) &SDL_sensor_manager);
|
||||
if (FAILED(hr)) {
|
||||
return WIN_SetErrorFromHRESULT("Couldn't create the sensor manager", hr);
|
||||
/* If we can't create a sensor manager (i.e. on Wine), we won't have any sensors, but don't fail the init */
|
||||
return 0; /* WIN_SetErrorFromHRESULT("Couldn't create the sensor manager", hr); */
|
||||
}
|
||||
|
||||
hr = ISensorManager_SetEventSink(SDL_sensor_manager, &sensor_manager_events);
|
||||
if (FAILED(hr)) {
|
||||
ISensorManager_Release(SDL_sensor_manager);
|
||||
SDL_sensor_manager = NULL;
|
||||
return WIN_SetErrorFromHRESULT("Couldn't set the sensor manager event sink", hr);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue