summaryrefslogtreecommitdiff
path: root/tmk_core/protocol/usb_descriptor.h
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol/usb_descriptor.h')
-rw-r--r--tmk_core/protocol/usb_descriptor.h170
1 files changed, 68 insertions, 102 deletions
diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h
index 586d07df62..3ca0c00b34 100644
--- a/tmk_core/protocol/usb_descriptor.h
+++ b/tmk_core/protocol/usb_descriptor.h
@@ -53,26 +53,27 @@ typedef struct
{
USB_Descriptor_Configuration_Header_t Config;
+#ifndef KEYBOARD_SHARED_EP
// Keyboard HID Interface
USB_Descriptor_Interface_t Keyboard_Interface;
USB_HID_Descriptor_HID_t Keyboard_HID;
USB_Descriptor_Endpoint_t Keyboard_INEndpoint;
+#endif
-#ifdef MOUSE_ENABLE
+#if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
// Mouse HID Interface
USB_Descriptor_Interface_t Mouse_Interface;
USB_HID_Descriptor_HID_t Mouse_HID;
USB_Descriptor_Endpoint_t Mouse_INEndpoint;
#endif
-#ifdef EXTRAKEY_ENABLE
- // Extrakey HID Interface
- USB_Descriptor_Interface_t Extrakey_Interface;
- USB_HID_Descriptor_HID_t Extrakey_HID;
- USB_Descriptor_Endpoint_t Extrakey_INEndpoint;
+#if defined(SHARED_EP_ENABLE)
+ USB_Descriptor_Interface_t Shared_Interface;
+ USB_HID_Descriptor_HID_t Shared_HID;
+ USB_Descriptor_Endpoint_t Shared_INEndpoint;
#endif
-#ifdef RAW_ENABLE
+#if defined(RAW_ENABLE)
// Raw HID Interface
USB_Descriptor_Interface_t Raw_Interface;
USB_HID_Descriptor_HID_t Raw_HID;
@@ -88,13 +89,6 @@ typedef struct
USB_Descriptor_Endpoint_t Console_OUTEndpoint;
#endif
-#ifdef NKRO_ENABLE
- // NKRO HID Interface
- USB_Descriptor_Interface_t NKRO_Interface;
- USB_HID_Descriptor_HID_t NKRO_HID;
- USB_Descriptor_Endpoint_t NKRO_INEndpoint;
-#endif
-
#ifdef MIDI_ENABLE
USB_Descriptor_Interface_Association_t Audio_Interface_Association;
// MIDI Audio Control Interface
@@ -133,133 +127,105 @@ typedef struct
/* index of interface */
-#define KEYBOARD_INTERFACE 0
-
+enum usb_interfaces {
+#if !defined(KEYBOARD_SHARED_EP)
+ KEYBOARD_INTERFACE,
+#else
+# define KEYBOARD_INTERFACE SHARED_INTERFACE
+#endif
// It is important that the Raw HID interface is at a constant
// interface number, to support Linux/OSX platforms and chrome.hid
// If Raw HID is enabled, let it be always 1.
-#ifdef RAW_ENABLE
-# define RAW_INTERFACE (KEYBOARD_INTERFACE + 1)
-#else
-# define RAW_INTERFACE KEYBOARD_INTERFACE
+#if defined(RAW_ENABLE)
+ RAW_INTERFACE,
#endif
-
-#ifdef MOUSE_ENABLE
-# define MOUSE_INTERFACE (RAW_INTERFACE + 1)
-#else
-# define MOUSE_INTERFACE RAW_INTERFACE
+#if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
+ MOUSE_INTERFACE,
#endif
-
-#ifdef EXTRAKEY_ENABLE
-# define EXTRAKEY_INTERFACE (MOUSE_INTERFACE + 1)
-#else
-# define EXTRAKEY_INTERFACE MOUSE_INTERFACE
+#if defined(SHARED_EP_ENABLE)
+ SHARED_INTERFACE,
#endif
-
-#ifdef CONSOLE_ENABLE
-# define CONSOLE_INTERFACE (EXTRAKEY_INTERFACE + 1)
-#else
-# define CONSOLE_INTERFACE EXTRAKEY_INTERFACE
-#endif
-
-#ifdef NKRO_ENABLE
-# define NKRO_INTERFACE (CONSOLE_INTERFACE + 1)
-#else
-# define NKRO_INTERFACE CONSOLE_INTERFACE
+#if defined(CONSOLE_ENABLE)
+ CONSOLE_INTERFACE,
#endif
-
-#ifdef MIDI_ENABLE
-# define AC_INTERFACE (NKRO_INTERFACE + 1)
-# define AS_INTERFACE (NKRO_INTERFACE + 2)
-#else
-# define AS_INTERFACE NKRO_INTERFACE
+#if defined(MIDI_ENABLE)
+ AC_INTERFACE,
+ AS_INTERFACE,
#endif
-
-#ifdef VIRTSER_ENABLE
-# define CCI_INTERFACE (AS_INTERFACE + 1)
-# define CDI_INTERFACE (AS_INTERFACE + 2)
-#else
-# define CDI_INTERFACE AS_INTERFACE
+#if defined(VIRTSER_ENABLE)
+ CCI_INTERFACE,
+ CDI_INTERFACE,
#endif
+ TOTAL_INTERFACES
+};
-/* nubmer of interfaces */
-#define TOTAL_INTERFACES (CDI_INTERFACE + 1)
-
+#define NEXT_EPNUM __COUNTER__
-// Endopoint number and size
-#define KEYBOARD_IN_EPNUM 1
-
-#ifdef MOUSE_ENABLE
-# define MOUSE_IN_EPNUM (KEYBOARD_IN_EPNUM + 1)
+enum usb_endpoints {
+ __unused_epnum__ = NEXT_EPNUM, /* EP numbering starts at 1 */
+#if !defined(KEYBOARD_SHARED_EP)
+ KEYBOARD_IN_EPNUM = NEXT_EPNUM,
#else
-# define MOUSE_IN_EPNUM KEYBOARD_IN_EPNUM
+# define KEYBOARD_IN_EPNUM SHARED_IN_EPNUM
#endif
-
-#ifdef EXTRAKEY_ENABLE
-# define EXTRAKEY_IN_EPNUM (MOUSE_IN_EPNUM + 1)
+#if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
+ MOUSE_IN_EPNUM = NEXT_EPNUM,
#else
-# define EXTRAKEY_IN_EPNUM MOUSE_IN_EPNUM
+# define MOUSE_IN_EPNUM SHARED_IN_EPNUM
#endif
-
-#ifdef RAW_ENABLE
-# define RAW_IN_EPNUM (EXTRAKEY_IN_EPNUM + 1)
-# define RAW_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 2)
-#else
-# define RAW_OUT_EPNUM EXTRAKEY_IN_EPNUM
+#if defined(RAW_ENABLE)
+ RAW_IN_EPNUM = NEXT_EPNUM,
+ RAW_OUT_EPNUM = NEXT_EPNUM,
#endif
-
-#ifdef CONSOLE_ENABLE
-# define CONSOLE_IN_EPNUM (RAW_OUT_EPNUM + 1)
+#if defined(SHARED_EP_ENABLE)
+ SHARED_IN_EPNUM = NEXT_EPNUM,
+#endif
+#if defined(CONSOLE_ENABLE)
+ CONSOLE_IN_EPNUM = NEXT_EPNUM,
#ifdef PROTOCOL_CHIBIOS
// ChibiOS has enough memory and descriptor to actually enable the endpoint
// It could use the same endpoint numbers, as that's supported by ChibiOS
// But the QMK code currently assumes that the endpoint numbers are different
-# define CONSOLE_OUT_EPNUM (RAW_OUT_EPNUM + 2)
+ CONSOLE_OUT_EPNUM = NEXT_EPNUM,
#else
-# define CONSOLE_OUT_EPNUM (RAW_OUT_EPNUM + 1)
+#define CONSOLE_OUT_EPNUM CONSOLE_IN_EPNUM
#endif
-#else
-# define CONSOLE_OUT_EPNUM RAW_OUT_EPNUM
#endif
-
-#ifdef NKRO_ENABLE
-# define NKRO_IN_EPNUM (CONSOLE_OUT_EPNUM + 1)
-#else
-# define NKRO_IN_EPNUM CONSOLE_OUT_EPNUM
-#endif
-
#ifdef MIDI_ENABLE
-# define MIDI_STREAM_IN_EPNUM (NKRO_IN_EPNUM + 1)
-// # define MIDI_STREAM_OUT_EPNUM (NKRO_IN_EPNUM + 1)
-# define MIDI_STREAM_OUT_EPNUM (NKRO_IN_EPNUM + 2)
+ MIDI_STREAM_IN_EPNUM = NEXT_EPNUM,
+ MIDI_STREAM_OUT_EPNUM = NEXT_EPNUM,
# define MIDI_STREAM_IN_EPADDR (ENDPOINT_DIR_IN | MIDI_STREAM_IN_EPNUM)
# define MIDI_STREAM_OUT_EPADDR (ENDPOINT_DIR_OUT | MIDI_STREAM_OUT_EPNUM)
-#else
-# define MIDI_STREAM_OUT_EPNUM NKRO_IN_EPNUM
#endif
-
#ifdef VIRTSER_ENABLE
-# define CDC_NOTIFICATION_EPNUM (MIDI_STREAM_OUT_EPNUM + 1)
-# define CDC_IN_EPNUM (MIDI_STREAM_OUT_EPNUM + 2)
-# define CDC_OUT_EPNUM (MIDI_STREAM_OUT_EPNUM + 3)
+ CDC_NOTIFICATION_EPNUM = NEXT_EPNUM,
+ CDC_IN_EPNUM = NEXT_EPNUM,
+ CDC_OUT_EPNUM = NEXT_EPNUM,
# define CDC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM)
# define CDC_IN_EPADDR (ENDPOINT_DIR_IN | CDC_IN_EPNUM)
# define CDC_OUT_EPADDR (ENDPOINT_DIR_OUT | CDC_OUT_EPNUM)
-#else
-# define CDC_OUT_EPNUM MIDI_STREAM_OUT_EPNUM
#endif
+};
+
+#if defined(PROTOCOL_LUFA)
+/* LUFA tells us total endpoints including control */
+#define MAX_ENDPOINTS (ENDPOINT_TOTAL_ENDPOINTS - 1)
+#elif defined(PROTOCOL_CHIBIOS)
+/* ChibiOS gives us number of available user endpoints, not control */
+#define MAX_ENDPOINTS USB_MAX_ENDPOINTS
+#endif
+/* TODO - ARM_ATSAM */
+
-#if (defined(PROTOCOL_LUFA) && CDC_OUT_EPNUM > (ENDPOINT_TOTAL_ENDPOINTS - 1)) || \
- (defined(PROTOCOL_CHIBIOS) && CDC_OUT_EPNUM > USB_MAX_ENDPOINTS)
-# error "There are not enough available endpoints to support all functions. Remove some in the rules.mk file.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO, MIDI, SERIAL, STENO)"
+#if (NEXT_EPNUM - 1) > MAX_ENDPOINTS
+# error There are not enough available endpoints to support all functions. Remove some in the rules.mk file. (MOUSEKEY, EXTRAKEY, CONSOLE, NKRO, MIDI, SERIAL, STENO)
#endif
#define KEYBOARD_EPSIZE 8
+#define SHARED_EPSIZE 32
#define MOUSE_EPSIZE 8
-#define EXTRAKEY_EPSIZE 8
#define RAW_EPSIZE 32
#define CONSOLE_EPSIZE 32
-#define NKRO_EPSIZE 32
#define MIDI_STREAM_EPSIZE 64
#define CDC_NOTIFICATION_EPSIZE 8
#define CDC_EPSIZE 16