Skip to content

Commit e5ecc39

Browse files
committed
Fix weak and strong joy vibration being swapped
1 parent ba0da90 commit e5ecc39

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/sdl/joypad_sdl.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,19 @@ void JoypadSDL::process_events() {
122122
SDL_Joystick *sdl_joy = SDL_GetJoystickFromID(joypads[i].sdl_instance_idx);
123123
Vector2 strength = Input::get_singleton()->get_joy_vibration_strength(i);
124124

125-
// If the vibration was requested to start, SDL_RumbleJoystick will start it.
126-
// If the vibration was requested to stop, strength and duration will be 0, so SDL will stop the rumble.
125+
/*
126+
If the vibration was requested to start, SDL_RumbleJoystick will start it.
127+
If the vibration was requested to stop, strength and duration will be 0, so SDL will stop the rumble.
128+
129+
Here strength.y goes first and then strength.x, because Input.get_joy_vibration_strength().x
130+
is vibration's weak magnitude (high frequency rumble), and .y is strong magnitude (low frequency rumble),
131+
SDL_RumbleJoystick takes low frequency rumble first and then high frequency rumble.
132+
*/
127133
SDL_RumbleJoystick(
128134
sdl_joy,
129135
// Rumble strength goes from 0 to 0xFFFF
130-
strength.x * UINT16_MAX,
131136
strength.y * UINT16_MAX,
137+
strength.x * UINT16_MAX,
132138
Input::get_singleton()->get_joy_vibration_duration(i) * 1000);
133139
}
134140
}

0 commit comments

Comments
 (0)