- From: Jake Archibald <notifications@github.com>
- Date: Tue, 02 Jan 2018 03:36:10 -0800
- To: w3c/gamepad <gamepad@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Tuesday, 2 January 2018 11:36:31 UTC
Thinking a little more about this, it could just be:
```js
gamepad.addEventListener('buttondown', listener);
gamepad.addEventListener('buttonup', listener);
// Event interface:
event.index; // index of button changed
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
gamepad.addEventListener('buttonvaluechange', listener);
// Event interface:
event.index; // index of button changed
const events = event.getCoalescedEvents();
events[0].index; // index of button changed
events[0].value; // value
```
When these events fire should follow mouse events in Firefox & Chrome, as in:
* A task is queued to fire an event for each `buttonup` & `buttondown`.
* If an axis or button changes value, an `axischange`/`buttonvaluechange` event will fire in the render steps of the event loop.
* In the task to fire a `buttonup` or `buttondown`, if an `axischange`/`buttonvaluechange` event is pending with an earlier timestamp, fire that event within the same task, before the `buttonup`/`buttondown`.
--
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-354749126
Received on Tuesday, 2 January 2018 11:36:31 UTC