Fixed updating the rumble parameters on Linux
authorSam Lantinga <slouken@libsdl.org>
Tue, 16 Oct 2018 14:58:07 -0700
changeset 12333898f03b00670
parent 12332 c80f702e4b8b
child 12334 0789a425e8d7
Fixed updating the rumble parameters on Linux
src/joystick/linux/SDL_sysjoystick.c
     1.1 --- a/src/joystick/linux/SDL_sysjoystick.c	Tue Oct 16 08:29:27 2018 -0700
     1.2 +++ b/src/joystick/linux/SDL_sysjoystick.c	Tue Oct 16 14:58:07 2018 -0700
     1.3 @@ -814,26 +814,24 @@
     1.4  {
     1.5      struct input_event event;
     1.6  
     1.7 -    if (joystick->hwdata->effect.id < 0) {
     1.8 -        if (joystick->hwdata->ff_rumble) {
     1.9 -            struct ff_effect *effect = &joystick->hwdata->effect;
    1.10 +    if (joystick->hwdata->ff_rumble) {
    1.11 +        struct ff_effect *effect = &joystick->hwdata->effect;
    1.12  
    1.13 -            effect->type = FF_RUMBLE;
    1.14 -            effect->replay.length = SDL_min(duration_ms, 32767);
    1.15 -            effect->u.rumble.strong_magnitude = low_frequency_rumble;
    1.16 -            effect->u.rumble.weak_magnitude = high_frequency_rumble;
    1.17 -        } else if (joystick->hwdata->ff_sine) {
    1.18 -            /* Scale and average the two rumble strengths */
    1.19 -            Sint16 magnitude = (Sint16)(((low_frequency_rumble / 2) + (high_frequency_rumble / 2)) / 2);
    1.20 -            struct ff_effect *effect = &joystick->hwdata->effect;
    1.21 +        effect->type = FF_RUMBLE;
    1.22 +        effect->replay.length = SDL_min(duration_ms, 32767);
    1.23 +        effect->u.rumble.strong_magnitude = low_frequency_rumble;
    1.24 +        effect->u.rumble.weak_magnitude = high_frequency_rumble;
    1.25 +    } else if (joystick->hwdata->ff_sine) {
    1.26 +        /* Scale and average the two rumble strengths */
    1.27 +        Sint16 magnitude = (Sint16)(((low_frequency_rumble / 2) + (high_frequency_rumble / 2)) / 2);
    1.28 +        struct ff_effect *effect = &joystick->hwdata->effect;
    1.29  
    1.30 -            effect->type = FF_PERIODIC;
    1.31 -            effect->replay.length = SDL_min(duration_ms, 32767);
    1.32 -            effect->u.periodic.waveform = FF_SINE;
    1.33 -            effect->u.periodic.magnitude = magnitude;
    1.34 -        } else {
    1.35 -            return SDL_Unsupported();
    1.36 -        }
    1.37 +        effect->type = FF_PERIODIC;
    1.38 +        effect->replay.length = SDL_min(duration_ms, 32767);
    1.39 +        effect->u.periodic.waveform = FF_SINE;
    1.40 +        effect->u.periodic.magnitude = magnitude;
    1.41 +    } else {
    1.42 +        return SDL_Unsupported();
    1.43      }
    1.44  
    1.45      if (ioctl(joystick->hwdata->fd, EVIOCSFF, &joystick->hwdata->effect) < 0) {