Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gamepad rumble support with SDL2 #3819

Merged
merged 5 commits into from
Feb 24, 2024
Merged

Gamepad rumble support with SDL2 #3819

merged 5 commits into from
Feb 24, 2024

Conversation

GideonSerf
Copy link
Contributor

As discussed in issue #3815, I added a function SetGamepadVibration(int gamepad, float leftMotor, float rightMotor). I also added a new define, MAX_GAMEPAD_VIBRATION_TIME 2.0f to control the maximum duration of the vibration. When the user sends SetGamepadVibration(gamepad, float 0.0f, float 0.0f), it cancels the vibration. Otherwise it continues on for MAX_GAMEPAD_VIBRATION_TIME.

It seems to work well on my end with an 8BitDo Pro 2 controller set both to Nintendo Switch Pro and Xbox One modes. Perhaps the max time could be changed to something else, but 2 seconds seem to be fine.

Currently the function is set as not returning a value, the SDL function returns -1 if rumble isn't supported on the controller. Should something like that be returned from the SetGamepadVibration function as well?

Gideon Serfontein and others added 5 commits February 23, 2024 16:13
Still need to add to the rest of the platforms.
The rumble in SDL2 will continue for MAX_GAMEPAD_VIBRATION_TIME unless the user cancels it with a call to SetGamepadVibration(0.0f,0.0f,0.0f)
@raysan5 raysan5 merged commit 371d25c into raysan5:master Feb 24, 2024
@raysan5
Copy link
Owner

raysan5 commented Feb 24, 2024

@GideonSerf Nice addition! Thanks! 👍🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants