Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename "Down" input methods for clarity from "Pressed" (e.g. IsKeyDown, IsMouseButtonDown etc.) #2287

Open
MechWarrior99 opened this issue May 26, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@MechWarrior99
Copy link
Contributor

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 to Held in the input related classes/interfaces/structs.
And mark existing public members that use Down in their name as obsolete.

Additional context
Considered renaming to Pressing instead of Held, but it would be the reverse of how events are normally called. Normally it is Loading > Loaded, so having Pressed > Pressing I feel adds more confusion. And Pressed > Held > Releases feels intutive to me. Open to other name ideas though.

@MechWarrior99 MechWarrior99 added the enhancement New feature or request label May 26, 2024
@Basewq
Copy link
Contributor

Basewq commented May 26, 2024

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:

  • Pressed - "just pressed", ie. was Up in the previous frame, but now Down (IsButtonPressed(...))
  • Held - was Down in the previous frame, and still Down now
  • Released - "just released", ie. was Down in the previous frame, but now Up (IsButtonReleased(...))

But there's two more other states to think about:

  • Down - is Down now, the previous frame does not matter (this is the current behavior of IsButtonDown(...))
  • Up - is Up now, the previous frame does not matter (basically just !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.

@Eideren
Copy link
Collaborator

Eideren commented May 26, 2024

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.

@MechWarrior99
Copy link
Contributor Author

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 be ButtonState 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.

@Kryptos-FR
Copy link
Member

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.

@Fydar
Copy link
Contributor

Fydar commented Jun 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants