Skip to content

Add Emscripten (web) joystick rumble support #13757

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Nintorch
Copy link

Description

This PR adds support for Emscripten (Web) joystick rumble support via EM_ASM_INT Emscripten macro and Web Gamepad API (specifically, gamepad's vibrationActuator property). I haven't found built-in Emscripten support for this feature in a form of C API, so that's why I decided to wrap pieces of JavaScript code inside EM_ASM_INT macros for this to work. (P.S. I used object['property'] notation instead of object.property because of JavaScript minifiers and Emscripten wiki suggesting to use it).

Relevant Emscripten wiki and web API documentation links: https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#calling-javascript-from-c-c and https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/vibrationActuator .

This fix has been tested with Godot Engine in this PR to fix an existing issue. But, if you feel this change is not necessary for SDL, please let me know 😅

This would be my first contribution to SDL. I like this library, I think you're all doing a great job, thank you so much for all your hard work! It's great to see both SDL and Godot become even better every day too! :)

Existing Issue(s)

I haven't found any in SDL's repository.

Adds support for Emscripten (Web) joystick rumble support via EM_ASM_INT macros and HTML5's Gamepad API.
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.

1 participant