Re: [gamepad] The API is not thread-safe and can not be fixed. (#18)

Note that eventing does not work for axes. For instance, suppose you have an X/Y axis. You interprete those axies as a cursor and use its position to draw on a canvas. What you want to get is a line connecting the current to the next cursor position at each interval. However, with events, what you will get is a staircase.

The reason is that first you receive the event for the X axis, so you move the cursor by that and draw a line, then you receive the event for the Y axis, move the cursor and draw a line --> a staircase.

The typical way to handle this (in native applications) is poll all the input events (until the queue is empty) and collate all values into an axis state object holding the X and Y value.

However in a browsers "event" interpretation, JS has no control over polling. So there's no way a JS program can synchronize its drawing loop with its event polling loop.

---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/gamepad/issues/18#issuecomment-155389954

Received on Tuesday, 10 November 2015 11:05:15 UTC