<!--
{
  "availability" : [
    "macOS: 15.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreHID",
  "identifier" : "/documentation/CoreHID/HIDVirtualDevice",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core HID"
    ],
    "preciseIdentifier" : "s:7CoreHID16HIDVirtualDeviceC"
  },
  "title" : "HIDVirtualDevice"
}
-->

# HIDVirtualDevice

A virtual service to emulate a HID device connected to the system.

```
actor HIDVirtualDevice
```

## Overview

A HID device is a computer peripheral intended to provide direction to the system from human input. The specification is a broad, industry-wide standard maintained by the [USB Implementers Forum](https://www.usb.org/hid).

A `HIDVirtualDevice` is an object that emulates a HID device connected to the system, without the need for a physical device. Such a tool can be used by an app to emulate a keyboard and dispatch HID reports to the system using [`dispatchInputReport(data:timestamp:)`](/documentation/CoreHID/HIDVirtualDevice/dispatchInputReport(data:timestamp:)) that signify key strokes, and could be received by a [`HIDDeviceClient`](/documentation/CoreHID/HIDDeviceClient)listening for such activity in other apps. The virtual device can also receive requests from the system using its [`HIDVirtualDeviceDelegate`](/documentation/CoreHID/HIDVirtualDeviceDelegate).

## Topics

### Create a HID virtual device

[`init?(properties: HIDVirtualDevice.Properties)`](/documentation/CoreHID/HIDVirtualDevice/init(properties:))

Creates a virtual HID device.

[`let deviceReference: HIDDeviceClient.DeviceReference`](/documentation/CoreHID/HIDVirtualDevice/deviceReference)

The reference to the virtual HID device.

[`func activate(delegate: any HIDVirtualDeviceDelegate)`](/documentation/CoreHID/HIDVirtualDevice/activate(delegate:))

Activate a newly created virtual device to begin receiving notifications and enable functionality.

### Dispatch input reports

[`func dispatchInputReport(data: Data, timestamp: SuspendingClock.Instant) async throws`](/documentation/CoreHID/HIDVirtualDevice/dispatchInputReport(data:timestamp:))

Dispatch an input report to the system.

### Structures

[`struct Properties`](/documentation/CoreHID/HIDVirtualDevice/Properties)

The properties for a virtual HID device.

### Instance Properties

[`var hidDevice: IOHIDUserDevice?`](/documentation/CoreHID/HIDVirtualDevice/hidDevice)

## Relationships

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`Escapable`](/documentation/Swift/Escapable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`Equatable`](/documentation/Swift/Equatable)

[`Actor`](/documentation/Swift/Actor)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Copyable`](/documentation/Swift/Copyable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)