mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
Updates SDL to 2.0.5
This commit is contained in:
parent
00a4a21e3f
commit
1e671bfc7a
274 changed files with 11502 additions and 4656 deletions
|
|
@ -609,7 +609,7 @@ SDL_SYS_HapticQuit(void)
|
|||
/* Opened and not closed haptics are leaked, this is on purpose.
|
||||
* Close your haptic devices after usage. */
|
||||
SDL_free(item->fname);
|
||||
item->fname = NULL;
|
||||
SDL_free(item);
|
||||
}
|
||||
|
||||
#if SDL_USE_LIBUDEV
|
||||
|
|
@ -690,7 +690,7 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src)
|
|||
else if (!src->dir[0])
|
||||
*dest = (src->dir[1] >= 0 ? 0x8000 : 0);
|
||||
else {
|
||||
float f = atan2(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */
|
||||
float f = SDL_atan2(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */
|
||||
/*
|
||||
atan2 takes the parameters: Y-axis-value and X-axis-value (in that order)
|
||||
- Y-axis-value is the second coordinate (from center to SOUTH)
|
||||
|
|
|
|||
|
|
@ -325,20 +325,12 @@ SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic * haptic, LPDIRECTINPUTDEVICE8 device
|
|||
|
||||
/* Set data format. */
|
||||
ret = IDirectInputDevice8_SetDataFormat(haptic->hwdata->device,
|
||||
&c_dfDIJoystick2);
|
||||
&SDL_c_dfDIJoystick2);
|
||||
if (FAILED(ret)) {
|
||||
DI_SetError("Setting data format", ret);
|
||||
goto acquire_err;
|
||||
}
|
||||
|
||||
/* Get number of axes. */
|
||||
ret = IDirectInputDevice8_EnumObjects(haptic->hwdata->device,
|
||||
DI_DeviceObjectCallback,
|
||||
haptic, DIDFT_AXIS);
|
||||
if (FAILED(ret)) {
|
||||
DI_SetError("Getting device axes", ret);
|
||||
goto acquire_err;
|
||||
}
|
||||
|
||||
/* Acquire the device. */
|
||||
ret = IDirectInputDevice8_Acquire(haptic->hwdata->device);
|
||||
|
|
@ -348,6 +340,15 @@ SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic * haptic, LPDIRECTINPUTDEVICE8 device
|
|||
}
|
||||
}
|
||||
|
||||
/* Get number of axes. */
|
||||
ret = IDirectInputDevice8_EnumObjects(haptic->hwdata->device,
|
||||
DI_DeviceObjectCallback,
|
||||
haptic, DIDFT_AXIS);
|
||||
if (FAILED(ret)) {
|
||||
DI_SetError("Getting device axes", ret);
|
||||
goto acquire_err;
|
||||
}
|
||||
|
||||
/* Reset all actuators - just in case. */
|
||||
ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device,
|
||||
DISFFC_RESET);
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ SDL_SYS_HapticQuit(void)
|
|||
for (hapticitem = SDL_haptics; hapticitem; hapticitem = hapticitem->next) {
|
||||
if ((hapticitem->hwdata->bXInputHaptic) && (hapticitem->hwdata->thread)) {
|
||||
/* we _have_ to stop the thread before we free the XInput DLL! */
|
||||
hapticitem->hwdata->stopThread = 1;
|
||||
SDL_AtomicSet(&hapticitem->hwdata->stopThread, 1);
|
||||
SDL_WaitThread(hapticitem->hwdata->thread, NULL);
|
||||
hapticitem->hwdata->thread = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ struct haptic_hwdata
|
|||
Uint8 userid; /* XInput userid index for this joystick */
|
||||
SDL_Thread *thread;
|
||||
SDL_mutex *mutex;
|
||||
volatile Uint32 stopTicks;
|
||||
volatile int stopThread;
|
||||
Uint32 stopTicks;
|
||||
SDL_atomic_t stopThread;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include "SDL_xinputhaptic_c.h"
|
||||
#include "../../core/windows/SDL_xinput.h"
|
||||
#include "../../joystick/windows/SDL_windowsjoystick_c.h"
|
||||
#include "../../thread/SDL_systhread.h"
|
||||
|
||||
/*
|
||||
* Internal stuff.
|
||||
|
|
@ -43,8 +44,7 @@ static SDL_bool loaded_xinput = SDL_FALSE;
|
|||
int
|
||||
SDL_XINPUT_HapticInit(void)
|
||||
{
|
||||
const char *env = SDL_GetHint(SDL_HINT_XINPUT_ENABLED);
|
||||
if (!env || SDL_atoi(env)) {
|
||||
if (SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE)) {
|
||||
loaded_xinput = (WIN_LoadXInputDLL() == 0);
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ SDL_RunXInputHaptic(void *arg)
|
|||
{
|
||||
struct haptic_hwdata *hwdata = (struct haptic_hwdata *) arg;
|
||||
|
||||
while (!hwdata->stopThread) {
|
||||
while (!SDL_AtomicGet(&hwdata->stopThread)) {
|
||||
SDL_Delay(50);
|
||||
SDL_LockMutex(hwdata->mutex);
|
||||
/* If we're currently running and need to stop... */
|
||||
|
|
@ -205,17 +205,8 @@ SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 userid)
|
|||
}
|
||||
|
||||
SDL_snprintf(threadName, sizeof(threadName), "SDLXInputDev%d", (int)userid);
|
||||
haptic->hwdata->thread = SDL_CreateThreadInternal(SDL_RunXInputHaptic, threadName, 64 * 1024, haptic->hwdata);
|
||||
|
||||
#if defined(__WIN32__) && !defined(HAVE_LIBC) /* !!! FIXME: this is nasty. */
|
||||
#undef SDL_CreateThread
|
||||
#if SDL_DYNAMIC_API
|
||||
haptic->hwdata->thread = SDL_CreateThread_REAL(SDL_RunXInputHaptic, threadName, haptic->hwdata, NULL, NULL);
|
||||
#else
|
||||
haptic->hwdata->thread = SDL_CreateThread(SDL_RunXInputHaptic, threadName, haptic->hwdata, NULL, NULL);
|
||||
#endif
|
||||
#else
|
||||
haptic->hwdata->thread = SDL_CreateThread(SDL_RunXInputHaptic, threadName, haptic->hwdata);
|
||||
#endif
|
||||
if (haptic->hwdata->thread == NULL) {
|
||||
SDL_DestroyMutex(haptic->hwdata->mutex);
|
||||
SDL_free(haptic->effects);
|
||||
|
|
@ -261,7 +252,7 @@ SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
|||
void
|
||||
SDL_XINPUT_HapticClose(SDL_Haptic * haptic)
|
||||
{
|
||||
haptic->hwdata->stopThread = 1;
|
||||
SDL_AtomicSet(&haptic->hwdata->stopThread, 1);
|
||||
SDL_WaitThread(haptic->hwdata->thread, NULL);
|
||||
SDL_DestroyMutex(haptic->hwdata->mutex);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue