Add comments to the currently completed portions of the incomplete Test and Measureme...
[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 /** HID class-specific Request to get the current HID report from the device. */
65 #define REQ_GetReport 0x01
66
67 /** HID class-specific Request to get the current device idle count. */
68 #define REQ_GetIdle 0x02
69
70 /** HID class-specific Request to set the current HID report to the device. */
71 #define REQ_SetReport 0x09
72
73 /** HID class-specific Request to set the device's idle count. */
74 #define REQ_SetIdle 0x0A
75
76 /** HID class-specific Request to get the current HID report protocol mode. */
77 #define REQ_GetProtocol 0x03
78
79 /** HID class-specific Request to set the current HID report protocol mode. */
80 #define REQ_SetProtocol 0x0B
81
82 /** Descriptor header type value, to indicate a HID class HID descriptor. */
83 #define DTYPE_HID 0x21
84
85 /** Descriptor header type value, to indicate a HID class HID report descriptor. */
86 #define DTYPE_Report 0x22
87
88 /** Constant for the protocol value of a HID interface descriptor, indicating that the interface does not support
89 * any HID class boot protocol (see HID Class Specification).
90 */
91 #define HID_NON_BOOT_PROTOCOL 0x00
92
93 /** Constant for the protocol value of a HID interface descriptor, indicating that the interface supports the
94 * HID class Keyboard boot protocol (see HID Class Specification).
95 */
96 #define HID_BOOT_KEYBOARD_PROTOCOL 0x01
97
98 /** Constant for the protocol value of a HID interface descriptor, indicating that the interface supports the
99 * HID class Mouse boot protocol (see HID Class Specification).
100 */
101 #define HID_BOOT_MOUSE_PROTOCOL 0x02
102
103 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left control key is currently pressed. */
104 #define HID_KEYBOARD_MODIFER_LEFTCTRL (1 << 0)
105
106 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left shift key is currently pressed. */
107 #define HID_KEYBOARD_MODIFER_LEFTSHIFT (1 << 1)
108
109 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left alt key is currently pressed. */
110 #define HID_KEYBOARD_MODIFER_LEFTALT (1 << 2)
111
112 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left GUI key is currently pressed. */
113 #define HID_KEYBOARD_MODIFER_LEFTGUI (1 << 3)
114
115 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right control key is currently pressed. */
116 #define HID_KEYBOARD_MODIFER_RIGHTCTRL (1 << 4)
117
118 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right shift key is currently pressed. */
119 #define HID_KEYBOARD_MODIFER_RIGHTSHIFT (1 << 5)
120
121 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right alt key is currently pressed. */
122 #define HID_KEYBOARD_MODIFER_RIGHTALT (1 << 6)
123
124 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */
125 #define HID_KEYBOARD_MODIFER_RIGHTGUI (1 << 7)
126
127 /** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */
128 #define HID_KEYBOARD_LED_NUMLOCK (1 << 0)
129
130 /** Constant for a keyboard output report LED byte, indicating that the host's CAPS LOCK mode is currently set. */
131 #define HID_KEYBOARD_LED_CAPSLOCK (1 << 1)
132
133 /** Constant for a keyboard output report LED byte, indicating that the host's SCROLL LOCK mode is currently set. */
134 #define HID_KEYBOARD_LED_SCROLLLOCK (1 << 2)
135
136 /** Constant for a keyboard output report LED byte, indicating that the host's KATANA mode is currently set. */
137 #define HID_KEYBOARD_LED_KATANA (1 << 3)
138
139 /* Type Defines: */
140 /** Enum for the different types of HID reports. */
141 enum HID_ReportItemTypes_t
142 {
143 REPORT_ITEM_TYPE_In = 0, /**< Indicates that the item is an IN report type. */
144 REPORT_ITEM_TYPE_Out = 1, /**< Indicates that the item is an OUT report type. */
145 REPORT_ITEM_TYPE_Feature = 2, /**< Indicates that the item is a FEATURE report type. */
146 };
147
148 /** \brief HID class-specific HID Descriptor.
149 *
150 * Type define for the HID class-specific HID descriptor, to describe the HID device's specifications. Refer to the HID
151 * specification for details on the structure elements.
152 */
153 typedef struct
154 {
155 USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
156
157 uint16_t HIDSpec; /**< BCD encoded version that the HID descriptor and device complies to. */
158 uint8_t CountryCode; /**< Country code of the localized device, or zero if universal. */
159
160 uint8_t TotalReportDescriptors; /**< Total number of HID report descriptors for the interface. */
161
162 uint8_t HIDReportType; /**< Type of HID report, set to \ref DTYPE_Report. */
163 uint16_t HIDReportLength; /**< Length of the associated HID report descriptor, in bytes. */
164 } USB_HID_Descriptor_t;
165
166 /** \brief Standard HID Boot Protocol Mouse Report.
167 *
168 * Type define for a standard Boot Protocol Mouse report
169 */
170 typedef struct
171 {
172 uint8_t Button; /**< Button mask for currently pressed buttons in the mouse. */
173 int8_t X; /**< Current delta X movement of the mouse. */
174 int8_t Y; /**< Current delta Y movement on the mouse. */
175 } USB_MouseReport_Data_t;
176
177 /** \brief Standard HID Boot Protocol Keyboard Report.
178 *
179 * Type define for a standard Boot Protocol Keyboard report
180 */
181 typedef struct
182 {
183 uint8_t Modifier; /**< Keyboard modifier byte, indicating pressed modifier keys (a combination of
184 * HID_KEYBOARD_MODIFER_* masks).
185 */
186 uint8_t Reserved; /**< Reserved for OEM use, always set to 0. */
187 uint8_t KeyCode[6]; /**< Key codes of the currently pressed keys. */
188 } USB_KeyboardReport_Data_t;
189
190 /** Type define for the data type used to store HID report descriptor elements. */
191 typedef uint8_t USB_Descriptor_HIDReport_Datatype_t;
192
193 #endif
194
195 /** @} */