From d96419c93ff66ce3a09294b1390d02f12e721af1 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 21 Jun 2017 01:22:00 -0400 Subject: [PATCH] xinput: use the full range of the haptic motors (thanks, Trent!). XInput goes from 0 to 64k; we were feeding it values in the range of 0 to 32k. Fixes Bugzilla #3002. --- src/haptic/windows/SDL_xinputhaptic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/haptic/windows/SDL_xinputhaptic.c b/src/haptic/windows/SDL_xinputhaptic.c index 6832f7e6c3c19..419a84ce92a57 100644 --- a/src/haptic/windows/SDL_xinputhaptic.c +++ b/src/haptic/windows/SDL_xinputhaptic.c @@ -278,8 +278,9 @@ SDL_XINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, { 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);