]> git.donarmstrong.com Git - tmk_firmware.git/blobdiff - common/report.h
Add option 7bit data to serial_soft.c
[tmk_firmware.git] / common / report.h
index 02deb7797e7ec6b224d94b53df56e1474ce57bae..71543cc23fa341ad77c2453913e6d0f9b4b34224 100644 (file)
@@ -72,14 +72,20 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 /* key report size(NKRO or boot mode) */
-#if defined(PROTOCOL_PJRC)
+#if defined(PROTOCOL_PJRC) && defined(NKRO_ENABLE)
 #   include "usb.h"
-#   if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS
-#       define REPORT_KEYS KBD2_REPORT_KEYS
-#   else
-#       define REPORT_KEYS KBD_REPORT_KEYS
-#   endif
+#   define REPORT_SIZE KBD2_SIZE
+#   define REPORT_KEYS (KBD2_SIZE - 2)
+#   define REPORT_BITS (KBD2_SIZE - 1)
+
+#elif defined(PROTOCOL_LUFA) && defined(NKRO_ENABLE)
+#   include "protocol/lufa/descriptor.h"
+#   define REPORT_SIZE NKRO_EPSIZE
+#   define REPORT_KEYS (NKRO_EPSIZE - 2)
+#   define REPORT_BITS (NKRO_EPSIZE - 1)
+
 #else
+#   define REPORT_SIZE 8
 #   define REPORT_KEYS 6
 #endif
 
@@ -88,11 +94,47 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 extern "C" {
 #endif
 
+/*
+ * keyboard report is 8-byte array retains state of 8 modifiers and 6 keys.
+ *
+ * byte |0       |1       |2       |3       |4       |5       |6       |7
+ * -----+--------+--------+--------+--------+--------+--------+--------+--------
+ * desc |mods    |reserved|keys[0] |keys[1] |keys[2] |keys[3] |keys[4] |keys[5]
+ *
+ * It is exended to 16 bytes to retain 120keys+8mods when NKRO mode.
+ *
+ * byte |0       |1       |2       |3       |4       |5       |6       |7        ... |15
+ * -----+--------+--------+--------+--------+--------+--------+--------+--------     +--------
+ * desc |mods    |bits[0] |bits[1] |bits[2] |bits[3] |bits[4] |bits[5] |bits[6]  ... |bit[14]
+ *
+ * mods retains state of 8 modifiers.
+ *
+ *  bit |0       |1       |2       |3       |4       |5       |6       |7
+ * -----+--------+--------+--------+--------+--------+--------+--------+--------
+ * desc |Lcontrol|Lshift  |Lalt    |Lgui    |Rcontrol|Rshift  |Ralt    |Rgui
+ *
+ */
+typedef union {
+    uint8_t raw[REPORT_SIZE];
+    struct {
+        uint8_t mods;
+        uint8_t reserved;
+        uint8_t keys[REPORT_KEYS];
+    };
+#ifdef NKRO_ENABLE
+    struct {
+        uint8_t mods;
+        uint8_t bits[REPORT_BITS];
+    } nkro;
+#endif
+} __attribute__ ((packed)) report_keyboard_t;
+/*
 typedef struct {
     uint8_t mods;
-    uint8_t rserved;
+    uint8_t reserved;
     uint8_t keys[REPORT_KEYS];
 } __attribute__ ((packed)) report_keyboard_t;
+*/
 
 typedef struct {
     uint8_t buttons;