Table of Contents

Class HIDDevice

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll
NOTE
Experimental
The HIDDevice interface of the WebHID API represents a HID Device. It provides properties for accessing information about the device, methods for opening and closing the connection, and the sending and receiving of reports.
[Value("HIDDevice")]
public class HIDDevice : EventTarget
Inheritance
HIDDevice
Inherited Members

Remarks

Constructors

HIDDevice()

public HIDDevice()

Properties

Collections

NOTE
Experimental
The collections read-only property of the HIDDevice interface returns an array of report formats
[Value("collections")]
public HIDCollectionInfo[] Collections { get; }

Property Value

HIDCollectionInfo[]

An array of report formats. Each entry contains the following:

Remarks

Oninputreport

[Value("oninputreport")]
public EventHandlerNonNull Oninputreport { get; set; }

Property Value

EventHandlerNonNull

Opened

NOTE
Experimental
The opened read-only property of the HIDDevice interface returns true if the connection to the HIDDevice is open and ready to transfer data.
[Value("opened")]
public bool Opened { get; }

Property Value

bool

A boolean value, true if the connection is open.

Remarks

ProductId

NOTE
Experimental
The productId read-only property of the HIDDevice interface returns the product ID of the connected HID device.
[Value("productId")]
public ushort ProductId { get; }

Property Value

ushort

An integer. If the device has no product ID, or the product ID cannot be accessed this will return 0.

Remarks

ProductName

NOTE
Experimental
The productName read-only property of the HIDDevice interface returns the product name of the connected HID device.
[Value("productName")]
public string ProductName { get; }

Property Value

string

A string.

Remarks

VendorId

NOTE
Experimental
The vendorId read-only property of the HIDDevice interface returns the vendor ID of the connected HID device. This identifies the vendor of the device.
[Value("vendorId")]
public ushort VendorId { get; }

Property Value

ushort

An integer. If the device has no vendor ID, or the vendor ID cannot be accessed this will return 0.

Remarks

Methods

Close()

NOTE
Experimental
The close() method of the HIDDevice interface closes the connection to the HID device.
[Value("close")]
public Task<GlobalObject.Undefined> Close()

Returns

Task<GlobalObject.Undefined>

A Promise that resolves with undefined once the connection is closed.

Remarks

Forget()

NOTE
Experimental
The forget() method of the HIDDevice interface closes the connection to the HID device and forgets the device.
[Value("forget")]
public Task<GlobalObject.Undefined> Forget()

Returns

Task<GlobalObject.Undefined>

A Promise that resolves with undefined once the connection is closed, the device is forgotten, and the permission is reset.

Remarks

Open()

NOTE
Experimental
The open() method of the HIDDevice interface requests that the operating system opens the HID device.
[Value("open")]
public Task<GlobalObject.Undefined> Open()

Returns

Task<GlobalObject.Undefined>

A Promise that resolves with undefined once the connection is opened.

Remarks

NOTE

HID devices are not opened automatically. Therefore, a HIDDevice returned by RequestDevice(HIDDeviceRequestOptions) must be opened with this method before it is available to transfer data.

See also on MDN

ReceiveFeatureReport(byte)

NOTE
Experimental
The receiveFeatureReport() method of the HIDDevice interface receives a feature report from the HID device. Feature reports are a way for HID devices and applications to exchange non-standardized HID data.
[Value("receiveFeatureReport")]
public Task<DataView> ReceiveFeatureReport(byte reportId)

Parameters

reportId byte

Returns

Task<DataView>

A Promise which resolves with a DataView object containing the feature report.

Remarks

The reportId for each of the report formats that this device supports can be retrieved from Collections.

See also on MDN

SendFeatureReport(byte, Union224)

NOTE
Experimental
The sendFeatureReport() method of the HIDDevice interface sends a feature report to the HID device. Feature reports are a way for HID devices and applications to exchange non-standardized HID data.
[Value("sendFeatureReport")]
public Task<GlobalObject.Undefined> SendFeatureReport(byte reportId, Union224 data)

Parameters

reportId byte
data Union224

Returns

Task<GlobalObject.Undefined>

A Promise that resolves with undefined once the report has been sent.

Remarks

The reportId for each of the report formats that this device supports can be retrieved from Collections.

See also on MDN

SendReport(byte, Union224)

NOTE
Experimental
The sendReport() method of the HIDDevice interface sends an output report to the HID device.
[Value("sendReport")]
public Task<GlobalObject.Undefined> SendReport(byte reportId, Union224 data)

Parameters

reportId byte
data Union224

Returns

Task<GlobalObject.Undefined>

A Promise that resolves with undefined once the report has been sent.

Remarks

The reportId for each of the report formats that this device supports can be retrieved from Collections.

See also on MDN