diff options
author | tmk <nobody@nowhere> | 2011-09-01 11:21:35 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2011-09-01 11:21:35 +0900 |
commit | b703de7b298f8463bf4654fa3730ba1958a7fa9e (patch) | |
tree | b2c0986a895178140aac8b7030417f80e62c9854 /adb_usb/matrix.c | |
parent | 0dde25e81cc06ed6331c030839b7048c69fc9c84 (diff) | |
download | firmware-b703de7b298f8463bf4654fa3730ba1958a7fa9e.tar.gz firmware-b703de7b298f8463bf4654fa3730ba1958a7fa9e.tar.bz2 firmware-b703de7b298f8463bf4654fa3730ba1958a7fa9e.zip |
Added locking capslock key support and default now.
Diffstat (limited to 'adb_usb/matrix.c')
-rw-r--r-- | adb_usb/matrix.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/adb_usb/matrix.c b/adb_usb/matrix.c index 51dd37fca..a2367af56 100644 --- a/adb_usb/matrix.c +++ b/adb_usb/matrix.c @@ -25,6 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #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 <http://www.gnu.org/licenses/>. # 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<<USB_LED_CAPS_LOCK)) { + // Ignore LockingCaps key down event when CAPS LOCK is on + if (key0 == CAPS && (key1 == CAPS || key1 == 0xFF)) return 0; + if (key0 == CAPS) key0 = key1; + if (key1 == CAPS) key1 = 0xFF; + // Convert LockingCaps key up event into down event + if (key0 == CAPS_UP) key0 = CAPS; + if (key1 == CAPS_UP) key1 = CAPS; + } else { + // CAPS LOCK off: + // Ignore LockingCaps key up event when CAPS LOCK is off + if (key0 == CAPS_UP && (key1 == CAPS_UP || key1 == 0xFF)) return 0; + if (key0 == CAPS_UP) key0 = key1; + if (key1 == CAPS_UP) key1 = 0xFF; + } +#endif _matrix_is_modified = true; _register_key(key0); if (key1 != 0xFF) // key1 is 0xFF when no second key. |