Leafwing-Studios / leafwing-input-manager

A straightforward stateful input manager for the Bevy game engine.
Apache License 2.0
686 stars 106 forks source link

Share metadata across input-kind #553

Closed alice-i-cecile closed 1 month ago

alice-i-cecile commented 3 months ago
          I wonder if some metadata should be shared between all 3 options.

For example the ActionState being disabled seems more-or-less independent from the way the action is mapped (button/axis/axis-2d).

For example in my case I want to stop input replication systems if the Action is disabled. Now it looks like i would have to check independently for all 3 subtypes of the action

_Originally posted by @cBournhonesque in https://github.com/Leafwing-Studios/leafwing-input-manager/pull/548#discussion_r1660326254_

cBournhonesque commented 2 months ago

In general I'm a bit unsure of why an ActionState could have both Button, 1dAxis, 2dAxis mapped to it simultaneously.

a) what would be some examples where this is useful? b) but then why not also allow multiple 2dAxis to be mapped to the same ActionState? It seems arbitrary to only allow one of each input-type, instead of also allowing duplicated (for instance the ActionState is mapped to a 1dAxis, another 1dAxis and a 2dAxis)

If it's not useful, maybe the InputType could become an

enum {
  Button,
  Axis,
  2dAxis
}

In general I do think it will be useful to not have ActionData contain both button-data, axis-data, etc. in the same struct as it is a bit confusing, but i'm unsure if having 3 hashmaps (1 for each input-type) is the right solution.

(of course I don't mean this to be a blocker, it's probably better to merge the refactor first and then iterate on it!)