Re: [w3c/gamepad] Should fire events instead of using passive model (#4)

@AshleyScirra 

> If you wait until rAF to draw any changes, and you received both axischange events by then, it should correctly handle simultaneous X/Y changes.

I'm proposing this event should be fired in the render steps, so it's already in the same phase of the event loop as rAF, and debounced in the same way.

> I think a more interesting question is how to handle that with getCoalescedEvents(). Will the coalesced events for different axes be guaranteed to have the same number of updates at the same time?

In my proposal the objects look like this:

```js

gamepad.addEventListener('axischange', listener);

// Event interface:
event.index; // index of axis changed
const events = event.getCoalescedEvents();
events[0].index; // index of axis changed
events[0].value; // value
```

Each `event` of `events` may have a different axis. They'll be in order of `event.timeStamp`.

I think needing `getCoalescedEvents` is an edge case (as it is with mouse events). In most cases you'll just do something like:

```js
gamepad.addEventListener('axischange', () => {
  doSomethingWithThese(gamepad.axes[0], gamepad.axes[1]);
});
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/gamepad/issues/4#issuecomment-355015569

Received on Wednesday, 3 January 2018 13:48:47 UTC