aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2011-09-01 11:21:35 +0900
committertmk <nobody@nowhere>2011-09-01 11:21:35 +0900
commitb703de7b298f8463bf4654fa3730ba1958a7fa9e (patch)
treeb2c0986a895178140aac8b7030417f80e62c9854
parent0dde25e81cc06ed6331c030839b7048c69fc9c84 (diff)
downloadqmk_firmware-b703de7b298f8463bf4654fa3730ba1958a7fa9e.tar.gz
qmk_firmware-b703de7b298f8463bf4654fa3730ba1958a7fa9e.zip
Added locking capslock key support and default now.
-rw-r--r--adb_usb/config.h3
-rw-r--r--adb_usb/matrix.c31
2 files changed, 34 insertions, 0 deletions
diff --git a/adb_usb/config.h b/adb_usb/config.h
index ef1076c31..27f31ca9e 100644
--- a/adb_usb/config.h
+++ b/adb_usb/config.h
@@ -31,6 +31,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
31#define MATRIX_ROWS 16 // keycode bit: 3-0 31#define MATRIX_ROWS 16 // keycode bit: 3-0
32#define MATRIX_COLS 8 // keycode bit: 6-4 32#define MATRIX_COLS 8 // keycode bit: 6-4
33 33
34/* Locking Caps Lock support */
35#define MATRIX_HAS_LOCKING_CAPS
36
34 37
35/* key combination for command */ 38/* key combination for command */
36#define IS_COMMAND() ( \ 39#define IS_COMMAND() ( \
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/>.
25#include "print.h" 25#include "print.h"
26#include "util.h" 26#include "util.h"
27#include "debug.h" 27#include "debug.h"
28#include "host.h"
29#include "led.h"
28#include "adb.h" 30#include "adb.h"
29#include "matrix.h" 31#include "matrix.h"
30 32
@@ -36,6 +38,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
36# error "MATRIX_ROWS must not exceed 255" 38# error "MATRIX_ROWS must not exceed 255"
37#endif 39#endif
38 40
41#define CAPS 0x39
42#define CAPS_UP (CAPS | 0x80)
43#define ROW(key) ((key)>>3&0x0F)
44#define COL(key) ((key)&0x07)
45
39 46
40static bool _matrix_is_modified = false; 47static bool _matrix_is_modified = false;
41 48
@@ -93,11 +100,35 @@ uint8_t matrix_scan(void)
93 key0 = codes>>8; 100 key0 = codes>>8;
94 key1 = codes&0xFF; 101 key1 = codes&0xFF;
95 102
103#ifdef MATRIX_HAS_LOCKING_CAPS
104 // Send Caps key up event
105 if (matrix_is_on(ROW(CAPS), COL(CAPS))) {
106 _matrix_is_modified = true;
107 _register_key(CAPS_UP);
108 }
109#endif
96 if (codes == 0) { // no keys 110 if (codes == 0) { // no keys
97 return 0; 111 return 0;
98 } else if (key0 == 0xFF && key1 != 0xFF) { // error 112 } else if (key0 == 0xFF && key1 != 0xFF) { // error
99 return codes&0xFF; 113 return codes&0xFF;
100 } else { 114 } else {
115#ifdef MATRIX_HAS_LOCKING_CAPS
116 if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {
117 // Ignore LockingCaps key down event when CAPS LOCK is on
118 if (key0 == CAPS && (key1 == CAPS || key1 == 0xFF)) return 0;
119 if (key0 == CAPS) key0 = key1;
120 if (key1 == CAPS) key1 = 0xFF;
121 // Convert LockingCaps key up event into down event
122 if (key0 == CAPS_UP) key0 = CAPS;
123 if (key1 == CAPS_UP) key1 = CAPS;
124 } else {
125 // CAPS LOCK off:
126 // Ignore LockingCaps key up event when CAPS LOCK is off
127 if (key0 == CAPS_UP && (key1 == CAPS_UP || key1 == 0xFF)) return 0;
128 if (key0 == CAPS_UP) key0 = key1;
129 if (key1 == CAPS_UP) key1 = 0xFF;
130 }
131#endif
101 _matrix_is_modified = true; 132 _matrix_is_modified = true;
102 _register_key(key0); 133 _register_key(key0);
103 if (key1 != 0xFF) // key1 is 0xFF when no second key. 134 if (key1 != 0xFF) // key1 is 0xFF when no second key.