MV [MZ if equal] Keyboard and Gamepad Controls

Hello Coders =)

I need a tiny help how to bound keyboard and gamepad if they can equally assign.

On this website JavaScript Key Code can you check the "key" like "ArrowLeft" or " " or "Enter".

question for this, how can the "key" recognize for gamePad?


if key = "Enter" than the Enter Key works, but not the Z in this case.

What would be the best use to make both keyboard and gamepad work?

I ask this because I created a FakeMouse controller to use for keyboard, but can be used with gamepad
if they are equal or assign correctly to use both them.

the keyarrows and for fakeMouse works, as well for real mouse on my htmlTicTacToe game.
but while I cannot test a controller, I love to know how to add this one, so it can control both.
I just declare the gamepad buttons to the corresponding keyboard key.

This is my Chrono Engine setup

Input.gamepadMapper[0] = 'ok'; //A Input.gamepadMapper[1] = 'cancel'; //B Input.gamepadMapper[2] = 'skill'; // X Input.gamepadMapper[3] = 'item'; // Y Input.gamepadMapper[4] = 'pageup'; //LB Input.gamepadMapper[5] = 'pagedown'; //RB Input.gamepadMapper[6] = 'lt';//LT Input.gamepadMapper[7] = 'shield';//RT Input.gamepadMapper[8] = 'start';//start Input.gamepadMapper[9] = 'select';//select
This is my Chrono Engine setup
that might not work on the manipulation in my case as this is my setup for arrows keys


JavaScript:
    document.addEventListener("keydown", (e) => {
        if (!FakeMouse.active) return;

        switch (e.key) {
            case "ArrowUp":    FakeMouse.move(0, -1); break;
            case "ArrowDown":  FakeMouse.move(0, 1); break;
            case "ArrowLeft":  FakeMouse.move(-1, 0); break;
            case "ArrowRight": FakeMouse.move(1, 0); break;
            case "Enter":
            case " ":          FakeMouse.click(); break;
        }
    });

so the way this works, can control the fake mouse like a realistic mouse.
its not as smooth movement, but does the trick (for now every 20px for movement.

I just need a way to bound the controller the same way inside this part somehow.

Arrow up get a later WASD to it one tictactoe is open, but it wouldnt work for
my menu as it's a little more painful to implement to make it work exactly how it should.

so for now, I make it work on my ticktactoe, maybe global function later, to navigate
the menu selection as well, but this might not exactly work, but can try later.

as you have a similar gamepad mouse so to speak 🙂
built my own UnifiedFusionBridge (so it should work for both).

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/mz-if-equal-keyboard-and-gamepad-controls.177179/