Interface IHidChannel

This is a wrapper for a stream of incoming IHidReports from a device and a callback to output IHidReports to the device.

Each instance of IHidChannel is associated with only one device, and additionally, only one of its physical/wireless connections to the system.

interface IHidChannel {
    descriptor: IHidUsage[];
    input: Observable<IHidReport>;
    findDescriptor(
        usagePage: number,
        usage: number,
        reportType: any,
    ): undefined | IHidUsage;
    getFeatureReport(usagePage: number, usage: number): Observable<number>;
    output(
        usagePage: number,
        usage: number,
        value: number | number[],
    ): Promise<void>;
    setFeatureReport(
        usagePage: number,
        usage: number,
        value: number | number[],
    ): void;
}

Methods

  • Internal

    Searches for and returns a specified HID usage. Used to check if a device supports said usage.

    Parameters

    • usagePage: number

      The Usage Page of the required HID feature.

    • usage: number

      The Usage of the required HID feature.

    • reportType: any

      The type of report that the query relates to.

    Returns undefined | IHidUsage

    The IHidUsage descriptor of the found feature. If the feature is not supported by the device, undefined is returned.

  • Returns a feature IHidReport from the device.

    Parameters

    • usagePage: number

      The Usage Page of the feature report.

    • usage: number

      The Usage of the report.

    Returns Observable<number>

    The current value of the feature.

  • Writes a IHidReport to the device.

    Parameters

    • usagePage: number

      The Usage Page of the report.

    • usage: number

      The Usage of the report.

    • value: number | number[]

      Values to send for that Usage and Usage Page.

    Returns Promise<void>

  • Writes a feature IHidReport to the device.

    Parameters

    • usagePage: number

      The Usage Page of the feature report.

    • usage: number

      The Usage of the report.

    • value: number | number[]

      The new value of that feature.

    Returns void

Properties

descriptor: IHidUsage[]

Contains all of the IHidUsages reported by the device upon device discovery.

input: Observable<IHidReport>

A continuous stream of incoming IHidReports from a device.