gdx-backend-bytecoder icon indicating copy to clipboard operation
gdx-backend-bytecoder copied to clipboard

Plan: how to implement input processing

Open keesvandieren opened this issue 5 years ago • 2 comments

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

keesvandieren avatar Nov 16 '20 16:11 keesvandieren

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).

yuripourre avatar Jun 26 '21 15:06 yuripourre

@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?

yuripourre avatar Jul 01 '21 16:07 yuripourre