aboutsummaryrefslogtreecommitdiff
path: root/m0110_usb/matrix.c
diff options
context:
space:
mode:
Diffstat (limited to 'm0110_usb/matrix.c')
-rw-r--r--m0110_usb/matrix.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/m0110_usb/matrix.c b/m0110_usb/matrix.c
index 11303ee0f..b28045b9c 100644
--- a/m0110_usb/matrix.c
+++ b/m0110_usb/matrix.c
@@ -32,10 +32,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
32 32
33 33
34#define CAPS 0x39 34#define CAPS 0x39
35#define CAPS_UP (CAPS | 0x80) 35#define CAPS_BREAK (CAPS | 0x80)
36#define ROW(key) ((key)>>3&0x0F) 36#define ROW(key) ((key)>>3&0x0F)
37#define COL(key) ((key)&0x07) 37#define COL(key) ((key)&0x07)
38 38
39#define ARROW_UP_BREAK (0x4D | 0x80)
40#define ARROW_DOWN_BREAK (0x48 | 0x80)
41#define ARROW_LEFT_BREAK (0x46 | 0x80)
42#define ARROW_RIGHT_BREAK (0x42 | 0x80)
43
39 44
40static bool is_modified = false; 45static bool is_modified = false;
41 46
@@ -88,14 +93,27 @@ uint8_t matrix_scan(void)
88 // Send Caps key up event 93 // Send Caps key up event
89 if (matrix_is_on(ROW(CAPS), COL(CAPS))) { 94 if (matrix_is_on(ROW(CAPS), COL(CAPS))) {
90 is_modified = true; 95 is_modified = true;
91 register_key(CAPS_UP); 96 register_key(CAPS_BREAK);
92 } 97 }
93#endif 98#endif
94 if (key == M0110_NULL) { 99 if (key == M0110_NULL) {
95 return 0; 100 return 0;
96 } else if (key == M0110_ERROR) { 101 } else if (key == M0110_ERROR) {
97 // TODO: error recovery or reinit
98 return 0; 102 return 0;
103 } else if (key == ARROW_UP_BREAK ||
104 key == ARROW_DOWN_BREAK ||
105 key == ARROW_LEFT_BREAK ||
106 key == ARROW_RIGHT_BREAK) {
107 // WORK AROUND: exceptional handling for M0110A
108 // Unregister both Arrow key and coressponding Calc key when receive Arrow key break.
109 //
110 // Shift + Calc keys(=/*+):
111 // Send no Shift break(0xF1) when release Calc keys. Can't be desinguished from Arrow keys.
112 // (press: 0x71, 0x79, 0xXX release: 0x79, 0xXX)
113 // See m0110.c for key events and scan codes.
114 is_modified = true;
115 register_key(key);
116 register_key(key|M0110_CALC_OFFSET);
99 } else { 117 } else {
100#ifdef MATRIX_HAS_LOCKING_CAPS 118#ifdef MATRIX_HAS_LOCKING_CAPS
101 if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { 119 if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {
@@ -103,11 +121,11 @@ uint8_t matrix_scan(void)
103 // Ignore LockingCaps key down event 121 // Ignore LockingCaps key down event
104 if (key == CAPS) return 0; 122 if (key == CAPS) return 0;
105 // Convert LockingCaps key up event into down event 123 // Convert LockingCaps key up event into down event
106 if (key == CAPS_UP) key = CAPS; 124 if (key == CAPS_BREAK) key = CAPS;
107 } else { 125 } else {
108 // CAPS LOCK off: 126 // CAPS LOCK off:
109 // Ignore LockingCaps key up event 127 // Ignore LockingCaps key up event
110 if (key == CAPS_UP) return 0; 128 if (key == CAPS_BREAK) return 0;
111 } 129 }
112#endif 130#endif
113 is_modified = true; 131 is_modified = true;