Supporting human interface devices (XAML)

[This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation]

The Windows.Devices.HumanInterfaceDevice API lets your Windows Runtime app access devices that support the Human Interface Device (HID) protocol.

When it was first developed, the protocol targeted devices like: keyboards, mice, and joysticks. It was initially designed to run over the USB transport. Today the protocol supports a significantly larger set of devices. In addition, for Windows 8.1, Microsoft includes support for the USB, Bluetooth, Bluetooth LE, and I2C transports.

The new API is intended for two distinct audiences:

  1. Hardware partners who create a HID peripheral and need a Windows Runtime app for their device. (IHVs can declare one app as automatically acquired when a user connects their peripheral.)
  2. App developers who want to build apps for these peripherals

The hardware partner is already familiar with HID but needs to understand the requirements of Windows Runtime apps. The app developer will likely need to learn the protocol. If you are new to the HID protocol and concepts like: feature reports, input reports, and output reports, you can find more information here.

The following short video describes an end-to-end sample solution for HID that's available for download on the MSDN samples gallery. (This solution includes a sample app created using the HID WinRT API.)

Before using this API, please review the Limitations section below to understand if there are any limitations which may prevent you from achieving any of your goals.

Limitations of the HID API

The Windows.Devices.HumanInterfaceDevice API supports most HID devices. However, it blocks the top-level application collection represented by the following usage pages, to prevent conflict with other Windows APIs and OS behavior:

  • HID_USAGE_PAGE_UNDEFINED
  • HID_USAGE_PAGE_GENERIC
  • HID_USAGE_GENERIC_KEYBOARD
  • HID_USAGE_GENERIC_KEYPAD
  • HID_USAGE_GENERIC_SYSTEM_CTL
  • HID_USAGE_PAGE_KEYBOARD
  • HID_USAGE_PAGE_CONSUMER
  • HID_USAGE_PAGE_DIGITIZER
  • HID_USAGE_PAGE_SENSOR
  • HID_USAGE_PAGE_BARCODE_SCANNER
  • HID_USAGE_PAGE_WEIGHING_DEVICE
  • HID_USAGE_PAGE_MAGNETIC_STRIPE_READER
  • HID_USAGE_PAGE_TELEPHONY

In addition to blocking support for the previous list of usage pages, the API also requires that your application run over the inbox drivers that ship with Windows 8.1. The API does not support vendor-supplied device drivers.

Designed for Peripherals

The HID API is primarily designed for accessing peripheral devices. The app developer scenario described earlier will only work for these devices.

OEMs can use the API access PC internal HID devices. However, this access is limited to a privileged app that is explicitly declared by the device manufacturer.

Not designed for Control Panel application scenarios

The HID Windows Runtime API is primarily designed for being accessed by Windows Runtime apps which are per-user apps. These apps can communicate with a HID device using this API, however there is no way for such an app to save settings outside of the scope of that app that are recognized by Windows, required for many Control Panel applications.

Requirements for Windows Phone Store apps

Windows Phone Store apps can access the Windows.Devices.HumanInterfaceDevice API if the manufacturer supported the HID protocol for specific devices and provided corresponding device-data to app developers. Refer to your manufacturer’s documentation for a list of supported HID devices as well as the data that you’ll need to implement device discovery.

Sample Windows Runtime app for HID

Windows.Devices.HumanInterfaceDevice