Skip to main content
Version: next

UHID Manager

ScrcpyUHidManager creates and tracks virtual HID devices. With @yume-chan/adb-scrcpy, access it through AdbScrcpyClient.uHidManager; it is unavailable when control is disabled or the selected Scrcpy version doesn't support UHID.

Use the manager to create a device, then use it to send input reports and receive output reports through its output stream.

createDevice​

Creates a virtual HID device on the Android device and returns a ScrcpyUHidDevice.

// import type { ScrcpyUHidDevice, ScrcpyUHidManager } from "@yume-chan/scrcpy";
interface ScrcpyUHidManager {
createDevice(device: {
name: string;
vendorId: number;
productId: number;
descriptor: Uint8Array;
}): Promise<ScrcpyUHidDevice>;

close?(): Promise<undefined>;
}
  • name: Human-readable device name. This is sent to the server.(since v2.7)
  • vendorId and productId: USB vendor and product identifiers. These are sent to the server.(since v3.1)
  • descriptor: HID report descriptor that defines the device's capabilities.

The device ID is allocated by the manager. It does not need to be supplied when creating a device.

In Scrcpy v2.4, createDevice accepts only { descriptor }. The ID is allocated automatically. This version does not expose device destruction or manager cleanup methods.

(between v2.4 and v2.7)

In Scrcpy v2.7 and v3.0, createDevice accepts { name, descriptor }. The manager also adds close() to destroy all devices it owns.

(between v2.7 and v3.1)

In Scrcpy v3.1 and later, createDevice accepts { name, vendorId, productId, descriptor }.

(since v3.1)

close​

Destroys all devices created by this manager and clears its internal tracking state. Call it when the application no longer needs those devices. This method is not available in Scrcpy v2.4.

(since v2.7)
note

See UHID control messages for the low-level protocol messages, or read about the device and its output stream.