chromium/third_party/blink/renderer/modules/hid/hid.idl

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Functionality for enumerating and connecting to devices within the HID
// subsystem.
// https://wicg.github.io/webhid/index.html#enumeration

[
    Exposed(ServiceWorker WebHIDOnServiceWorkers,
            Window WebHID),
    SecureContext
] interface HID : EventTarget {
    attribute EventHandler onconnect;
    attribute EventHandler ondisconnect;

    // Retrieves information about all available HID subsystem devices.
    [
        CallWith=ScriptState,
        RaisesException,
        MeasureAs=HidGetDevices
    ] Promise<sequence<HIDDevice>> getDevices();

    // Requests permission from the user to use a device.
    [
        Exposed(Window WebHID),
        CallWith=ScriptState,
        RaisesException,
        MeasureAs=HidRequestDevice
    ] Promise<sequence<HIDDevice>> requestDevice(
        HIDDeviceRequestOptions options);
};