-#define KEYBOARD_INTERFACE 0
-#define KEYBOARD_ENDPOINT 1
-#define KEYBOARD_SIZE 8
-#define KEYBOARD_BUFFER EP_DOUBLE_BUFFER
-
-// TODO: move to usb_keycodes.h ?
-// modifier bits
-#define MOD_LCTRL (1<<0)
-#define MOD_LSHIFT (1<<1)
-#define MOD_LALT (1<<2)
-#define MOD_LGUI (1<<3)
-#define MOD_RCTRL (1<<4)
-#define MOD_RSHIFT (1<<5)
-#define MOD_RALT (1<<6)
-#define MOD_RGUI (1<<7)
-
-
-// TODO: change variable name: usb_keyboard_ or usb_kb_
-extern uint8_t keyboard_modifier_keys;
-extern uint8_t keyboard_keys[6];
-extern uint8_t keyboard_protocol;
-extern uint8_t keyboard_idle_config;
-extern uint8_t keyboard_idle_count;
-extern volatile uint8_t keyboard_leds; // TODO: delete NOT USED?
-
-
-int8_t usb_keyboard_press(uint8_t key, uint8_t modifier);
+#define KBD_INTERFACE 0
+#define KBD_ENDPOINT 1
+#define KBD_SIZE 8
+#define KBD_BUFFER EP_DOUBLE_BUFFER
+#define KBD_REPORT_KEYS (KBD_SIZE - 2)
+
+// secondary keyboard
+#ifdef USB_NKRO_ENABLE
+#define KBD2_INTERFACE 4
+#define KBD2_ENDPOINT 5
+#define KBD2_SIZE 16
+#define KBD2_BUFFER EP_DOUBLE_BUFFER
+#define KBD2_REPORT_KEYS (KBD2_SIZE - 1)
+#endif
+
+#if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS
+#define KEYS_MAX KBD2_REPORT_KEYS
+#else
+#define KEYS_MAX KBD_REPORT_KEYS
+#endif
+
+#define BIT_LCTRL (1<<0)
+#define BIT_LSHIFT (1<<1)
+#define BIT_LALT (1<<2)
+#define BIT_LGUI (1<<3)
+#define BIT_RCTRL (1<<4)
+#define BIT_RSHIFT (1<<5)
+#define BIT_RALT (1<<6)
+#define BIT_RGUI (1<<7)
+#define BIT_LCTL BIT_LCTRL
+#define BIT_RCTL BIT_RCTRL
+#define BIT_LSFT BIT_LSHIFT
+#define BIT_RSFT BIT_RSHIFT
+
+typedef struct report {
+ uint8_t keys[KEYS_MAX];
+ uint8_t mods;
+ bool is_sent;
+} usb_keyboard_report_t;
+
+
+#define usb_keyboard_keys usb_keyboard_report->keys
+#define usb_keyboard_mods usb_keyboard_report->mods
+#define usb_keyboard_keys_prev usb_keyboard_report_prev->keys
+#define usb_keyboard_mods_prev usb_keyboard_report_prev->mods
+
+
+extern usb_keyboard_report_t *usb_keyboard_report;
+extern usb_keyboard_report_t *usb_keyboard_report_prev;
+extern uint8_t usb_keyboard_protocol;
+extern uint8_t usb_keyboard_idle_config;
+extern uint8_t usb_keyboard_idle_count;
+extern volatile uint8_t usb_keyboard_leds;
+extern bool usb_keyboard_nkro;
+
+