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

> Ah, I thought HID was polling based and this API was an abstraction layer on top of polling. If it's event-driven, then this makes a lot more sense.

For full disclosure HID over USB is a hybrid of polling and events. At the physical transport level (except for fancier USB 3.0 devices) the USB host controller constantly polls the devices on the bus for completion of "transfers" requested by the kernel. A HID device might respond to every request with a new HID report or it might only respond when something has changed. That's up to the device. When the host controller gets a response other than "I'm not ready, try again later" that completes the transfer and generates an interrupt. The kernel then submits a new transfer request to the host controller so that it will keep asking the device for more data. So the software is polling, but only gets interrupts when the hardware has something new to report. The kernel can forward those interrupts to listening applications or can simply update an internal record of the current controller state that can be queried by applications as part of their game loop.

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

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

Received on Monday, 23 May 2022 21:34:27 UTC