summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/SDL2/src/haptic
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/SDL2/src/haptic')
-rw-r--r--3rdparty/SDL2/src/haptic/linux/SDL_syshaptic.c4
-rw-r--r--3rdparty/SDL2/src/haptic/windows/SDL_dinputhaptic.c19
-rw-r--r--3rdparty/SDL2/src/haptic/windows/SDL_windowshaptic.c2
-rw-r--r--3rdparty/SDL2/src/haptic/windows/SDL_windowshaptic_c.h4
-rw-r--r--3rdparty/SDL2/src/haptic/windows/SDL_xinputhaptic.c19
5 files changed, 20 insertions, 28 deletions
diff --git a/3rdparty/SDL2/src/haptic/linux/SDL_syshaptic.c b/3rdparty/SDL2/src/haptic/linux/SDL_syshaptic.c
index e8d78553541..7bd96644940 100644
--- a/3rdparty/SDL2/src/haptic/linux/SDL_syshaptic.c
+++ b/3rdparty/SDL2/src/haptic/linux/SDL_syshaptic.c
@@ -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)
diff --git a/3rdparty/SDL2/src/haptic/windows/SDL_dinputhaptic.c b/3rdparty/SDL2/src/haptic/windows/SDL_dinputhaptic.c
index c51470dd5a3..c81432c26e6 100644
--- a/3rdparty/SDL2/src/haptic/windows/SDL_dinputhaptic.c
+++ b/3rdparty/SDL2/src/haptic/windows/SDL_dinputhaptic.c
@@ -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);
diff --git a/3rdparty/SDL2/src/haptic/windows/SDL_windowshaptic.c b/3rdparty/SDL2/src/haptic/windows/SDL_windowshaptic.c
index 0c038fb1b97..c6bcba1f31e 100644
--- a/3rdparty/SDL2/src/haptic/windows/SDL_windowshaptic.c
+++ b/3rdparty/SDL2/src/haptic/windows/SDL_windowshaptic.c
@@ -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;
}
diff --git a/3rdparty/SDL2/src/haptic/windows/SDL_windowshaptic_c.h b/3rdparty/SDL2/src/haptic/windows/SDL_windowshaptic_c.h
index 89fdd2cb9cf..f344264420f 100644
--- a/3rdparty/SDL2/src/haptic/windows/SDL_windowshaptic_c.h
+++ b/3rdparty/SDL2/src/haptic/windows/SDL_windowshaptic_c.h
@@ -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;
};
diff --git a/3rdparty/SDL2/src/haptic/windows/SDL_xinputhaptic.c b/3rdparty/SDL2/src/haptic/windows/SDL_xinputhaptic.c
index a46ae5f97d1..afbab456a0d 100644
--- a/3rdparty/SDL2/src/haptic/windows/SDL_xinputhaptic.c
+++ b/3rdparty/SDL2/src/haptic/windows/SDL_xinputhaptic.c
@@ -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);
}