HID Library Overview

Introduction

The Human Interface Devices (HID) library provides an API to interface with USB HIDs connected to the Wii U console. The HID library performs attach/detach and asynchronous transactions for HID devices on the external USB bus.

This library is intended to be used for HID driver development by HID device manufacturers. Ensure that you have the appropriate licensing permissions from Nintendo before developing an HID driver.

To use this library, be familiar with the HID specification (USB Device Class Definition for Human Interface Devices (HID)).

Library Flow

To operate a HID device the application must:

  1. Register the client(s) for attach and detach notifications by calling HIDAddClient.
  2. Adopt desired clients during attach notification by checking for an HID class or a specific VID and PID, and/or other attributes of the HID device.
  3. After the device is adopted, use the handle in HIDDevice to perform transactions with the device.
  4. A device may be detached by notification or by unregistering the device by using the HIDClient function to release the device.

Process Switching

HID automatically attach and detach devices to/from clients on process acquire and release foreground respectively. There is no more preparation required by the application other than the usual dynamic attach and detach processing. Ensure that application device references and resources are freed on detach.

Cautions

All transaction data must be aligned and padded to L2_CACHE_LINE_SIZE.

Demo

$cafe/system/src/demo/usb/hid/hid_mouse_keyboard.c

Build and run this program. Attach a USB keyboard or mouse to the CAT-DEV. See input in debug console.

This program performs the following.

  1. Allocates aligned memory for mouse and keyboard transaction data.
  2. Registers HID clients for a mouse and keyboard.
  3. Clients accept HID devices with a correct HID subclass and protocol for mouse and keyboard respectively.
  4. After a matching device is attached, the clients perform HIDSetProtocol and HIDSetIdle and then kick off asynchronous reads for user input.
  5. Asynchronous reads will print input stream to debug when successful, then kick off another read for the next input.
  6. The read loop is broken when a device errors or a device is detached.

This program only accepts one instance each of mouse and keyboard and will not work with multiples.

Revision History

2013/05/08 Automated cleanup pass.


CONFIDENTIAL