xinput: use the full range of the haptic motors (thanks, Trent!).
authorRyan C. Gordon <icculus@icculus.org>
Wed, 21 Jun 2017 01:22:00 -0400
changeset 11110db5c09aa4fd4
parent 11109 5f33dc4d399e
child 11111 0841489fa4df
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
     1.1 --- a/src/haptic/windows/SDL_xinputhaptic.c	Sun Jun 18 23:00:42 2017 +0200
     1.2 +++ b/src/haptic/windows/SDL_xinputhaptic.c	Wed Jun 21 01:22:00 2017 -0400
     1.3 @@ -278,8 +278,9 @@
     1.4  {
     1.5      XINPUT_VIBRATION *vib = &effect->hweffect->vibration;
     1.6      SDL_assert(data->type == SDL_HAPTIC_LEFTRIGHT);
     1.7 -    vib->wLeftMotorSpeed = data->leftright.large_magnitude;
     1.8 -    vib->wRightMotorSpeed = data->leftright.small_magnitude;
     1.9 +    /* SDL_HapticEffect has max magnitude of 32767, XInput expects 65535 max, so multiply */
    1.10 +    vib->wLeftMotorSpeed = data->leftright.large_magnitude * 2;
    1.11 +    vib->wRightMotorSpeed = data->leftright.small_magnitude * 2;
    1.12      SDL_LockMutex(haptic->hwdata->mutex);
    1.13      if (haptic->hwdata->stopTicks) {  /* running right now? Update it. */
    1.14          XINPUTSETSTATE(haptic->hwdata->userid, vib);