]> git.friedersdorff.com Git - max/tmk_keyboard.git/blobdiff - usb_keyboard.h
added initial support of mousekeys to ps2_vusb
[max/tmk_keyboard.git] / usb_keyboard.h
index 4be40aaaf25a7603e4c4e22685f3514e7eba4bcd..141efc97a629ac56f3fa0bb25ac734146f4d1c26 100644 (file)
@@ -6,10 +6,26 @@
 #include "usb.h"
 
 
-#define KEYBOARD_INTERFACE     0
-#define KEYBOARD_ENDPOINT      1
-#define KEYBOARD_SIZE          8
-#define KEYBOARD_BUFFER                EP_DOUBLE_BUFFER
+#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)
@@ -25,7 +41,7 @@
 #define BIT_RSFT BIT_RSHIFT
 
 typedef struct report {
-    uint8_t keys[6];
+    uint8_t keys[KEYS_MAX];
     uint8_t mods;
     bool is_sent;
 } usb_keyboard_report_t;
@@ -33,6 +49,8 @@ typedef struct report {
 
 #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;
@@ -41,9 +59,9 @@ 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;
 
 
-int8_t usb_keyboard_press(uint8_t key, uint8_t modifier);
 int8_t usb_keyboard_send(void);
 int8_t usb_keyboard_send_report(usb_keyboard_report_t *report);
 
@@ -53,7 +71,7 @@ void usb_keyboard_clear_report(void);
 void usb_keyboard_clear_keys(void);
 void usb_keyboard_clear_mods(void);
 
-void usb_keyboard_set_keys(uint8_t keys[6]);
+void usb_keyboard_set_keys(uint8_t *keys);
 void usb_keyboard_set_mods(uint8_t mods);
 
 void usb_keyboard_add_code(uint8_t code);
@@ -68,6 +86,8 @@ bool usb_keyboard_is_sent(void);
 bool usb_keyboard_has_key(void);
 bool usb_keyboard_has_mod(void);
 
+uint8_t usb_keyboard_get_key(void);
+
 void usb_keyboard_print_report(usb_keyboard_report_t *report);
 
 #endif