Re: [w3c/gamepad] Add gamepad input events (#152)

@SINePrime, different games use different models for handling input. Polling input is very natural for games that consider controller state as part of their update step, but not every game works this way. Polling also means that it is possible for the game to miss inputs if it doesn't happen to poll the controller while a button is pressed. Input events are designed to enable developers that want to write logic like "when button A is pressed, start a jump animation" but also allows developers using the update model to modify state (e.g. "jump button was pressed") that is then checked as part of the main game loop.

In other words, it is easy to polyfill a polling-based input model on top of an event-based one. Doing the reverse is inefficient (because you just keep having to poll faster and faster to avoid missing events) and so the platform should provide events and let developers use them however they'd like to.

Events are also how the underlying hardware interfaces work, they generate interrupts when the controller state changes. Providing an event-based API allows developers to get those events as quickly as possible without wasting cycles polling.

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

Message ID: <w3c/gamepad/pull/152/c1135111413@github.com>

Received on Monday, 23 May 2022 20:33:06 UTC