[Feature Idea] Input to Action map

Started by eri0o, Sat 03/09/2022 21:11:27

Previous topic - Next topic

eri0o

So, I recently begin to think of something like this



With the EventHandler mapping to a script of the form of a ActionName_Triggered(Action *action, bool state) in global script. Actions would be arbitrary, and you could use for both a keyboard button that you map or a joystick button being pressed triggering the same event handler.

Possibly some reserved actions would exist, which would allow things like mapping different inputs to being able to skip text. All possible inputs would be selectable from a predefined list, using something like the packed InputType+Keycode/Button+modifier.

While I have some idea how this would work on the Editor side, I don't have much idea how this works in the engine. Perhaps I need some reverse map to be able to check whenever an input event happens if I need to trigger some script event. Also this may need a script API in case someone wants to remap buttons on runtime.

Questions/Problems:

  • Action folders could have some property that you could set and the actions in it would inherit?
  • Figure a way to handle multiple gamepads/joysticks, perhaps something outside maps to either gamepad 1 or 2 or...?
  • Big list of possible inputs has to be manually maintained in sync between engine and editor
  • Should continuous input be included here? They have no state change, so they don't make sense as event generating.

Crimson Wizard

#1
Quote from: eri0o on Sat 03/09/2022 21:11:27
While I have some idea how this would work on the Editor side, I don't have much idea how this works in the engine. Perhaps I need some reverse map to be able to check whenever an input event happens if I need to trigger some script event. Also this may need a script API in case someone wants to remap buttons on runtime.

I'd like to add a important note, that I'd very much like to aim the concept where everything should be createable in script (as mentioned in the preliminary concept draft written a while ago).

In this concept the script methods have a priority, and Editor acts rather as a frontend for generating the starting state of the game.

Therefore ideally you should be able to create, delete and configure these Actions right in script too. Perhaps even think about the script API first, and then figure out how to configure them using Editor interface.

EDIT: if something cannot be done right in script yet, then of course some workaround may be used for objects created in script. For example, if there won't be a feature of connecting event handlers in script done yet (#1409), then the script-born Action could trigger a default function with predefined name (like on_action).

eri0o

#2
Yes, using something like on_action could avoid the lack of function pointers to make it viable creating actions through script.

I mostly was looking on some concept that would have some reserved elements that would be used by the engine internally - for advancing dialog, skipping cutscenes and such usages, I don't remember if there are more internal configurable buttons.

SMF spam blocked by CleanTalk