Open MechWarrior99 opened 3 months ago
Having thought about this myself a while back, I didn't reach quite your conclusion. I think adding 'Held' would be nice to have but not remove 'Down'. Unfortunately the difficulty is due to what the previous button's state was, which may be important.
The states I think are of interest are:
IsButtonPressed(...)
)IsButtonReleased(...)
)But there's two more other states to think about:
IsButtonDown(...)
)!IsButtonDown(...)
)So, 'Down' would actually mean either 'Pressed' or 'Held'. Or if you want to add 'Held' as a new state, then 'Held' would mean 'Down' and not 'Pressed'.
Though to be honest, I'm not really sure if I can think of a scenario where you really need to know if a button is 'held' (ie both previous frame & current frame down), I'm sure someone can point out a situation though.
Held - was Down in the previous frame, and still Down now I think we should avoid discussing this specific implementation, as you said, the specifics of it is just not that useful and may introduce an unwanted delay to inputs as users may think this would be similar to the
Down
you described, increasing confusion even more.
I prefer Held
over Down
as it is more specific, but it's still not perfect; @Basewq going over his implementation does show that it could be interpreted in that way as well.
Maybe Held
/Down
should be ButtonState
instead. It sure is not as nice but I don't think users could misinterpret its specifics ?
Unity has this naming scheme:
Input.GetButton
Input.GetButtonDown
Input.GetButtonUp
myInput.isPressed
myInput.wasPressedThisFrame
myInput.wasReleasedThisFrame
Godot:
is_action_pressed
is_action_just_pressed
is_action_just_released
Bevy:
pressed
just_pressed
just_released
UE is all event based, so not really applicable here.
Held - was Down in the previous frame, and still Down now
I think we should avoid discussing this specific implementation, as you said, the specifics of it is just not that useful and may introduce an unwanted delay to inputs as users may think this would be similar to the Down you described, increasing confusion even more.
I would agree, not that useful and may introduce unexpected and unwanted behavior. Though was worth bringing up still I think.
Maybe
Held
/Down
should beButtonState
instead. It sure is not as nice but I don't think users could misinterpret its specifics
I have always really disliked Unity's Input.GetButton
as to me it doesn't convay well that it is returning the button's current state, and not an actual button object of some kind.
Godot: Bevy:
Adding the just
infront makes sense, but also feels really clunky to me, and 'un C#', plus then you get Input.WasVirtualButtonJustPressed
which is starting to get pretty long. (Not that it is everything, but I think worth considering and making note of)
A note on how the input actually works right now.
For VirtualButtons all states are processed once each update. For low-level device inputs, the Down
state is update immediatly, while the Pressed
and Released
is update once each update. So, technically, depending on the call order, it might be possible for Down
to be called before Pressed
, but I am not completly sure on this.
Not sure how relevent it is, but wanted to add a bit of clarification if it was needed.
Down
is standard in UI frameworks (Winforms, WPF, egui, ImGui, Swift, Web). I don't know of any that uses the word Held
. I'd prefer we stick to what people might recognize.
My personal preference is press/release naming in line with John Carmack's description on UI design: https://x.com/ID_AA_Carmack/status/1787850053912064005
And then "Down" would refer to the current state of the key, whether it is "down" or not. I also believe that this naming convention translates well to analogue keyboards.
Is your feature request related to a problem? Please describe. It is difficult to keep straight which behavior the "Down" and "Pressed" input methods perform.
Describe the solution you'd like Rename all occrances of
Down
toHeld
in the input related classes/interfaces/structs. And mark existing public members that useDown
in their name as obsolete.Additional context Considered renaming to
Pressing
instead ofHeld
, but it would be the reverse of how events are normally called. Normally it isLoading
>Loaded
, so havingPressed
>Pressing
I feel adds more confusion. AndPressed
>Held
>Releases
feels intutive to me. Open to other name ideas though.