Implemented on GIT Remove code that makes non standard mapped joysticks on HTML ignored

grant

Member
CX Code Contributor
3rd Party Module Dev
Joined
Nov 19, 2019
Messages
81
In JavaScript gamepads have a "mapping" property that says if the gamepads has a specific mapping and so far they only have a "standard" value. Other gamepads may or may not be mapped correctly. A lot of generic USB gamepads and adapters return that they don't have a mapping. On Firefox especially. The source code in Cerberus X's HTML5 export ignores any gamepads that haven't been marked as "standard". This should be removed, because these gamepads still may be mapped correctly and even if they aren't we shouldn't block the player from trying them.

Info on JavaScript Gamepads: https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API

These lines should be removed form targets/html5/modules/native/html5game.js
Code:
if (gamepad.mapping == "standard") {

Code:
} else {
   console.log('Cerberus has ignored gamepad at raw port #'+gamepad.index+' with unrecognised mapping scheme \''+gamepad.mapping+'\'.');
}
 
Last edited:

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
912
Interesting! When I'm done with the current project I'm planning to make Cerberus talk with
different sensors and MIDI through the gamepad-API.

(I'll be emulating gamepad events and hide the fact that MIDI and hardware sensors are not gamepads at all).
 

grant

Member
CX Code Contributor
3rd Party Module Dev
Joined
Nov 19, 2019
Messages
81
Interesting! When I'm done with the current project I'm planning to make Cerberus talk with
different sensors and MIDI through the gamepad-API.

(I'll be emulating gamepad events and hide the fact that MIDI and hardware sensors are not gamepads at all).
Interesting! I don't have any MIDI devices. How would they connect through the gamepad API?

This change I'm proposing is just because most game controllers have different button mappings. Sometimes the web browser remaps them so they are "standard".
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
912
I understand! I wonder what else will come after having only standard for such a long time..
Augmented reality & Accessibility will certainly come into play there.

The connection is easy actually you just emulate events in pure javascript.
Here's a few examples that are quiet well coded :


 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
912
All the MIDI timing inside Javascript is so great at this point so can even do Audio DSP real-time and be quiet okay with the results.

Which means the full lag-chain will be almost zero and non-existant.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,165
As nobody mentioned any problems, I moved it to the develop branch.
 
Top Bottom