Open hajimehoshi opened 3 years ago
This will be a preparation for HandleInput
(#1704)
EDIT: Or, HandleInput
might have to take an event argument like what key is pressed. Hmm
This doesn't resolve an issue when a user invokes input functions in Draw instead of Update (#2462). I think we have to restrict the input API only for Update.
If we don't have to consider backward compatibility,
Game
's Update() error
to Update(input *Input) error
inpututil
?HandleInput
(#1704)I think this should be done in the last 2.x after v3.0.0-alpha is tagged. Or, the API would be unnecessarily complex.
What about exp/input
? I feel like this is not trivial to get right with a single minor version or two. For these complicated features, it may be helpful to have a less stable surface where you can iterate and figure out exactly what's working well and what not. Saying this because I saw the exp/textinput
issue, and I think that was a great idea. It's an uncommon pattern, but only because very few projects are big and complex enough to deserve such exp
packages. For Ebitengine, though, it may work very well (e.g. this input issue, figuring out text/v2, maybe something with shaders, etc).
My concern is that existing APIs are marked as 'deprecated' and then pkg.go.dev for Ebitengine would be confusing. exp/textinput was a completely new feature so this didn't have such an issue.
We discussion at Discord about #1704, and realized that global input functions are not available at HandleInput
suggested at #1704. It's because the global APIs return a frozen input state for a tick. In order to avoid the confusions, we should give a good name like:
func FrozenInputStateForTick() *ebiten.InputState
if we keep global functions.
What about
?
Probably the controversial point is whether
Input
,Keyboard
,Mouse
,Touch
andGamepad
are interfaces or structs. If they are interfaces, it is pretty hard or impossible to add a new function to them, otherwise it would break backward compatibility.EDIT: Added iter.Seq