Hey DK… remember long ago, when I was bitching about the new camera.inputs system, and I was sort-of talking about a controller “patch panel” (and “ganging”, “binding”, and/or cascading controller events)?
And remember when I suggested… that all inputs should pass to a new kind of ActionManager… made for controller inputs… but uses same trigger/action registering system as current actionManagers? Remember?
Boy, was I ever off-base, just like the entire contents of this post, huh? heh. But still, doesn’t this sort-of “feel” like an actionManager made for controllers/inputs?
EventManager, InputManager, ObserverManager, ActionManager, a triggers and actions festival.
Maybe it’s just me. All in all, ignore this, not pertinent. Sorry for interrupt.
So really, it depends on whether BabylonJS is aiming at being a game engine that targets multiple platforms or more towards being a 3d framework that targets traditional HTML5 platforms.
A web developer won’t have many use cases for an input mapping system I guess …? while a game developer may want to target multiple platforms, and multiple input devices, or manage input for multiple game states (menu, multiplayer, story mode), multiple gameplay states or multiple vehicles (i.e. tank, planes, walk). In such a scenarii, the use cases increase in numbers.
Hence it really depends on whether you see BabylonJS as a game engine or a 3d framework.
If you go down this road, the big names can serve as inspiration for the implementation.
However, for unity, I would advice having a look at the plug-in ReWired in the asset store, which is more robust and flexible than the unity input manager ^^
You can kinda script all this with how the system is. I mean its not as easy as a cool UI with drop down visuals, but for the most part if you code up a Controller object and just change what your inputs are depending on the client you can handle almost any case I would imagine.
Looks nice, but why not using letters instead of keycode? Or maybe even better: an enum, so that the gamedev can use the autocompletion to find the key they are looking for.
Note: we need to make sure that the structure you are creating scale to continuous values, such as controller axis, pinch touch, controller’s left and right triggers, mouse position/dragging? Godot Engine uses the concept of action strength, hence all events return a number between 0 to 1. Discrete events can only return 0 or 1 while continuous event can use all the range. Also I believe that an axis can return -1 to 1? I need to read their doc.
Also, it would be nice that we can import the input map from a JSON file… So that we can edit it independently from the code.
You may need the concepts of players, layouts and categories as in ReWired, if you want to deal with multiple controllers (multiplayer games), multiple input layouts (e.g. left and right handed players, etc…) and importantly different gameplay contexts (e.g. in menu, in tank, in top-down view).
Concerning the touch input, it would be nice that the pinch input that you coded for the arc rotate camera become usable for anything else. I had to cancel the pinch zoom feature of my game cause I was using a free camera
String: How do you capture keys like space or numLock?
Enum: Not something I want to maintain for all the keyboards in the world
Importing from a JSON file: Not something I want to do. It is client code.
Players, etc: I do not want to go to that level. This is user code again. Babylonjs is a framework and I do not want to bloat it with too high level and very specific features. We have the extensions repo for that
Continuous event: Yep good point. Based on my current API, how do you see the trigger declaration? Can you provide some examples so I can back track it?
JSON file: yes but to save to/read from JSON could be facilitated if you develop the input manager with that in mind that gamedev will probably want to save their mapping into a file
Players: I would say that you need to make sure that your solution scales to local multiplayers (i.e. several gamepads).
Wait I’m trying to help you guys here but I won’t do the job:)
I started a branch so you can contribute and shape the tool you need.
I checked your links and this seems all great (all but the enums as we should not considering maintaining an enum with all the keycode of the world. Just think about Chinese or Japanese Unicode values)
I am not sure what to do with this link you gave us @Deltakosh:
If I understand, there is a branch input-manager and we can try to implement something in that branch. Should we open the PR once we are done implementing it, or now?
I 100% agree on JSON and hooking the event.key attribute along with the keycode. Can we please replace the device: BABYLON.InputHubDevice.Keyboard with a string?
If you have looked at many good games, they allow players to map actions to their own gestures. This is what I want to have happen with this eventually. I would like to be able to export and import a JSON file.
Also, how easy is it to register and unregister event handlers? I’m thinking of the action “up” will need a different handler for the inventory screen vs the navigation screen.
This is a very good idea, especially if everything that @frastlin mentioned ends up being implemented eventually. Our project could throw out a lot of lines of client side code code if it could use this (and we have not even started with the mobile controls implementation for the main game yet!).
Can we also have a standard API to query the names of the keys that have been set? This is very kludgy in JavaScript at the moment with KeyboardEvent.keyCode being deprecated and KeyboardEvent.key being inconsistent across keyboard layouts. We use a manually coded lookup table ATM, but a standardized solution would be welcome!
Re: touch etc., I would want something like {event, key(W), screen(x1,y1,x2,y2,1finger), joy(‘up’), voiceaccessible(“walk forward”)}
With observables (isHeld?, hasbeenTapped? [A queue]) Or some such… The joystick camera is a pretty exemplary example of touch input.