Add Emscripten (web) joystick rumble support #13757
Open
+40
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds support for Emscripten (Web) joystick rumble support via
EM_ASM_INT
Emscripten macro and Web Gamepad API (specifically, gamepad'svibrationActuator
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 insideEM_ASM_INT
macros for this to work. (P.S. I usedobject['property']
notation instead ofobject.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.