Hello everyone! I have modified RunLoop.js to allow the use of gampads with Fusion's joystick actions on HTML5. This modification means you can now use the Joystick 1/2/3/4 input devices similar to how you would on the Windows runtime.
This is made possible through the use of the JavaScript Gamepad API. Without this modification, the inputs for all four players are just mapped to their keyboard controls. Now, if you select Joystick 1 for a player's input, the runtime will get the input for that player from the first gamepad recognized by the Gamepad API.
Supporting both Keyboard and Joystick Input
Since most developers would still want to support keyboard input in addition to any joystick support, a way to detect if a gamepad is connected at runtime is required. For this, you can use the Please login to see this link. that I have just released (and also attached to this thread for convenience). There is a condition in there that allows you to check if a gamepad is connected at a specific device index (0-3).
Please login to see this attachment.
You can also use the object to get joystick input without modifying the runtime, but that would require using the object's conditions over Fusion's built in ones. If you are fine with the built in joystick actions, then the extension is only needed for detecting if a gamepad is connected, which will allow you to set the player's input device accordingly.
Installation
Just replace the RunLoop.js file in the Data\Runtime\Html5 folder inside of your Fusion installation directory with the one provided here and you are ready to go.
The Gamepad Input object's files can just be dragged into the main Fusion installation directory (the same directory the mmf2u.exe is in). You may need to accept a prompt to merge the folders before proceeding, but after that everything should copy correctly.
Important Notice
It is important to note that the order in which gamepads are recognized (and subsequently the index they are assigned) may not reflect the player number displayed on the controller. This seems to be a problem with the API since there is no way to get the player number assigned to a connected device.
As a compromise for this, you'll find two different zip files for download here. The regular "RunLoop.zip" enables joystick input for all 4 players, while the "RunLoop_Single_Joystick.zip" file only enables joystick input for Player 1, with all other players falling back to keyboard input automatically if they have a non-keyboard input defined for them like they do on the current unmodified runtime.
Of course you could simply assign all other players keyboard input in Fusion before exporting, but the 2nd file ensures that even if you set the input for players 2/3/4 to a joystick device with an event, it will still fall back to keyboard input. This primarily benefits projects that already have events like these, but it also reduces concern when adding those events for other platforms. Just less to worry about
A Note about Testing
Sometimes Fusion will disable certain features when running a application through the editor with F5/F7/F8 based on the build target you have selected. For HTML5, it will ignore joystick input when running in debug mode through the editor. When it is actually deployed to HTML5 Development or Final with the modification though, the joystick input will work as expected. To my knowledge, this is something that can't be changed with simple file editing. So, if you are testing inside Fusion and notice your joysticks not working, that is likely because you have the HTML5 build type selected. Just remember, it WILL work when running in the browser though.
Okay I think that's everything. Have fun everyone!