3 Copyright (C) Dean Camera, 2010.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
12 Permission to use, copy, modify, distribute, and sell this
13 software and its documentation for any purpose is hereby granted
14 without fee, provided that the above copyright notice appear in
15 all copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
32 * \brief Common definitions and declarations for the library USB HID Class driver.
34 * \note This file should not be included directly. It is automatically included as needed by the class driver
35 * dispatch header located in LUFA/Drivers/USB/Class/HID.h.
38 /** \ingroup Group_USBClassHID
39 * @defgroup Group_USBClassHIDCommon Common Class Definitions
41 * \section Module Description
42 * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
48 #ifndef _HID_CLASS_COMMON_H_
49 #define _HID_CLASS_COMMON_H_
52 #include "../../USB.h"
56 /* Preprocessor Checks: */
57 #if !defined(__INCLUDE_FROM_HID_DRIVER)
58 #error Do not include this file directly. Include LUFA/Drivers/Class/HID.h instead.
62 /** HID Class Specific Request to get the current HID report from the device. */
63 #define REQ_GetReport 0x01
65 /** HID Class Specific Request to get the current device idle count. */
66 #define REQ_GetIdle 0x02
68 /** HID Class Specific Request to set the current HID report to the device. */
69 #define REQ_SetReport 0x09
71 /** HID Class Specific Request to set the device's idle count. */
72 #define REQ_SetIdle 0x0A
74 /** HID Class Specific Request to get the current HID report protocol mode. */
75 #define REQ_GetProtocol 0x03
77 /** HID Class Specific Request to set the current HID report protocol mode. */
78 #define REQ_SetProtocol 0x0B
80 /** Descriptor header type value, to indicate a HID class HID descriptor. */
81 #define DTYPE_HID 0x21
83 /** Descriptor header type value, to indicate a HID class HID report descriptor. */
84 #define DTYPE_Report 0x22
86 /** Constant for the protocol value of a HID interface descriptor, indicating that the interface does not support
87 * any HID class boot protocol (see HID Class Specification).
89 #define HID_NON_BOOT_PROTOCOL 0x00
91 /** Constant for the protocol value of a HID interface descriptor, indicating that the interface supports the
92 * HID class Keyboard boot protocol (see HID Class Specification).
94 #define HID_BOOT_KEYBOARD_PROTOCOL 0x01
96 /** Constant for the protocol value of a HID interface descriptor, indicating that the interface supports the
97 * HID class Mouse boot protocol (see HID Class Specification).
99 #define HID_BOOT_MOUSE_PROTOCOL 0x02
101 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left control key is currently pressed. */
102 #define HID_KEYBOARD_MODIFER_LEFTCTRL (1 << 0)
104 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left shift key is currently pressed. */
105 #define HID_KEYBOARD_MODIFER_LEFTSHIFT (1 << 1)
107 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left alt key is currently pressed. */
108 #define HID_KEYBOARD_MODIFER_LEFTALT (1 << 2)
110 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left GUI key is currently pressed. */
111 #define HID_KEYBOARD_MODIFER_LEFTGUI (1 << 3)
113 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right control key is currently pressed. */
114 #define HID_KEYBOARD_MODIFER_RIGHTCTRL (1 << 4)
116 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right shift key is currently pressed. */
117 #define HID_KEYBOARD_MODIFER_RIGHTSHIFT (1 << 5)
119 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right alt key is currently pressed. */
120 #define HID_KEYBOARD_MODIFER_RIGHTALT (1 << 6)
122 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */
123 #define HID_KEYBOARD_MODIFER_RIGHTGUI (1 << 7)
125 /** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */
126 #define HID_KEYBOARD_LED_NUMLOCK (1 << 0)
128 /** Constant for a keyboard output report LED byte, indicating that the host's CAPS LOCK mode is currently set. */
129 #define HID_KEYBOARD_LED_CAPSLOCK (1 << 1)
131 /** Constant for a keyboard output report LED byte, indicating that the host's SCROLL LOCK mode is currently set. */
132 #define HID_KEYBOARD_LED_SCROLLLOCK (1 << 2)
134 /** Constant for a keyboard output report LED byte, indicating that the host's KATANA mode is currently set. */
135 #define HID_KEYBOARD_LED_KATANA (1 << 3)
138 /** Enum for the different types of HID reports. */
139 enum HID_ReportItemTypes_t
141 REPORT_ITEM_TYPE_In
= 0, /**< Indicates that the item is an IN report type. */
142 REPORT_ITEM_TYPE_Out
= 1, /**< Indicates that the item is an OUT report type. */
143 REPORT_ITEM_TYPE_Feature
= 2, /**< Indicates that the item is a FEATURE report type. */
146 /** Type define for the HID class specific HID descriptor, to describe the HID device's specifications. Refer to the HID
147 * specification for details on the structure elements.
151 USB_Descriptor_Header_t Header
;
156 uint8_t TotalReportDescriptors
;
158 uint8_t HIDReportType
;
159 uint16_t HIDReportLength
;
160 } USB_HID_Descriptor_t
;
162 /** Type define for a standard Boot Protocol Mouse report */
165 uint8_t Button
; /**< Button mask for currently pressed buttons in the mouse */
166 int8_t X
; /**< Current delta X movement of the mouse */
167 int8_t Y
; /**< Current delta Y movement on the mouse */
168 } USB_MouseReport_Data_t
;
170 /** Type define for a standard Boot Protocol Keyboard report */
173 uint8_t Modifier
; /**< Keyboard modifier byte, indicating pressed modifier keys (a combination of
174 * HID_KEYBOARD_MODIFER_* masks)
176 uint8_t Reserved
; /**< Reserved for OEM use, always set to 0 */
177 uint8_t KeyCode
[6]; /**< Key codes of the currently pressed keys */
178 } USB_KeyboardReport_Data_t
;
180 /** Type define for the data type used to store HID report descriptor elements. */
181 typedef uint8_t USB_Descriptor_HIDReport_Datatype_t
;