Connection to rare devices from your application.
Updated
The API de WebHID es parte de capabilities project and is currently under development. This post will be updated as implementation progresses.
What is the WebHID API?
Existe una larga lista de dispositivos de interfaz humana (HID) que son demasiado nuevos, demasiado antiguos o poco comunes para que los controladores de dispositivos de los sistemas puedan acceder a ellos. La API WebHID resuelve esto proporcionando una forma de implementar la lógica específica del dispositivo en JavaScript.
Suggested use cases for the WebHID API
An HID takes information from humans or provides them with results. Examples of devices include keyboards, pointing devices (mice, touchscreens, etc.), and gamepads. the HID protocol hace posible acceder a estos dispositivos en computadoras de escritorio utilizando controladores del sistema operativo. La plataforma Web admite HID basándose en estos controladores.
La imposibilidad de acceder a dispositivos HID poco comunes es particularmente dolorosa cuando se trata de compatibilidad con gamepad. Los gamepads diseñados para PC a menudo usan HID para las entradas del gamepad (botones, joysticks, disparadores) y salidas (LED, rumble). Sin embargo, las entradas y salidas del gamepad no están bien estandarizadas y los browsers web a menudo requieren una lógica personalizada para dispositivos específicos. Esto es insostenible y da como resultado un soporte deficiente para la larga cola de dispositivos más antiguos y poco comunes. También hace que el browser dependa de las peculiaridades presentes en el comportamiento de dispositivos específicos.
Actual state
He passed | Condition |
---|---|
1. Create an explainer | To complete |
2. Create initial draft specification | In progress |
3. Collect feedback and repeat the design | In progress |
4. Proof of origin | Get started in Chrome 86 |
5. Launch | Not started |
Give, give, give
Uno de los miembros de mi equipo está trabajando actualmente en un artículo de instrucciones. Dado que WebHID está comenzando una prueba de origen en Chrome 86, algunos de nosotros queríamos avisarle y compartir algunas demostraciones para jugar. Si tiene curiosidad acerca de cómo funciona alguno de estos ejemplos, el source code de todos ellos está disponible en GitHub. There is a barebones code example in the explainer.
To use the demos, enable the #enable-experimental-web-platform-features
flag on chrome://flags
.
MacBook Pro keyboard backlight
The biggest barrier to trying any of these demos is lack of access to the device. Fortunately, if you have a MacBook Pro with a TouchBar, you don't need to buy anything. This demo allows you to use the API directly from your laptop. It also shows how WebHID can be used to unlock the functionality of embedded devices, not just peripherals.
Author: FWeinb
Demo / Source: Keyboard backlight
Game controllers
The next step is something that less of you probably have. The Sony DualShock 4 is a wireless controller for PlayStation 4 game consoles.
The DualShock 4 demo uses WebHID to receive the raw input reports from the DualShock 4 and provides a high-level API to access the controller's gyro, accelerometer, touchpad, button, and joystick inputs. It also supports rumble and set the color of an RGB LED housed within the controller.
Author: TheBITLINK
Manifestation: DualShock 4 Demo (Source)
The BlinkStick Strip
BlinkStick Strip es una tira de luz compatible con HID con 8 LED RGB. La demostración permite al Username seleccionar entre varios patrones de parpadeo, incluidos persecución, parpadeo y escáner Larson (también conocido como Cylon).
Author: Robat williams
Manifestation: flashing strip (source)
Blink, blink, blink
What does this demo do? (Wait for it.) Blink. It's actually three demos using the flashing USB notification light (1).
blink (1) is simple and well documented, making it a great choice to get started with HID.
Author: Tod E. Kurt
Population: blink (1) (source)
conclusion
I hope I have piqued your interest in the WebHID API. Watch this space in the next few weeks for updates and Getting Started Part II, which will show you how to use the API yourself.
Helpful Links
Do you want to go deeper?
Thanks
Thanks to Pete LePage and Kayce Basques to review this article.
Photo by Ugur Akdemir in Unsplash