I’m resending this here as it was recently posted to the old mailing list. Apologies as I can’t upload the patch as a new user.
I recently tried the haptics support on a couple joysticks. One worked seemingly fine (an Xbox 360 pad) while the other (Logitech F710) I can barely detect a rumble using the basic rumble support (SDL_RumbleInit etc.) I dug through the code a little and found that although SDL_HapticEffect has a max magnitude of 32767, XInput expects max to be 65535[1]. I attached a patch. I’m not certain it’s completely correct as I didn’t quite understand what “180 degree phase shift” for negative magnitudes means, but with positive values this makes my gamepad move.
diff -r 10552ae634ca src/haptic/windows/SDL_xinputhaptic.c
— a/src/haptic/windows/SDL_xinputhaptic.c Fri May 26 22:45:52 2017 +0200
+++ b/src/haptic/windows/SDL_xinputhaptic.c Fri May 26 22:32:57 2017 -0600
@@ -278,8 +278,9 @@
{
XINPUT_VIBRATION *vib = &effect->hweffect->vibration;
SDL_assert(data->type == SDL_HAPTIC_LEFTRIGHT);
- vib->wLeftMotorSpeed = data->leftright.large_magnitude;
- vib->wRightMotorSpeed = data->leftright.small_magnitude;
- /* SDL_HapticEffect has max magnitude of 32767, XInput expects 65535 max, so multiply */
- vib->wLeftMotorSpeed = data->leftright.large_magnitude * 2;
- vib->wRightMotorSpeed = data->leftright.small_magnitude * 2;
SDL_LockMutex(haptic->hwdata->mutex);
if (haptic->hwdata->stopTicks) { /* running right now? Update it. */
XINPUTSETSTATE(haptic->hwdata->userid, vib);