]> git.donarmstrong.com Git - tmk_firmware.git/blobdiff - protocol/lufa/descriptor.h
Check if LUFA-git really exists(Fix #118)
[tmk_firmware.git] / protocol / lufa / descriptor.h
index 001e072e6ab50f7c59e06e54ff398ba4027690c1..a2db4bfd7b6604c1aea9837c3db7c5f0501bcfe1 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright 2012 Jun Wako <wakojun@gmail.com>
+ * Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
  * This file is based on:
  *     LUFA-120219/Demos/Device/Lowlevel/KeyboardMouse
  *     LUFA-120219/Demos/Device/Lowlevel/GenericHID
@@ -57,24 +57,33 @@ typedef struct
     USB_HID_Descriptor_HID_t              Keyboard_HID;
     USB_Descriptor_Endpoint_t             Keyboard_INEndpoint;
 
-    // Mouse HID Interface
 #ifdef MOUSE_ENABLE
+    // 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;
+#endif
+
+#ifdef CONSOLE_ENABLE
     // Console HID Interface
     USB_Descriptor_Interface_t            Console_Interface;
     USB_HID_Descriptor_HID_t              Console_HID;
     USB_Descriptor_Endpoint_t             Console_INEndpoint;
     USB_Descriptor_Endpoint_t             Console_OUTEndpoint;
+#endif
 
-    // Extra HID Interface
-#ifdef EXTRAKEY_ENABLE
-    USB_Descriptor_Interface_t            Extra_Interface;
-    USB_HID_Descriptor_HID_t              Extra_HID;
-    USB_Descriptor_Endpoint_t             Extra_INEndpoint;
+#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
 } USB_Descriptor_Configuration_t;
 
@@ -89,29 +98,60 @@ typedef struct
 #endif 
 
 #ifdef EXTRAKEY_ENABLE
-#   define EXTRA_INTERFACE          (MOUSE_INTERFACE + 1)
+#   define EXTRAKEY_INTERFACE       (MOUSE_INTERFACE + 1)
 #else
-#   define EXTRA_INTERFACE          MOUSE_INTERFACE
+#   define EXTRAKEY_INTERFACE       MOUSE_INTERFACE
 #endif 
 
-#define CONSOLE_INTERFACE           (EXTRA_INTERFACE + 1)
+#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
+#endif
 
 
 /* nubmer of interfaces */
-#define TOTAL_INTERFACES            (CONSOLE_INTERFACE + 1)
+#define TOTAL_INTERFACES            (NKRO_INTERFACE + 1)
 
 
 // Endopoint number and size
 #define KEYBOARD_IN_EPNUM           1
-#define MOUSE_IN_EPNUM              2
-#define CONSOLE_IN_EPNUM            3
-#define CONSOLE_OUT_EPNUM           4
-#define EXTRA_IN_EPNUM              5
+
+#ifdef MOUSE_ENABLE
+#   define MOUSE_IN_EPNUM           (KEYBOARD_IN_EPNUM + 1) 
+#else
+#   define MOUSE_IN_EPNUM           KEYBOARD_IN_EPNUM
+#endif
+
+#ifdef EXTRAKEY_ENABLE
+#   define EXTRAKEY_IN_EPNUM        (MOUSE_IN_EPNUM + 1)
+#else
+#   define EXTRAKEY_IN_EPNUM        MOUSE_IN_EPNUM 
+#endif
+
+#ifdef CONSOLE_ENABLE
+#   define CONSOLE_IN_EPNUM         (EXTRAKEY_IN_EPNUM + 1)
+#   define CONSOLE_OUT_EPNUM        (EXTRAKEY_IN_EPNUM + 2)
+#else
+#   define CONSOLE_OUT_EPNUM        EXTRAKEY_IN_EPNUM
+#endif
+
+#ifdef NKRO_ENABLE
+#   define NKRO_IN_EPNUM            (CONSOLE_OUT_EPNUM + 1)
+#endif
+
 
 #define KEYBOARD_EPSIZE             8
 #define MOUSE_EPSIZE                8
-#define CONSOLE_EPSIZE              8
-#define EXTRA_EPSIZE                8
+#define EXTRAKEY_EPSIZE             8
+#define CONSOLE_EPSIZE              32
+#define NKRO_EPSIZE                 16
 
 
 uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
@@ -119,4 +159,14 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
                                     const void** const DescriptorAddress)
                                     ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
 
+
+/* new API */
+#if LUFA_VERSION_INTEGER < 0x140302
+    #undef VERSION_BCD
+    #define VERSION_BCD(Major, Minor, Revision) \
+                                              CPU_TO_LE16( ((Major & 0xFF) << 8) | \
+                                                           ((Minor & 0x0F) << 4) | \
+                                                           (Revision & 0x0F) )
+#endif
+
 #endif