Skip to main content
Version: next

UHID Device

ScrcpyUHidManager.createDevice returns a ScrcpyUHidDevice. The device exposes a readable output stream and sends input reports to the Android device.

Properties​

// import type { ScrcpyUHidDevice, ScrcpyUHidOutputDeviceMessage } from "@yume-chan/scrcpy";
import type { ReadableStream } from "@yume-chan/stream-extra";

interface ScrcpyUHidDevice {
readonly id: number;
readonly output: ReadableStream<ScrcpyUHidOutputDeviceMessage>;
readonly name?: string;
readonly productId?: number;
readonly vendorId?: number;
readonly destroyed?: boolean;
}
  • id: ID assigned by the manager.
  • output: Stream of output reports sent by the virtual HID device, such as keyboard LED state changes.
  • name: Device name. Available when the server version supports device names.(since v2.7)
  • vendorId and productId: USB identifiers. Available when the server version supports these identifiers.(since v3.1)
  • destroyed: Whether the device has been destroyed. Available when explicit device destruction is supported.(since v2.7)

sendReport​

Sends an input report to the virtual device. The report bytes must match the input report format declared by its HID descriptor.

sendReport(report: Uint8Array): Promise<undefined>;

destroy​

Destroys this virtual HID device. Repeated calls share the in-progress operation. After a successful call, sendReport rejects because the device is destroyed. Scrcpy v2.4 devices do not expose this method; their lifetime is tied to the connection.

(since v2.7)
note

See UHID manager to create and manage devices, or read about its output stream.