gdx-backend-bytecoder
gdx-backend-bytecoder copied to clipboard
Plan: how to implement input processing
How can we implement input?
- can we reuse GWT implementation?
- what are bytecoder specifics we need to take care of?
- how much work is the minimal implementation?
- Focus first on mouse clicks / tabs, keyboard input lower prio for us
I think GWT can be used as a basis. It can copy the hookEvents method from DefaultGwtInput
val w = Window.window()
val d = w.document()
d.addEventListener("mousemove", this);
d.addEventListener("mousedown", this);
d.addEventListener("mouseup", this);
d.addEventListener("keyup", this);
//...
The BytecoderInput class should implement EventListener<Event> and inside the run method, check the type of the event and cast them for specific usage (just like gwt implementation is doing).
The steps would be:
- [x] Add type to event (Merged)
- [X] Add button to MouseEvent (Merged)
- [X] Add key and code to KeyboardEvent (Merged)
- [x] Create MouseWheel event (Merged)
- [x] Update BytecoderInput adding hookEvents method
- [ ] Think about how to handle events outside the canvas element (calculate relative positions, handle focus, etc).
@keesvandieren @CoenRijsdijk I updated my comment to reflect the current state of Bytecoder. I added a task list that can work as a plan.
What do you think?