The API used in RPGMV's
RPG_CORE.js is
Input, it's not something simple for common users...
Going to line 3036 there is a mapping of the keys by the ID passed from what I understand:
JavaScript:
Input.gamepadMapper = {
0: 'ok', // A
1: 'cancel', // B
2: 'shift', // X
3: 'menu', // Y
4: 'pageup', // LB
5: 'pagedown', // RB
12: 'up', // D-pad up
13: 'down', // D-pad down
14: 'left', // D-pad left
15: 'right', // D-pad right
};
The problem is that the "core" functions make the keys work in parallel, so
Input.isPressed("right") will check if the "AXIS" is to the right, but it will also check if the "Right" key on the keyboard will also activate the
Conditional Branch.
Code:
◆If:Button [Right] is pressed down
◆Show Balloon Icon:Player, Exclamation (Wait)
◆
:End
Now to be able to confirm that only the GamePad would really have to learn the native API:
HTML provides the necessary components for rich, interactive game development. Technologies like <canvas>, WebGL, <audio>, and <video>, along with JavaScript implementations, support tasks that provide similar, if not the same, features as native code. The Gamepad API allows developers and...
developer.mozilla.org
I believe that to check whether it is to the right or left it is like this, with "-1" being left and "1" being right:
JavaScript:
parseInt(navigator.getGamepads()[0].axes[0])
On RPG Maker:
Code:
◆If:Script:parseInt(navigator.getGamepads()[0].axes[0]) == 1
◆Show Balloon Icon:Player, Exclamation (Wait)
◆
:End
I'm not a programmer, I just read the APIs and use logical sense to understand something, so that's what I assume.
But one thing is certain, this check is for control "1", if you connect another control the object will appear in Array [ 1 ] and not in [ 0 ]:
JavaScript:
navigator.getGamepads()[0] /*Gampad 1*/
navigator.getGamepads()[1] /*Gampad 2*/
navigator.getGamepads()[2] /*Gampad 3*/
I have two USB controllers here to test if I disconnect the first one to see if the second one will take control of the game, but I don't have time at the moment.