Use HID for a custom PC control panel, a keyboard, a mouse or another input device. Start by choosing the report layout below, then follow the task that fits your project.

Select the HID profile that matches your project. For your own PC program, start with HID data; for keys or movement, choose the matching input profile.

Windows can list HID data as an Input device. Seeing the device is the first check; sending a command and checking its reply tests the application as well.
HID sends and receives small blocks called reports. Your PIC and PC program must agree on what each byte means.
In the Device tool, choose HID, then select a HID usage profile. Choose HID data for your own PC program. To make a keyboard, mouse or other listed input device, choose that profile instead.
|
Profile |
PIC-to-PC report |
PC-to-PIC report |
|
|
HID data |
0 |
Configurable; normally 64 bytes |
Configurable; normally 64 bytes |
|
Boot keyboard |
1 |
8 bytes |
1 byte: keyboard LEDs |
|
Boot mouse |
2 |
3 bytes: buttons, X, Y |
None |
|
Joystick |
3 |
6 bytes: four axes, 16 buttons |
None |
|
Consumer control |
4 |
2 bytes: one media-control usage |
None |
|
Custom descriptor |
5 |
Must match your descriptor |
Must match your descriptor |
The tool fills the fixed profiles' sizes for you. Mouse, joystick and consumer profiles retain USB_RX_SIZE=1 as a storage placeholder; this does not provide a receive endpoint. The supplied mouse profile has no wheel byte.
HID always uses USB interrupt transfers. This is the USB transfer type; it is separate from your choice of polling or an interrupt handler in the PIC.
The IN/OUT intervals tell the PC how often it can check those endpoints, in milliseconds. They do not run your code or send a new report automatically. Every HID write must contain exactly USB_TX_SIZE bytes. A shorter write returns USB_BAD_LENGTH.
For HID data, start with these defaults unless the PC application needs other identifiers:
|
HID option |
Meaning and normal choice |
|
Usage page — USB_HID_USAGE_PAGE |
Group of HID meanings. $FF00 is vendor-defined and suitable for your own data protocol. |
|
Application usage — USB_HID_USAGE |
Identifies the collection; default 1. |
|
Input usage — USB_HID_INPUT_USAGE |
Labels PIC-to-PC data; default 2. |
|
Output usage — USB_HID_OUTPUT_USAGE |
Labels PC-to-PIC data; default 3. |
|
Feature usage — USB_HID_FEATURE_USAGE |
Labels optional configuration/status data; default 4. |
|
HID version — USB_HID_BCD |
Normally 1.11. The tool converts the entered version to its descriptor encoding. |
|
Hardware localization — USB_HID_COUNTRY |
Normally Not localized. This is separate from descriptor string language and the PC's keyboard layout. |
Usage numbers label the data in the USB description. The library does not add them to your messages. To make a keyboard, select Boot keyboard; changing a usage number on its own is not enough. The fixed profiles already supply their own usage numbers.
HID Data → PC Host App contains the Visual Basic/WPF source for a basic test app. Follow Build the Windows test apps, then Use the HID test app to match its identifiers and report sizes to your HID data firmware.

Created with the Personal Edition of HelpNDoc: Maximize Your Documentation Capabilities with HelpNDoc's Project Analyzer