summaryrefslogtreecommitdiff
path: root/Source/3rdParty/SDL2/src/haptic
diff options
context:
space:
mode:
Diffstat (limited to 'Source/3rdParty/SDL2/src/haptic')
-rw-r--r--Source/3rdParty/SDL2/src/haptic/SDL_haptic.c7
-rw-r--r--Source/3rdParty/SDL2/src/haptic/SDL_haptic_c.h5
-rw-r--r--Source/3rdParty/SDL2/src/haptic/android/SDL_syshaptic.c13
-rw-r--r--Source/3rdParty/SDL2/src/haptic/linux/SDL_syshaptic.c12
-rw-r--r--Source/3rdParty/SDL2/src/haptic/windows/SDL_windowshaptic.c15
5 files changed, 41 insertions, 11 deletions
diff --git a/Source/3rdParty/SDL2/src/haptic/SDL_haptic.c b/Source/3rdParty/SDL2/src/haptic/SDL_haptic.c
index 4988c30..f23ba18 100644
--- a/Source/3rdParty/SDL2/src/haptic/SDL_haptic.c
+++ b/Source/3rdParty/SDL2/src/haptic/SDL_haptic.c
@@ -389,9 +389,11 @@ SDL_HapticClose(SDL_Haptic * haptic)
void
SDL_HapticQuit(void)
{
+ while (SDL_haptics) {
+ SDL_HapticClose(SDL_haptics);
+ }
+
SDL_SYS_HapticQuit();
- SDL_assert(SDL_haptics == NULL);
- SDL_haptics = NULL;
}
/*
@@ -765,6 +767,7 @@ SDL_HapticRumbleInit(SDL_Haptic * haptic)
SDL_zerop(efx);
if (haptic->supported & SDL_HAPTIC_SINE) {
efx->type = SDL_HAPTIC_SINE;
+ efx->periodic.direction.type = SDL_HAPTIC_CARTESIAN;
efx->periodic.period = 1000;
efx->periodic.magnitude = 0x4000;
efx->periodic.length = 5000;
diff --git a/Source/3rdParty/SDL2/src/haptic/SDL_haptic_c.h b/Source/3rdParty/SDL2/src/haptic/SDL_haptic_c.h
index 26d900d..390dc78 100644
--- a/Source/3rdParty/SDL2/src/haptic/SDL_haptic_c.h
+++ b/Source/3rdParty/SDL2/src/haptic/SDL_haptic_c.h
@@ -19,7 +19,12 @@
3. This notice may not be removed or altered from any source distribution.
*/
+#ifndef SDL_haptic_c_h_
+#define SDL_haptic_c_h_
+
extern int SDL_HapticInit(void);
extern void SDL_HapticQuit(void);
+#endif /* SDL_haptic_c_h_ */
+
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/Source/3rdParty/SDL2/src/haptic/android/SDL_syshaptic.c b/Source/3rdParty/SDL2/src/haptic/android/SDL_syshaptic.c
index 1fb2352..7cb289b 100644
--- a/Source/3rdParty/SDL2/src/haptic/android/SDL_syshaptic.c
+++ b/Source/3rdParty/SDL2/src/haptic/android/SDL_syshaptic.c
@@ -195,6 +195,10 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic)
void
SDL_SYS_HapticQuit(void)
{
+/* We don't have any way to scan for joysticks (and their vibrators) at init, so don't wipe the list
+ * of joysticks here in case this is a reinit.
+ */
+#if 0
SDL_hapticlist_item *item = NULL;
SDL_hapticlist_item *next = NULL;
@@ -206,6 +210,7 @@ SDL_SYS_HapticQuit(void)
SDL_hapticlist = SDL_hapticlist_tail = NULL;
numhaptics = 0;
return;
+#endif
}
@@ -230,7 +235,12 @@ int
SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
Uint32 iterations)
{
- Android_JNI_HapticRun (((SDL_hapticlist_item *)haptic->hwdata)->device_id, effect->effect.leftright.length);
+ float large = effect->effect.leftright.large_magnitude / 32767.0f;
+ float small = effect->effect.leftright.small_magnitude / 32767.0f;
+
+ float total = (large * 0.6f) + (small * 0.4f);
+
+ Android_JNI_HapticRun (((SDL_hapticlist_item *)haptic->hwdata)->device_id, total, effect->effect.leftright.length);
return 0;
}
@@ -238,6 +248,7 @@ SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
int
SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
{
+ Android_JNI_HapticStop (((SDL_hapticlist_item *)haptic->hwdata)->device_id);
return 0;
}
diff --git a/Source/3rdParty/SDL2/src/haptic/linux/SDL_syshaptic.c b/Source/3rdParty/SDL2/src/haptic/linux/SDL_syshaptic.c
index 9c11a2f..4e4f8a5 100644
--- a/Source/3rdParty/SDL2/src/haptic/linux/SDL_syshaptic.c
+++ b/Source/3rdParty/SDL2/src/haptic/linux/SDL_syshaptic.c
@@ -181,6 +181,9 @@ SDL_SYS_HapticInit(void)
SDL_UDEV_Quit();
return SDL_SetError("Could not setup haptic <-> udev callback");
}
+
+ /* Force a scan to build the initial device list */
+ SDL_UDEV_Scan();
#endif /* SDL_USE_LIBUDEV */
return numhaptics;
@@ -798,7 +801,8 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src)
else if (periodic->type == SDL_HAPTIC_SAWTOOTHDOWN)
dest->u.periodic.waveform = FF_SAW_DOWN;
dest->u.periodic.period = CLAMP(periodic->period);
- dest->u.periodic.magnitude = periodic->magnitude;
+ /* Linux expects 0-65535, so multiply by 2 */
+ dest->u.periodic.magnitude = CLAMP(periodic->magnitude) * 2;
dest->u.periodic.offset = periodic->offset;
/* Linux phase is defined in interval "[0x0000, 0x10000[", corresponds with "[0deg, 360deg[" phase shift. */
dest->u.periodic.phase = ((Uint32)periodic->phase * 0x10000U) / 36000;
@@ -905,9 +909,9 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src)
dest->trigger.button = 0;
dest->trigger.interval = 0;
- /* Rumble */
- dest->u.rumble.strong_magnitude = leftright->large_magnitude;
- dest->u.rumble.weak_magnitude = leftright->small_magnitude;
+ /* Rumble (Linux expects 0-65535, so multiply by 2) */
+ dest->u.rumble.strong_magnitude = CLAMP(leftright->large_magnitude) * 2;
+ dest->u.rumble.weak_magnitude = CLAMP(leftright->small_magnitude) * 2;
break;
diff --git a/Source/3rdParty/SDL2/src/haptic/windows/SDL_windowshaptic.c b/Source/3rdParty/SDL2/src/haptic/windows/SDL_windowshaptic.c
index 3d7361d..2e806c9 100644
--- a/Source/3rdParty/SDL2/src/haptic/windows/SDL_windowshaptic.c
+++ b/Source/3rdParty/SDL2/src/haptic/windows/SDL_windowshaptic.c
@@ -157,7 +157,7 @@ SDL_SYS_HapticMouse(void)
/* Grab the first mouse haptic device we find. */
for (item = SDL_hapticlist; item != NULL; item = item->next) {
- if (item->capabilities.dwDevType == DI8DEVCLASS_POINTER ) {
+ if (item->capabilities.dwDevType == DI8DEVCLASS_POINTER) {
return index;
}
++index;
@@ -173,14 +173,16 @@ SDL_SYS_HapticMouse(void)
int
SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
{
- const struct joystick_hwdata *hwdata = joystick->hwdata;
+ if (joystick->driver != &SDL_WINDOWS_JoystickDriver) {
+ return 0;
+ }
#if SDL_HAPTIC_XINPUT
- if (hwdata->bXInputHaptic) {
+ if (joystick->hwdata->bXInputHaptic) {
return 1;
}
#endif
#if SDL_HAPTIC_DINPUT
- if (hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) {
+ if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) {
return 1;
}
#endif
@@ -193,6 +195,9 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
int
SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
{
+ if (joystick->driver != &SDL_WINDOWS_JoystickDriver) {
+ return 0;
+ }
if (joystick->hwdata->bXInputHaptic != haptic->hwdata->bXInputHaptic) {
return 0; /* one is XInput, one is not; not the same device. */
} else if (joystick->hwdata->bXInputHaptic) {
@@ -208,6 +213,8 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
int
SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
{
+ SDL_assert(joystick->driver == &SDL_WINDOWS_JoystickDriver);
+
if (joystick->hwdata->bXInputDevice) {
return SDL_XINPUT_HapticOpenFromJoystick(haptic, joystick);
} else {