diff --git a/adb_usb/config.h b/adb_usb/config.h index ef1076c3..27f31ca9 100644 --- a/adb_usb/config.h +++ b/adb_usb/config.h @@ -31,6 +31,9 @@ along with this program. If not, see . #define MATRIX_ROWS 16 // keycode bit: 3-0 #define MATRIX_COLS 8 // keycode bit: 6-4 +/* Locking Caps Lock support */ +#define MATRIX_HAS_LOCKING_CAPS + /* key combination for command */ #define IS_COMMAND() ( \ diff --git a/adb_usb/matrix.c b/adb_usb/matrix.c index 51dd37fc..a2367af5 100644 --- a/adb_usb/matrix.c +++ b/adb_usb/matrix.c @@ -25,6 +25,8 @@ along with this program. If not, see . #include "print.h" #include "util.h" #include "debug.h" +#include "host.h" +#include "led.h" #include "adb.h" #include "matrix.h" @@ -36,6 +38,11 @@ along with this program. If not, see . # error "MATRIX_ROWS must not exceed 255" #endif +#define CAPS 0x39 +#define CAPS_UP (CAPS | 0x80) +#define ROW(key) ((key)>>3&0x0F) +#define COL(key) ((key)&0x07) + static bool _matrix_is_modified = false; @@ -93,11 +100,35 @@ uint8_t matrix_scan(void) key0 = codes>>8; key1 = codes&0xFF; +#ifdef MATRIX_HAS_LOCKING_CAPS + // Send Caps key up event + if (matrix_is_on(ROW(CAPS), COL(CAPS))) { + _matrix_is_modified = true; + _register_key(CAPS_UP); + } +#endif if (codes == 0) { // no keys return 0; } else if (key0 == 0xFF && key1 != 0xFF) { // error return codes&0xFF; } else { +#ifdef MATRIX_HAS_LOCKING_CAPS + if (host_keyboard_leds() & (1<