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
10 Copyright (C) Dean Camera, 2012.
12 dean [at] fourwalledcubicle [dot] com
17 Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
18 Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
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.
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
41 * Header file for Descriptors.c.
44 #ifndef _DESCRIPTORS_H_
45 #define _DESCRIPTORS_H_
47 #include <LUFA/Drivers/USB/USB.h>
48 #include <avr/pgmspace.h>
53 USB_Descriptor_Configuration_Header_t Config;
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;
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;
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;
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;
84 USB_Descriptor_Interface_t NKRO_Interface;
85 USB_HID_Descriptor_HID_t NKRO_HID;
86 USB_Descriptor_Endpoint_t NKRO_INEndpoint;
90 // MIDI Audio Control Interface
91 USB_Descriptor_Interface_t Audio_ControlInterface;
92 USB_Audio_Descriptor_Interface_AC_t Audio_ControlInterface_SPC;
94 // MIDI Audio Streaming Interface
95 USB_Descriptor_Interface_t Audio_StreamInterface;
96 USB_MIDI_Descriptor_AudioInterface_AS_t Audio_StreamInterface_SPC;
97 USB_MIDI_Descriptor_InputJack_t MIDI_In_Jack_Emb;
98 USB_MIDI_Descriptor_InputJack_t MIDI_In_Jack_Ext;
99 USB_MIDI_Descriptor_OutputJack_t MIDI_Out_Jack_Emb;
100 USB_MIDI_Descriptor_OutputJack_t MIDI_Out_Jack_Ext;
101 USB_Audio_Descriptor_StreamEndpoint_Std_t MIDI_In_Jack_Endpoint;
102 USB_MIDI_Descriptor_Jack_Endpoint_t MIDI_In_Jack_Endpoint_SPC;
103 USB_Audio_Descriptor_StreamEndpoint_Std_t MIDI_Out_Jack_Endpoint;
104 USB_MIDI_Descriptor_Jack_Endpoint_t MIDI_Out_Jack_Endpoint_SPC;
107 } USB_Descriptor_Configuration_t;
110 /* index of interface */
111 #define KEYBOARD_INTERFACE 0
114 # define MOUSE_INTERFACE (KEYBOARD_INTERFACE + 1)
116 # define MOUSE_INTERFACE KEYBOARD_INTERFACE
119 #ifdef EXTRAKEY_ENABLE
120 # define EXTRAKEY_INTERFACE (MOUSE_INTERFACE + 1)
122 # define EXTRAKEY_INTERFACE MOUSE_INTERFACE
125 #ifdef CONSOLE_ENABLE
126 # define CONSOLE_INTERFACE (EXTRAKEY_INTERFACE + 1)
128 # define CONSOLE_INTERFACE EXTRAKEY_INTERFACE
132 # define NKRO_INTERFACE (CONSOLE_INTERFACE + 1)
134 # define NKRO_INTERFACE CONSOLE_INTERFACE
138 # define AC_INTERFACE (NKRO_INTERFACE + 1)
139 # define AS_INTERFACE (NKRO_INTERFACE + 2)
141 # define AS_INTERFACE NKRO_INTERFACE
144 /* nubmer of interfaces */
145 #define TOTAL_INTERFACES AS_INTERFACE + 1
148 // Endopoint number and size
149 #define KEYBOARD_IN_EPNUM 1
152 # define MOUSE_IN_EPNUM (KEYBOARD_IN_EPNUM + 1)
154 # define MOUSE_IN_EPNUM KEYBOARD_IN_EPNUM
157 #ifdef EXTRAKEY_ENABLE
158 # define EXTRAKEY_IN_EPNUM (MOUSE_IN_EPNUM + 1)
160 # define EXTRAKEY_IN_EPNUM MOUSE_IN_EPNUM
163 #ifdef CONSOLE_ENABLE
164 # define CONSOLE_IN_EPNUM (EXTRAKEY_IN_EPNUM + 1)
165 # define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 1)
166 //# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 2)
168 # define CONSOLE_OUT_EPNUM EXTRAKEY_IN_EPNUM
172 # define NKRO_IN_EPNUM (CONSOLE_OUT_EPNUM + 1)
174 # define NKRO_IN_EPNUM CONSOLE_OUT_EPNUM
178 # define MIDI_STREAM_IN_EPNUM (NKRO_IN_EPNUM + 1)
179 // # define MIDI_STREAM_OUT_EPNUM (NKRO_IN_EPNUM + 1)
180 # define MIDI_STREAM_OUT_EPNUM (NKRO_IN_EPNUM + 2)
181 # define MIDI_STREAM_IN_EPADDR (ENDPOINT_DIR_IN | MIDI_STREAM_IN_EPNUM)
182 # define MIDI_STREAM_OUT_EPADDR (ENDPOINT_DIR_OUT | MIDI_STREAM_OUT_EPNUM)
186 #if defined(__AVR_ATmega32U2__) && MIDI_STREAM_OUT_EPADDR > 4
187 # error "Endpoints are not available enough to support all functions. Remove some in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO, MIDI)"
190 #define KEYBOARD_EPSIZE 8
191 #define MOUSE_EPSIZE 8
192 #define EXTRAKEY_EPSIZE 8
193 #define CONSOLE_EPSIZE 32
194 #define NKRO_EPSIZE 16
195 #define MIDI_STREAM_EPSIZE 64
198 uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
199 const uint8_t wIndex,
200 const void** const DescriptorAddress)
201 ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
205 #if LUFA_VERSION_INTEGER < 0x140302
207 #define VERSION_BCD(Major, Minor, Revision) \
208 CPU_TO_LE16( ((Major & 0xFF) << 8) | \
209 ((Minor & 0x0F) << 4) | \