Fixed LowLevel JoystickHostWithParser demo not saving the chosen HID interface's...
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Common / HID.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2010.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
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.
20
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
28 this software.
29 */
30
31 /** \file
32 * \brief Common definitions and declarations for the library USB HID Class driver.
33 *
34 * Common definitions and declarations for the library USB HID Class driver.
35 *
36 * \note This file should not be included directly. It is automatically included as needed by the class driver
37 * dispatch header located in LUFA/Drivers/USB/Class/HID.h.
38 */
39
40 /** \ingroup Group_USBClassHID
41 * @defgroup Group_USBClassHIDCommon Common Class Definitions
42 *
43 * \section Module Description
44 * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
45 * HID Class.
46 *
47 * @{
48 */
49
50 #ifndef _HID_CLASS_COMMON_H_
51 #define _HID_CLASS_COMMON_H_
52
53 /* Includes: */
54 #include "../../USB.h"
55
56 #include <string.h>
57
58 /* Preprocessor Checks: */
59 #if !defined(__INCLUDE_FROM_HID_DRIVER)
60 #error Do not include this file directly. Include LUFA/Drivers/Class/HID.h instead.
61 #endif
62
63 /* Macros: */
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)
66
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)
69
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)
72
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)
75
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)
78
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)
81
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)
84
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)
87
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)
90
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)
93
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)
96
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)
99
100 /* Type Defines: */
101 /** Enum for the HID class specific control requests that can be issued by the USB bus host. */
102 enum HID_ClassRequests_t
103 {
104 HID_REQ_GetReport = 0x01, /**< HID class-specific Request to get the current HID report from the device. */
105 HID_REQ_GetIdle = 0x02, /**< HID class-specific Request to get the current device idle count. */
106 HID_REQ_SetReport = 0x09, /**< HID class-specific Request to set the current HID report to the device. */
107 HID_REQ_SetIdle = 0x0A, /**< HID class-specific Request to set the device's idle count. */
108 HID_REQ_GetProtocol = 0x03, /**< HID class-specific Request to get the current HID report protocol mode. */
109 HID_REQ_SetProtocol = 0x0B, /**< HID class-specific Request to set the current HID report protocol mode. */
110 };
111
112 /** Enum for the HID class specific descriptor types. */
113 enum HID_DescriptorTypes_t
114 {
115 HID_DTYPE_HID = 0x21, /**< Descriptor header type value, to indicate a HID class HID descriptor. */
116 HID_DTYPE_Report = 0x22, /**< Descriptor header type value, to indicate a HID class HID report descriptor. */
117 };
118
119 /** Enum for the HID class boot protocols that may be supported by HID devices. */
120 enum HID_BootProtocols_t
121 {
122 HID_BOOTP_NonBootProtocol = 0x00, /**< Constant for the protocol value of a HID interface descriptor, indicating
123 * that the interface does not support any HID class boot protocol (see HID
124 * Class Specification).
125 */
126 HID_BOOTP_KeyboardBootProtocol = 0x01, /**< Constant for the protocol value of a HID interface descriptor, indicating
127 * that the interface supports the HID class Keyboard boot protocol (see HID
128 * Class Specification).
129 */
130 HID_BOOTP_MouseBootProtocol = 0x02, /**< Constant for the protocol value of a HID interface descriptor, indicating
131 * that the interface supports the HID class Mouse boot protocol (see HID Class
132 * Specification).
133 */
134 };
135
136 /** Enum for the different types of HID reports. */
137 enum HID_ReportItemTypes_t
138 {
139 HID_REPORT_ITEM_In = 0, /**< Indicates that the item is an IN report type. */
140 HID_REPORT_ITEM_Out = 1, /**< Indicates that the item is an OUT report type. */
141 HID_REPORT_ITEM_Feature = 2, /**< Indicates that the item is a FEATURE report type. */
142 };
143
144 /** \brief HID class-specific HID Descriptor (LUFA naming conventions).
145 *
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.
148 *
149 * \see \ref USB_HID_StdDescriptor_HID_t for the version of this type with standard element names.
150 */
151 typedef struct
152 {
153 USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
154
155 uint16_t HIDSpec; /**< BCD encoded version that the HID descriptor and device complies to. */
156 uint8_t CountryCode; /**< Country code of the localized device, or zero if universal. */
157
158 uint8_t TotalReportDescriptors; /**< Total number of HID report descriptors for the interface. */
159
160 uint8_t HIDReportType; /**< Type of HID report, set to \ref HID_DTYPE_Report. */
161 uint16_t HIDReportLength; /**< Length of the associated HID report descriptor, in bytes. */
162 } USB_HID_Descriptor_HID_t;
163
164 /** \brief HID class-specific HID Descriptor (USB-IF naming conventions).
165 *
166 * Type define for the HID class-specific HID descriptor, to describe the HID device's specifications. Refer to the HID
167 * specification for details on the structure elements.
168 *
169 * \see \ref USB_HID_Descriptor_HID_t for the version of this type with non-standard LUFA specific
170 * element names.
171 */
172 typedef struct
173 {
174 uint8_t bLength; /**< Size of the descriptor, in bytes. */
175 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
176 * given by the specific class.
177 */
178
179 uint16_t bcdHID; /**< BCD encoded version that the HID descriptor and device complies to. */
180 uint8_t bCountryCode; /**< Country code of the localized device, or zero if universal. */
181
182 uint8_t bNumDescriptors; /**< Total number of HID report descriptors for the interface. */
183
184 uint8_t bDescriptorType2; /**< Type of HID report, set to \ref HID_DTYPE_Report. */
185 uint16_t wDescriptorLength; /**< Length of the associated HID report descriptor, in bytes. */
186 } USB_HID_StdDescriptor_HID_t;
187
188 /** \brief Standard HID Boot Protocol Mouse Report.
189 *
190 * Type define for a standard Boot Protocol Mouse report
191 */
192 typedef struct
193 {
194 uint8_t Button; /**< Button mask for currently pressed buttons in the mouse. */
195 int8_t X; /**< Current delta X movement of the mouse. */
196 int8_t Y; /**< Current delta Y movement on the mouse. */
197 } USB_MouseReport_Data_t;
198
199 /** \brief Standard HID Boot Protocol Keyboard Report.
200 *
201 * Type define for a standard Boot Protocol Keyboard report
202 */
203 typedef struct
204 {
205 uint8_t Modifier; /**< Keyboard modifier byte, indicating pressed modifier keys (a combination of
206 * HID_KEYBOARD_MODIFER_* masks).
207 */
208 uint8_t Reserved; /**< Reserved for OEM use, always set to 0. */
209 uint8_t KeyCode[6]; /**< Key codes of the currently pressed keys. */
210 } USB_KeyboardReport_Data_t;
211
212 /** Type define for the data type used to store HID report descriptor elements. */
213 typedef uint8_t USB_Descriptor_HIDReport_Datatype_t;
214
215 #endif
216
217 /** @} */