3 Copyright (C) Dean Camera, 2010.
5 dean [at] fourwalledcubicle [dot] 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 * Common definitions and declarations for the library USB HID Class driver.
36 * \note This file should not be included directly. It is automatically included as needed by the USB module driver
37 * dispatch header located in LUFA/Drivers/USB.h.
40 /** \ingroup Group_USBClassHID
41 * @defgroup Group_USBClassHIDCommon Common Class Definitions
43 * \section Module Description
44 * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
50 #ifndef _HID_CLASS_COMMON_H_
51 #define _HID_CLASS_COMMON_H_
54 #include "../../HighLevel/StdDescriptors.h"
58 /* Preprocessor Checks: */
59 #if !defined(__INCLUDE_FROM_HID_DRIVER)
60 #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
64 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left control key is currently pressed. */
65 #define HID_KEYBOARD_MODIFER_LEFTCTRL (1 << 0)
67 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left shift key is currently pressed. */
68 #define HID_KEYBOARD_MODIFER_LEFTSHIFT (1 << 1)
70 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left alt key is currently pressed. */
71 #define HID_KEYBOARD_MODIFER_LEFTALT (1 << 2)
73 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left GUI key is currently pressed. */
74 #define HID_KEYBOARD_MODIFER_LEFTGUI (1 << 3)
76 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right control key is currently pressed. */
77 #define HID_KEYBOARD_MODIFER_RIGHTCTRL (1 << 4)
79 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right shift key is currently pressed. */
80 #define HID_KEYBOARD_MODIFER_RIGHTSHIFT (1 << 5)
82 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right alt key is currently pressed. */
83 #define HID_KEYBOARD_MODIFER_RIGHTALT (1 << 6)
85 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */
86 #define HID_KEYBOARD_MODIFER_RIGHTGUI (1 << 7)
88 /** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */
89 #define HID_KEYBOARD_LED_NUMLOCK (1 << 0)
91 /** Constant for a keyboard output report LED byte, indicating that the host's CAPS LOCK mode is currently set. */
92 #define HID_KEYBOARD_LED_CAPSLOCK (1 << 1)
94 /** Constant for a keyboard output report LED byte, indicating that the host's SCROLL LOCK mode is currently set. */
95 #define HID_KEYBOARD_LED_SCROLLLOCK (1 << 2)
97 /** Constant for a keyboard output report LED byte, indicating that the host's KATANA mode is currently set. */
98 #define HID_KEYBOARD_LED_KATANA (1 << 3)
101 /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the HID
104 enum HID_Descriptor_ClassSubclassProtocol_t
106 HID_CSCP_HIDClass
= 0x03, /**< Descriptor Class value indicating that the device or interface
107 * belongs to the HID class.
109 HID_CSCP_NonBootSubclass
= 0x00, /**< Descriptor Subclass value indicating that the device or interface
110 * does not implement a HID boot protocol.
112 HID_CSCP_BootSubclass
= 0x01, /**< Descriptor Subclass value indicating that the device or interface
113 * implements a HID boot protocol.
115 HID_CSCP_NonBootProtocol
= 0x00, /**< Descriptor Protocol value indicating that the device or interface
116 * does not belong to a HID boot protocol.
118 HID_CSCP_KeyboardBootProtocol
= 0x01, /**< Descriptor Protocol value indicating that the device or interface
119 * belongs to the Keyboard HID boot protocol.
121 HID_CSCP_MouseBootProtocol
= 0x02, /**< Descriptor Protocol value indicating that the device or interface
122 * belongs to the Mouse HID boot protocol.
126 /** Enum for the HID class specific control requests that can be issued by the USB bus host. */
127 enum HID_ClassRequests_t
129 HID_REQ_GetReport
= 0x01, /**< HID class-specific Request to get the current HID report from the device. */
130 HID_REQ_GetIdle
= 0x02, /**< HID class-specific Request to get the current device idle count. */
131 HID_REQ_SetReport
= 0x09, /**< HID class-specific Request to set the current HID report to the device. */
132 HID_REQ_SetIdle
= 0x0A, /**< HID class-specific Request to set the device's idle count. */
133 HID_REQ_GetProtocol
= 0x03, /**< HID class-specific Request to get the current HID report protocol mode. */
134 HID_REQ_SetProtocol
= 0x0B, /**< HID class-specific Request to set the current HID report protocol mode. */
137 /** Enum for the HID class specific descriptor types. */
138 enum HID_DescriptorTypes_t
140 HID_DTYPE_HID
= 0x21, /**< Descriptor header type value, to indicate a HID class HID descriptor. */
141 HID_DTYPE_Report
= 0x22, /**< Descriptor header type value, to indicate a HID class HID report descriptor. */
144 /** Enum for the different types of HID reports. */
145 enum HID_ReportItemTypes_t
147 HID_REPORT_ITEM_In
= 0, /**< Indicates that the item is an IN report type. */
148 HID_REPORT_ITEM_Out
= 1, /**< Indicates that the item is an OUT report type. */
149 HID_REPORT_ITEM_Feature
= 2, /**< Indicates that the item is a FEATURE report type. */
152 /** \brief HID class-specific HID Descriptor (LUFA naming conventions).
154 * Type define for the HID class-specific HID descriptor, to describe the HID device's specifications. Refer to the HID
155 * specification for details on the structure elements.
157 * \see \ref USB_HID_StdDescriptor_HID_t for the version of this type with standard element names.
161 USB_Descriptor_Header_t Header
; /**< Regular descriptor header containing the descriptor's type and length. */
163 uint16_t HIDSpec
; /**< BCD encoded version that the HID descriptor and device complies to. */
164 uint8_t CountryCode
; /**< Country code of the localized device, or zero if universal. */
166 uint8_t TotalReportDescriptors
; /**< Total number of HID report descriptors for the interface. */
168 uint8_t HIDReportType
; /**< Type of HID report, set to \ref HID_DTYPE_Report. */
169 uint16_t HIDReportLength
; /**< Length of the associated HID report descriptor, in bytes. */
170 } USB_HID_Descriptor_HID_t
;
172 /** \brief HID class-specific HID Descriptor (USB-IF naming conventions).
174 * Type define for the HID class-specific HID descriptor, to describe the HID device's specifications. Refer to the HID
175 * specification for details on the structure elements.
177 * \see \ref USB_HID_Descriptor_HID_t for the version of this type with non-standard LUFA specific
182 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
183 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
184 * given by the specific class.
187 uint16_t bcdHID
; /**< BCD encoded version that the HID descriptor and device complies to. */
188 uint8_t bCountryCode
; /**< Country code of the localized device, or zero if universal. */
190 uint8_t bNumDescriptors
; /**< Total number of HID report descriptors for the interface. */
192 uint8_t bDescriptorType2
; /**< Type of HID report, set to \ref HID_DTYPE_Report. */
193 uint16_t wDescriptorLength
; /**< Length of the associated HID report descriptor, in bytes. */
194 } USB_HID_StdDescriptor_HID_t
;
196 /** \brief Standard HID Boot Protocol Mouse Report.
198 * Type define for a standard Boot Protocol Mouse report
202 uint8_t Button
; /**< Button mask for currently pressed buttons in the mouse. */
203 int8_t X
; /**< Current delta X movement of the mouse. */
204 int8_t Y
; /**< Current delta Y movement on the mouse. */
205 } USB_MouseReport_Data_t
;
207 /** \brief Standard HID Boot Protocol Keyboard Report.
209 * Type define for a standard Boot Protocol Keyboard report
213 uint8_t Modifier
; /**< Keyboard modifier byte, indicating pressed modifier keys (a combination of
214 * HID_KEYBOARD_MODIFER_* masks).
216 uint8_t Reserved
; /**< Reserved for OEM use, always set to 0. */
217 uint8_t KeyCode
[6]; /**< Key codes of the currently pressed keys. */
218 } USB_KeyboardReport_Data_t
;
220 /** Type define for the data type used to store HID report descriptor elements. */
221 typedef uint8_t USB_Descriptor_HIDReport_Datatype_t
;