]> git.gir.st - tmk_keyboard.git/blob - protocol/lufa/descriptor.h
Change TOP_DIR to TMK_DIR in makefiles
[tmk_keyboard.git] / protocol / lufa / descriptor.h
1 /*
2 * Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
3 * This file is based on:
4 * LUFA-120219/Demos/Device/Lowlevel/KeyboardMouse
5 * LUFA-120219/Demos/Device/Lowlevel/GenericHID
6 */
7
8 /*
9 LUFA Library
10 Copyright (C) Dean Camera, 2012.
11
12 dean [at] fourwalledcubicle [dot] com
13 www.lufa-lib.org
14 */
15
16 /*
17 Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
18 Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
19
20 Permission to use, copy, modify, distribute, and sell this
21 software and its documentation for any purpose is hereby granted
22 without fee, provided that the above copyright notice appear in
23 all copies and that both that the copyright notice and this
24 permission notice and warranty disclaimer appear in supporting
25 documentation, and that the name of the author not be used in
26 advertising or publicity pertaining to distribution of the
27 software without specific, written prior permission.
28
29 The author disclaim all warranties with regard to this
30 software, including all implied warranties of merchantability
31 and fitness. In no event shall the author be liable for any
32 special, indirect or consequential damages or any damages
33 whatsoever resulting from loss of use, data or profits, whether
34 in an action of contract, negligence or other tortious action,
35 arising out of or in connection with the use or performance of
36 this software.
37 */
38
39 /** \file
40 *
41 * Header file for Descriptors.c.
42 */
43
44 #ifndef _DESCRIPTORS_H_
45 #define _DESCRIPTORS_H_
46
47 #include <LUFA/Drivers/USB/USB.h>
48 #include <avr/pgmspace.h>
49
50
51 typedef struct
52 {
53 USB_Descriptor_Configuration_Header_t Config;
54
55 // Keyboard HID Interface
56 USB_Descriptor_Interface_t Keyboard_Interface;
57 USB_HID_Descriptor_HID_t Keyboard_HID;
58 USB_Descriptor_Endpoint_t Keyboard_INEndpoint;
59
60 #ifdef MOUSE_ENABLE
61 // Mouse HID Interface
62 USB_Descriptor_Interface_t Mouse_Interface;
63 USB_HID_Descriptor_HID_t Mouse_HID;
64 USB_Descriptor_Endpoint_t Mouse_INEndpoint;
65 #endif
66
67 #ifdef EXTRAKEY_ENABLE
68 // Extrakey HID Interface
69 USB_Descriptor_Interface_t Extrakey_Interface;
70 USB_HID_Descriptor_HID_t Extrakey_HID;
71 USB_Descriptor_Endpoint_t Extrakey_INEndpoint;
72 #endif
73
74 #ifdef CONSOLE_ENABLE
75 // Console HID Interface
76 USB_Descriptor_Interface_t Console_Interface;
77 USB_HID_Descriptor_HID_t Console_HID;
78 USB_Descriptor_Endpoint_t Console_INEndpoint;
79 USB_Descriptor_Endpoint_t Console_OUTEndpoint;
80 #endif
81
82 #ifdef NKRO_ENABLE
83 // NKRO HID Interface
84 USB_Descriptor_Interface_t NKRO_Interface;
85 USB_HID_Descriptor_HID_t NKRO_HID;
86 USB_Descriptor_Endpoint_t NKRO_INEndpoint;
87 #endif
88 } USB_Descriptor_Configuration_t;
89
90
91 /* index of interface */
92 #define KEYBOARD_INTERFACE 0
93
94 #ifdef MOUSE_ENABLE
95 # define MOUSE_INTERFACE (KEYBOARD_INTERFACE + 1)
96 #else
97 # define MOUSE_INTERFACE KEYBOARD_INTERFACE
98 #endif
99
100 #ifdef EXTRAKEY_ENABLE
101 # define EXTRAKEY_INTERFACE (MOUSE_INTERFACE + 1)
102 #else
103 # define EXTRAKEY_INTERFACE MOUSE_INTERFACE
104 #endif
105
106 #ifdef CONSOLE_ENABLE
107 # define CONSOLE_INTERFACE (EXTRAKEY_INTERFACE + 1)
108 #else
109 # define CONSOLE_INTERFACE EXTRAKEY_INTERFACE
110 #endif
111
112 #ifdef NKRO_ENABLE
113 # define NKRO_INTERFACE (CONSOLE_INTERFACE + 1)
114 #else
115 # define NKRO_INTERFACE CONSOLE_INTERFACE
116 #endif
117
118
119 /* nubmer of interfaces */
120 #define TOTAL_INTERFACES (NKRO_INTERFACE + 1)
121
122
123 // Endopoint number and size
124 #define KEYBOARD_IN_EPNUM 1
125
126 #ifdef MOUSE_ENABLE
127 # define MOUSE_IN_EPNUM (KEYBOARD_IN_EPNUM + 1)
128 #else
129 # define MOUSE_IN_EPNUM KEYBOARD_IN_EPNUM
130 #endif
131
132 #ifdef EXTRAKEY_ENABLE
133 # define EXTRAKEY_IN_EPNUM (MOUSE_IN_EPNUM + 1)
134 #else
135 # define EXTRAKEY_IN_EPNUM MOUSE_IN_EPNUM
136 #endif
137
138 #ifdef CONSOLE_ENABLE
139 # define CONSOLE_IN_EPNUM (EXTRAKEY_IN_EPNUM + 1)
140 # define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 1)
141 //# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 2)
142 #else
143 # define CONSOLE_OUT_EPNUM EXTRAKEY_IN_EPNUM
144 #endif
145
146 #ifdef NKRO_ENABLE
147 # define NKRO_IN_EPNUM (CONSOLE_OUT_EPNUM + 1)
148 # if defined(__AVR_ATmega32U2__) && NKRO_IN_EPNUM > 4
149 # error "Endpoints are not available enough to support all functions. Remove some in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO)"
150 # endif
151 #endif
152
153
154 #define KEYBOARD_EPSIZE 8
155 #define MOUSE_EPSIZE 8
156 #define EXTRAKEY_EPSIZE 8
157 #define CONSOLE_EPSIZE 32
158 #define NKRO_EPSIZE 16
159
160
161 uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
162 const uint8_t wIndex,
163 const void** const DescriptorAddress)
164 ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
165
166
167 /* new API */
168 #if LUFA_VERSION_INTEGER < 0x140302
169 #undef VERSION_BCD
170 #define VERSION_BCD(Major, Minor, Revision) \
171 CPU_TO_LE16( ((Major & 0xFF) << 8) | \
172 ((Minor & 0x0F) << 4) | \
173 (Revision & 0x0F) )
174 #endif
175
176 #endif
Imprint / Impressum