[Phaser 3] New InputManager library


#1

I basically started with the thought: “it shouldn’t be too hard to match fighting game style input sequences” during a conversation in the discord…

And when I had stopped typing I had something that did this and much much more.

phaser3-hadoken is a library that can function as a general input manager mapping signals from arbitrary controllers (out of the box it supports keyboard and gamepad) into inputs that are meaningful to the game. This means you can do things like handle “jump” inputs and have that coming from a keyboard, a gamepad, or any other adapter you’ve hooked in allowing the player to seamlessly transition between them.

A game can run multiple instances of hadoken meaning you can create one per player and player-specific events will be easy to process to support couch co-op gameplay.

And, yes, it comes with an input for fighting game inputs since that was the v0. Check out the demo.

I consider this beta-quality, it’s functional and I’ve used it for some small projects but I’ve also identified a lot of neat extras that could be added or alterations that would be worthwhile if it gets any amount of adoption.

If you have questions feel free to drop by discord or ask on thread.

Cheers.


#2

This looks amazing! Thank you for making it. Any plans to add methods to make it easy for the player to remap controls?


#3

This looks amazing! … Any plans to add methods to make it easy for the player to remap controls?

Yay, I’m glad you like it, :heart:!

Kinda?

Like, right now it’s trivial to remap controls on the keyboard adapter (see the demo which supports trivial switching between qwerty & dvorak). There is a minor change to the Gamepad adapter so that it exposes a setter for the button mapping allowing you to swap up the mappings which I meant to include in the initial release but totally forgot about; I’ll try to push that tomorrow :joy:.

Beyond that, though, there is a generalized “remap your controller” API that generates ButtonMap/MappingFn dynamically which wants to be written; I think this can be done on top of phaser3-hadoken without impacting the core library. If it requires any changes to the underlying library I’m happy to make/help make them. For the time being though I’m pushing that into “if we want it we’ll write it” and maybe revisit when I’ve taken a bit of a break

Basically, I’m happy to help folks 1:1 that want to use it and even make changes to support their use case in many circumstances but unless folks are actively expressing interest in using hadoken a remapping API is a bit of work that it isn’t clear is necessary or even useful.


#4

Hey @B3L7,

I didn’t implement a player remapping UI for the reasons listed above but I push pushed v0.2.0 that includes an explicit API to remap controls so that it’s easier to build one for your game.

I also updated the demo to include usage of that API to show how it can be used to do things like invert one or both directions of the joystick axis.


#5

Awesome! I can’t wait to check it out.