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 /** \name Keyboard Standard Report Modifier Masks */
66 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left control key is currently pressed. */
67 #define HID_KEYBOARD_MODIFER_LEFTCTRL (1 << 0)
69 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left shift key is currently pressed. */
70 #define HID_KEYBOARD_MODIFER_LEFTSHIFT (1 << 1)
72 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left alt key is currently pressed. */
73 #define HID_KEYBOARD_MODIFER_LEFTALT (1 << 2)
75 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left GUI key is currently pressed. */
76 #define HID_KEYBOARD_MODIFER_LEFTGUI (1 << 3)
78 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right control key is currently pressed. */
79 #define HID_KEYBOARD_MODIFER_RIGHTCTRL (1 << 4)
81 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right shift key is currently pressed. */
82 #define HID_KEYBOARD_MODIFER_RIGHTSHIFT (1 << 5)
84 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right alt key is currently pressed. */
85 #define HID_KEYBOARD_MODIFER_RIGHTALT (1 << 6)
87 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */
88 #define HID_KEYBOARD_MODIFER_RIGHTGUI (1 << 7)
91 /** \name Keyboard Standard Report LED Masks */
93 /** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */
94 #define HID_KEYBOARD_LED_NUMLOCK (1 << 0)
96 /** Constant for a keyboard output report LED byte, indicating that the host's CAPS LOCK mode is currently set. */
97 #define HID_KEYBOARD_LED_CAPSLOCK (1 << 1)
99 /** Constant for a keyboard output report LED byte, indicating that the host's SCROLL LOCK mode is currently set. */
100 #define HID_KEYBOARD_LED_SCROLLLOCK (1 << 2)
102 /** Constant for a keyboard output report LED byte, indicating that the host's KATANA mode is currently set. */
103 #define HID_KEYBOARD_LED_KATANA (1 << 3)
107 /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the HID
110 enum HID_Descriptor_ClassSubclassProtocol_t
112 HID_CSCP_HIDClass
= 0x03, /**< Descriptor Class value indicating that the device or interface
113 * belongs to the HID class.
115 HID_CSCP_NonBootSubclass
= 0x00, /**< Descriptor Subclass value indicating that the device or interface
116 * does not implement a HID boot protocol.
118 HID_CSCP_BootSubclass
= 0x01, /**< Descriptor Subclass value indicating that the device or interface
119 * implements a HID boot protocol.
121 HID_CSCP_NonBootProtocol
= 0x00, /**< Descriptor Protocol value indicating that the device or interface
122 * does not belong to a HID boot protocol.
124 HID_CSCP_KeyboardBootProtocol
= 0x01, /**< Descriptor Protocol value indicating that the device or interface
125 * belongs to the Keyboard HID boot protocol.
127 HID_CSCP_MouseBootProtocol
= 0x02, /**< Descriptor Protocol value indicating that the device or interface
128 * belongs to the Mouse HID boot protocol.
132 /** Enum for the HID class specific control requests that can be issued by the USB bus host. */
133 enum HID_ClassRequests_t
135 HID_REQ_GetReport
= 0x01, /**< HID class-specific Request to get the current HID report from the device. */
136 HID_REQ_GetIdle
= 0x02, /**< HID class-specific Request to get the current device idle count. */
137 HID_REQ_SetReport
= 0x09, /**< HID class-specific Request to set the current HID report to the device. */
138 HID_REQ_SetIdle
= 0x0A, /**< HID class-specific Request to set the device's idle count. */
139 HID_REQ_GetProtocol
= 0x03, /**< HID class-specific Request to get the current HID report protocol mode. */
140 HID_REQ_SetProtocol
= 0x0B, /**< HID class-specific Request to set the current HID report protocol mode. */
143 /** Enum for the HID class specific descriptor types. */
144 enum HID_DescriptorTypes_t
146 HID_DTYPE_HID
= 0x21, /**< Descriptor header type value, to indicate a HID class HID descriptor. */
147 HID_DTYPE_Report
= 0x22, /**< Descriptor header type value, to indicate a HID class HID report descriptor. */
150 /** Enum for the different types of HID reports. */
151 enum HID_ReportItemTypes_t
153 HID_REPORT_ITEM_In
= 0, /**< Indicates that the item is an IN report type. */
154 HID_REPORT_ITEM_Out
= 1, /**< Indicates that the item is an OUT report type. */
155 HID_REPORT_ITEM_Feature
= 2, /**< Indicates that the item is a FEATURE report type. */
158 /** \brief HID class-specific HID Descriptor (LUFA naming conventions).
160 * Type define for the HID class-specific HID descriptor, to describe the HID device's specifications. Refer to the HID
161 * specification for details on the structure elements.
163 * \see \ref USB_HID_StdDescriptor_HID_t for the version of this type with standard element names.
167 USB_Descriptor_Header_t Header
; /**< Regular descriptor header containing the descriptor's type and length. */
169 uint16_t HIDSpec
; /**< BCD encoded version that the HID descriptor and device complies to. */
170 uint8_t CountryCode
; /**< Country code of the localized device, or zero if universal. */
172 uint8_t TotalReportDescriptors
; /**< Total number of HID report descriptors for the interface. */
174 uint8_t HIDReportType
; /**< Type of HID report, set to \ref HID_DTYPE_Report. */
175 uint16_t HIDReportLength
; /**< Length of the associated HID report descriptor, in bytes. */
176 } USB_HID_Descriptor_HID_t
;
178 /** \brief HID class-specific HID Descriptor (USB-IF naming conventions).
180 * Type define for the HID class-specific HID descriptor, to describe the HID device's specifications. Refer to the HID
181 * specification for details on the structure elements.
183 * \see \ref USB_HID_Descriptor_HID_t for the version of this type with non-standard LUFA specific
188 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
189 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
190 * given by the specific class.
193 uint16_t bcdHID
; /**< BCD encoded version that the HID descriptor and device complies to. */
194 uint8_t bCountryCode
; /**< Country code of the localized device, or zero if universal. */
196 uint8_t bNumDescriptors
; /**< Total number of HID report descriptors for the interface. */
198 uint8_t bDescriptorType2
; /**< Type of HID report, set to \ref HID_DTYPE_Report. */
199 uint16_t wDescriptorLength
; /**< Length of the associated HID report descriptor, in bytes. */
200 } USB_HID_StdDescriptor_HID_t
;
202 /** \brief Standard HID Boot Protocol Mouse Report.
204 * Type define for a standard Boot Protocol Mouse report
208 uint8_t Button
; /**< Button mask for currently pressed buttons in the mouse. */
209 int8_t X
; /**< Current delta X movement of the mouse. */
210 int8_t Y
; /**< Current delta Y movement on the mouse. */
211 } USB_MouseReport_Data_t
;
213 /** \brief Standard HID Boot Protocol Keyboard Report.
215 * Type define for a standard Boot Protocol Keyboard report
219 uint8_t Modifier
; /**< Keyboard modifier byte, indicating pressed modifier keys (a combination of
220 * HID_KEYBOARD_MODIFER_* masks).
222 uint8_t Reserved
; /**< Reserved for OEM use, always set to 0. */
223 uint8_t KeyCode
[6]; /**< Key codes of the currently pressed keys. */
224 } USB_KeyboardReport_Data_t
;
226 /** Type define for the data type used to store HID report descriptor elements. */
227 typedef uint8_t USB_Descriptor_HIDReport_Datatype_t
;