diff options
| author | tmk <nobody@nowhere> | 2012-05-22 00:14:02 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2012-05-22 00:14:02 +0900 |
| commit | 805ce3c1309421df6166b085b70f53c494f9946b (patch) | |
| tree | 1d5757f7d6f426d038807d49813a7683ed053a43 | |
| parent | 901503a1c7eec4be8cf5aa3ab45e5f36fd2f12bc (diff) | |
| download | qmk_firmware-805ce3c1309421df6166b085b70f53c494f9946b.tar.gz qmk_firmware-805ce3c1309421df6166b085b70f53c494f9946b.zip | |
Fix key stuck bug of M0110A support.
- rewrite special key handling in m0110.c
- add mouse keys to keymap
| -rw-r--r-- | m0110.c | 229 | ||||
| -rw-r--r-- | m0110.h | 2 | ||||
| -rw-r--r-- | m0110_usb/README.md | 27 | ||||
| -rw-r--r-- | m0110_usb/config.h | 2 | ||||
| -rw-r--r-- | m0110_usb/keymap.c | 39 | ||||
| -rw-r--r-- | m0110_usb/matrix.c | 49 |
6 files changed, 213 insertions, 135 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Copyright 2011 Jun WAKO <wakojun@gmail.com> | 2 | Copyright 2011,2012 Jun WAKO <wakojun@gmail.com> |
| 3 | 3 | ||
| 4 | This software is licensed with a Modified BSD License. | 4 | This software is licensed with a Modified BSD License. |
| 5 | All of this is supposed to be Free Software, Open Source, DFSG-free, | 5 | All of this is supposed to be Free Software, Open Source, DFSG-free, |
| @@ -82,6 +82,9 @@ static inline void request(void); | |||
| 82 | } \ | 82 | } \ |
| 83 | } while (0) | 83 | } while (0) |
| 84 | 84 | ||
| 85 | #define KEY(raw) ((raw) & 0x7f) | ||
| 86 | #define IS_BREAK(raw) (((raw) & 0x80) == 0x80) | ||
| 87 | |||
| 85 | 88 | ||
| 86 | uint8_t m0110_error = 0; | 89 | uint8_t m0110_error = 0; |
| 87 | 90 | ||
| @@ -92,10 +95,6 @@ void m0110_init(void) | |||
| 92 | idle(); | 95 | idle(); |
| 93 | _delay_ms(1000); | 96 | _delay_ms(1000); |
| 94 | 97 | ||
| 95 | // Model Number | ||
| 96 | // M0110 : 0x09 00001001 : model number 4 (100) | ||
| 97 | // M0110A: 0x0B 00001011 : model number 5 (101) | ||
| 98 | // M0110 & M0120: ??? | ||
| 99 | m0110_send(M0110_MODEL); | 98 | m0110_send(M0110_MODEL); |
| 100 | data = m0110_recv(); | 99 | data = m0110_recv(); |
| 101 | print("m0110_init model: "); phex(data); print("\n"); | 100 | print("m0110_init model: "); phex(data); print("\n"); |
| @@ -153,47 +152,151 @@ ERROR: | |||
| 153 | return 0xFF; | 152 | return 0xFF; |
| 154 | } | 153 | } |
| 155 | 154 | ||
| 155 | /* | ||
| 156 | Handling for exceptional case of key combinations for M0110A | ||
| 157 | |||
| 158 | Shift and Calc/Arrow key could be operated simultaneously: | ||
| 159 | |||
| 160 | Case Shift Arrow Events Interpret | ||
| 161 | ------------------------------------------------------------------- | ||
| 162 | 1 Down Down 71, 79, DD Calc(d)*a *b | ||
| 163 | 2 Down Up 71, 79, UU Arrow&Calc(u)*a | ||
| 164 | 3 Up Down F1, 79, DD Shift(u) *c | ||
| 165 | 4 Up Up F1, 79, UU Shift(u) and Arrow&Calc(u)*a | ||
| 166 | |||
| 167 | Case Shift Calc Events Interpret | ||
| 168 | ------------------------------------------------------------------- | ||
| 169 | 5(1) Down Down 71, 71, 79, DD Shift(d) and Cacl(d) | ||
| 170 | 6(2) Down Up F1, 71, 79, UU Shift(u) and Arrow&Calc(u)*a | ||
| 171 | 7(1) Up Down F1, 71, 79, DD Shift(u) and Calc(d) | ||
| 172 | 8(4) Up Up F1, F1, 79, UU Shift(ux2) and Arrow&Calc(u)*a | ||
| 173 | |||
| 174 | During Calc key is hold: | ||
| 175 | Case Shift Arrow Events Interpret | ||
| 176 | ------------------------------------------------------------------- | ||
| 177 | A(3) ---- Down F1, 79, DD Shift(u) *c | ||
| 178 | B ---- Up 79, UU Arrow&Calc(u)*a | ||
| 179 | C Down ---- F1, 71 Shift(u) and Shift(d) | ||
| 180 | D Up ---- F1 Shift(u) | ||
| 181 | E Hold Down 79, DD Normal | ||
| 182 | F Hold Up 79, UU Arrow&Calc(u)*a | ||
| 183 | G(1) Down Down F1, 71, 79, DD Shift(u)*b and Calc(d)*a | ||
| 184 | H(2) Down Up F1, 71, 79, UU Shift(u) and Arrow&Calc(u)*a | ||
| 185 | I(3) Up Down F1, F1, 79, DD Shift(ux2) *c | ||
| 186 | J(4) Up Up F1, 79, UU Shift(u) and Arrow&Calc(u)*a | ||
| 187 | |||
| 188 | Case Shift Calc Events Interpret | ||
| 189 | ------------------------------------------------------------------- | ||
| 190 | K(1) ---- Down 71, 79, DD Calc(d)*a | ||
| 191 | L(4) ---- Up F1, 79, UU Shift(u) and Arrow&Calc(u)*a | ||
| 192 | M(1) Hold Down 71, 79, DD Calc(d)*a | ||
| 193 | N Hold Up 79, UU Arrow&Calc(u)*a | ||
| 194 | |||
| 195 | Where DD/UU indicates part of Keypad Down/Up event. | ||
| 196 | *a: Impossible to distinguish btween Arrow and Calc event. | ||
| 197 | *b: Shift(d) event is ignored. | ||
| 198 | *c: Arrow/Calc(d) event is ignored. | ||
| 199 | */ | ||
| 156 | uint8_t m0110_recv_key(void) | 200 | uint8_t m0110_recv_key(void) |
| 157 | { | 201 | { |
| 158 | static uint8_t keybuf = 0x00; | 202 | static uint8_t keybuf = 0x00; |
| 159 | uint8_t key, key2, key3; | 203 | static uint8_t keybuf2 = 0x00; |
| 204 | static uint8_t rawbuf = 0x00; | ||
| 205 | uint8_t raw, raw2, raw3; | ||
| 160 | 206 | ||
| 161 | if (keybuf) { | 207 | if (keybuf) { |
| 162 | key = keybuf; | 208 | raw = keybuf; |
| 163 | keybuf = 0x00; | 209 | keybuf = 0x00; |
| 164 | return key; | 210 | return raw; |
| 211 | } | ||
| 212 | if (keybuf2) { | ||
| 213 | raw = keybuf2; | ||
| 214 | keybuf2 = 0x00; | ||
| 215 | return raw; | ||
| 165 | } | 216 | } |
| 166 | key = instant(); // Use INSTANT for better response. Should be INQUIRY ? | 217 | |
| 167 | switch (key & 0x7F) { | 218 | if (rawbuf) { |
| 219 | raw = rawbuf; | ||
| 220 | rawbuf = 0x00; | ||
| 221 | } else { | ||
| 222 | raw = instant(); // Use INSTANT for better response. Should be INQUIRY ? | ||
| 223 | } | ||
| 224 | switch (KEY(raw)) { | ||
| 168 | case M0110_KEYPAD: | 225 | case M0110_KEYPAD: |
| 169 | // Pad/Arrow keys | 226 | raw2 = instant(); |
| 170 | return (raw2scan(instant()) | M0110_KEYPAD_OFFSET); | 227 | switch (KEY(raw2)) { |
| 228 | case M0110_ARROW_UP: | ||
| 229 | case M0110_ARROW_DOWN: | ||
| 230 | case M0110_ARROW_LEFT: | ||
| 231 | case M0110_ARROW_RIGHT: | ||
| 232 | if (IS_BREAK(raw2)) { | ||
| 233 | // Case B,F,N: | ||
| 234 | keybuf = (raw2scan(raw2) | M0110_CALC_OFFSET); // Calc(u) | ||
| 235 | return (raw2scan(raw2) | M0110_KEYPAD_OFFSET); // Arrow(u) | ||
| 236 | } | ||
| 237 | break; | ||
| 238 | } | ||
| 239 | // Keypad or Arrow | ||
| 240 | return (raw2scan(raw2) | M0110_KEYPAD_OFFSET); | ||
| 171 | break; | 241 | break; |
| 172 | case M0110_SHIFT: | 242 | case M0110_SHIFT: |
| 173 | key2 = instant(); | 243 | raw2 = instant(); |
| 174 | if (key2 == M0110_KEYPAD) { | 244 | switch (KEY(raw2)) { |
| 175 | key3 = instant(); | 245 | case M0110_SHIFT: |
| 176 | switch (key3 & 0x7F) { | 246 | // Case: 5-8,C,G,H |
| 177 | case M0110_ARROW_UP: | 247 | rawbuf = raw2; |
| 178 | case M0110_ARROW_DOWN: | 248 | return raw2scan(raw); // Shift(d/u) |
| 179 | case M0110_ARROW_LEFT: | 249 | break; |
| 180 | case M0110_ARROW_RIGHT: | 250 | case M0110_KEYPAD: |
| 181 | // Calc keys | 251 | // Shift + Arrow, Calc, or etc. |
| 182 | return (raw2scan(key3) | M0110_CALC_OFFSET); | 252 | raw3 = instant(); |
| 183 | default: | 253 | switch (KEY(raw3)) { |
| 184 | // Shift + Pad/Arrow keys | 254 | case M0110_ARROW_UP: |
| 185 | keybuf = raw2scan(key3); | 255 | case M0110_ARROW_DOWN: |
| 186 | return (raw2scan(key) | M0110_KEYPAD_OFFSET); | 256 | case M0110_ARROW_LEFT: |
| 187 | } | 257 | case M0110_ARROW_RIGHT: |
| 188 | } else { | 258 | if (IS_BREAK(raw)) { |
| 189 | // Shift + other keys | 259 | if (IS_BREAK(raw3)) { |
| 190 | keybuf = raw2scan(key2); | 260 | // Case 4: |
| 191 | return raw2scan(key); | 261 | print("(4)\n"); |
| 262 | keybuf2 = raw2scan(raw); // Shift(u) | ||
| 263 | keybuf = (raw2scan(raw3) | M0110_CALC_OFFSET); // Calc(u) | ||
| 264 | return (raw2scan(raw3) | M0110_KEYPAD_OFFSET); // Arrow(u) | ||
| 265 | } else { | ||
| 266 | // Case 3: | ||
| 267 | print("(3)\n"); | ||
| 268 | return (raw2scan(raw)); // Shift(u) | ||
| 269 | } | ||
| 270 | } else { | ||
| 271 | if (IS_BREAK(raw3)) { | ||
| 272 | // Case 2: | ||
| 273 | print("(2)\n"); | ||
| 274 | keybuf = (raw2scan(raw3) | M0110_CALC_OFFSET); // Calc(u) | ||
| 275 | return (raw2scan(raw3) | M0110_KEYPAD_OFFSET); // Arrow(u) | ||
| 276 | } else { | ||
| 277 | // Case 1: | ||
| 278 | print("(1)\n"); | ||
| 279 | return (raw2scan(raw3) | M0110_CALC_OFFSET); // Calc(d) | ||
| 280 | } | ||
| 281 | } | ||
| 282 | break; | ||
| 283 | default: | ||
| 284 | // Shift + Keypad | ||
| 285 | keybuf = (raw2scan(raw3) | M0110_KEYPAD_OFFSET); | ||
| 286 | return raw2scan(raw); // Shift(d/u) | ||
| 287 | break; | ||
| 288 | } | ||
| 289 | break; | ||
| 290 | default: | ||
| 291 | // Shift + Normal keys | ||
| 292 | keybuf = raw2scan(raw2); | ||
| 293 | return raw2scan(raw); // Shift(d/u) | ||
| 294 | break; | ||
| 192 | } | 295 | } |
| 193 | break; | 296 | break; |
| 194 | default: | 297 | default: |
| 195 | // other keys | 298 | // Normal keys |
| 196 | return raw2scan(key); | 299 | return raw2scan(raw); |
| 197 | break; | 300 | break; |
| 198 | } | 301 | } |
| 199 | } | 302 | } |
| @@ -216,10 +319,9 @@ static inline uint8_t inquiry(void) | |||
| 216 | static inline uint8_t instant(void) | 319 | static inline uint8_t instant(void) |
| 217 | { | 320 | { |
| 218 | m0110_send(M0110_INSTANT); | 321 | m0110_send(M0110_INSTANT); |
| 219 | //return m0110_recv(); | ||
| 220 | uint8_t data = m0110_recv(); | 322 | uint8_t data = m0110_recv(); |
| 221 | if (data != 0x7B) { | 323 | if (data != M0110_NULL) { |
| 222 | print("data: "); phex(data); print("\n"); | 324 | phex(data); print(" "); |
| 223 | } | 325 | } |
| 224 | return data; | 326 | return data; |
| 225 | } | 327 | } |
| @@ -326,7 +428,7 @@ CLOCK is always from KEYBOARD. DATA are sent with MSB first. | |||
| 326 | Protocol | 428 | Protocol |
| 327 | -------- | 429 | -------- |
| 328 | COMMAND: | 430 | COMMAND: |
| 329 | Inquiry 0x10 get key event | 431 | Inquiry 0x10 get key event with block |
| 330 | Instant 0x12 get key event | 432 | Instant 0x12 get key event |
| 331 | Model 0x14 get model number(M0110 responds with 0x09) | 433 | Model 0x14 get model number(M0110 responds with 0x09) |
| 332 | bit 7 1 if another device connected(used when keypad exists?) | 434 | bit 7 1 if another device connected(used when keypad exists?) |
| @@ -341,14 +443,13 @@ KEY EVENT: | |||
| 341 | bit 0 always 1 | 443 | bit 0 always 1 |
| 342 | To get scan code use this: ((bits&(1<<7)) | ((bits&0x7F))>>1). | 444 | To get scan code use this: ((bits&(1<<7)) | ((bits&0x7F))>>1). |
| 343 | 445 | ||
| 344 | Note: On the M0110A, the numpad keys and the arrow keys are preceded by 0x79. | 446 | Note: On the M0110A, Keypad keys and Arrow keys are preceded by 0x79. |
| 345 | Moreover, the numpad keys =, /, * and + are preceded by shift-down 0x71 on press and shift-up 0xF1 on release. | 447 | Moreover, some Keypad keys(=, /, * and +) are preceded by 0x71 on press and 0xF1 on release. |
| 346 | So, the data transferred by nupmad 5 is "79 2F" whereas for numpad + it's "71 79 0D". | ||
| 347 | 448 | ||
| 348 | ARROW KEYS: | 449 | ARROW KEYS: |
| 349 | Arrow keys and Pad+,*,/,=(Calc keys) share same byte sequence and its preceding byte | 450 | Arrow keys and Calc keys(+,*,/,= on keypad) share same byte sequence and preceding byte of |
| 350 | 0x71 and 0xF1 means press and release event of SHIFT. These cause very confusing situation. | 451 | Calc keys(0x71 and 0xF1) means press and release event of SHIFT. This causes a very confusing situation, |
| 351 | It is difficult or impossible to tell Calc key from Arrow key with SHIFT in some cases. | 452 | it is difficult or impossible to tell Calc key from Arrow key plus SHIFT in some cases. |
| 352 | 453 | ||
| 353 | Raw key events: | 454 | Raw key events: |
| 354 | press release | 455 | press release |
| @@ -362,9 +463,45 @@ ARROW KEYS: | |||
| 362 | Pad/: 0x71, 0x79, 0x1B 0xF1, 0x79, 0x9B | 463 | Pad/: 0x71, 0x79, 0x1B 0xF1, 0x79, 0x9B |
| 363 | Pad=: 0x71, 0x79, 0x11 0xF1, 0x79, 0x91 | 464 | Pad=: 0x71, 0x79, 0x11 0xF1, 0x79, 0x91 |
| 364 | 465 | ||
| 365 | SCAN CODE: | 466 | |
| 366 | m0111_recv_key() function returns follwing scan codes instead of raw key events. | 467 | RAW CODE: |
| 367 | Scan codes are 1 byte long and bit7 is set when key is released. | 468 | M0110A |
| 469 | ,---------------------------------------------------------. ,---------------. | ||
| 470 | | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Bcksp| |Clr| =| /| *| | ||
| 471 | |---------------------------------------------------------| |---------------| | ||
| 472 | |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7| 8| 9| -| | ||
| 473 | |-----------------------------------------------------' | |---------------| | ||
| 474 | |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| +| | ||
| 475 | |---------------------------------------------------------| |---------------| | ||
| 476 | |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shft|Up | | 1| 2| 3| | | ||
| 477 | |---------------------------------------------------------' |-----------|Ent| | ||
| 478 | |Optio|Mac | Space | \|Lft|Rgt|Dn | | 0| .| | | ||
| 479 | `---------------------------------------------------------' `---------------' | ||
| 480 | ,---------------------------------------------------------. ,---------------. | ||
| 481 | | 65| 25| 27| 29| 2B| 2F| 2D| 35| 39| 33| 3B| 37| 31| 67| |+0F|*11|*1B|*05| | ||
| 482 | |---------------------------------------------------------| |---------------| | ||
| 483 | | 61| 19| 1B| 1D| 1F| 23| 21| 41| 45| 3F| 47| 43| 3D| | |+33|+37|+39|+1D| | ||
| 484 | |-----------------------------------------------------' | |---------------| | ||
| 485 | | 73| 01| 03| 05| 07| 0B| 09| 4D| 51| 4B| 53| 4F| 49| |+2D|+2F|+31|*0D| | ||
| 486 | |---------------------------------------------------------| |---------------| | ||
| 487 | | 71| 0D| 0F| 11| 13| 17| 5B| 5D| 27| 5F| 59| 71|+1B| |+27|+29|+2B| | | ||
| 488 | |---------------------------------------------------------' |-----------|+19| | ||
| 489 | | 75| 6F| 63 | 55|+0D|+05|+11| | +25|+03| | | ||
| 490 | `---------------------------------------------------------' `---------------' | ||
| 491 | + 0x79, 0xDD / 0xF1, 0xUU | ||
| 492 | * 0x71, 0x79,DD / 0xF1, 0x79, 0xUU | ||
| 493 | |||
| 494 | |||
| 495 | MODEL NUMBER: | ||
| 496 | M0110: 0x09 00001001 : model number 4 (100) | ||
| 497 | M0110A: 0x0B 00001011 : model number 5 (101) | ||
| 498 | M0110 & M0120: ??? | ||
| 499 | |||
| 500 | |||
| 501 | Scan Code | ||
| 502 | --------- | ||
| 503 | m0110_recv_key() function returns following scan codes instead of raw key events. | ||
| 504 | Scan codes are 1 byte long and MSB(bit7) is set when key is released. | ||
| 368 | 505 | ||
| 369 | M0110 | 506 | M0110 |
| 370 | ,---------------------------------------------------------. | 507 | ,---------------------------------------------------------. |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Copyright 2011 Jun WAKO <wakojun@gmail.com> | 2 | Copyright 2011,2012 Jun WAKO <wakojun@gmail.com> |
| 3 | 3 | ||
| 4 | This software is licensed with a Modified BSD License. | 4 | This software is licensed with a Modified BSD License. |
| 5 | All of this is supposed to be Free Software, Open Source, DFSG-free, | 5 | All of this is supposed to be Free Software, Open Source, DFSG-free, |
diff --git a/m0110_usb/README.md b/m0110_usb/README.md index a948af91b..92b58f684 100644 --- a/m0110_usb/README.md +++ b/m0110_usb/README.md | |||
| @@ -105,15 +105,15 @@ You can change keymaps by editing *keymap.c*. | |||
| 105 | `---------------------------------------------------------' `---------------' | 105 | `---------------------------------------------------------' `---------------' |
| 106 | #### *HHKB/WASD cursor Layer(Fn0)* | 106 | #### *HHKB/WASD cursor Layer(Fn0)* |
| 107 | ,---------------------------------------------------------. ,---------------. | 107 | ,---------------------------------------------------------. ,---------------. |
| 108 | |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delet| |Nlk| =| /| *| | 108 | |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delet| |Nlk|Mb1|Mb3|Mb2| |
| 109 | |---------------------------------------------------------| |---------------| | 109 | |---------------------------------------------------------| |---------------| |
| 110 | |Caps |Hom| Up|PgU| | | | |Psc|Slk|Pau|Up |Ins| | | 7| 8| 9| -| | 110 | |Caps |Hom| Up|PgU| | | | |Psc|Slk|Pau|Up |Ins| | |MwD|McU|MwU|MwU| |
| 111 | |-----------------------------------------------------' | |---------------| | 111 | |-----------------------------------------------------' | |---------------| |
| 112 | |Fn0 |Lef|Dow|Rig| | | | |Hom|PgU|Lef|Rig|Return| | 4| 5| 6| +| | 112 | |Fn0 |Lef|Dow|Rig| | | | |Hom|PgU|Lef|Rig|Return| |McL|McD|McR|MwD| |
| 113 | |---------------------------------------------------------| |---------------| | 113 | |---------------------------------------------------------| |---------------| |
| 114 | |Shift |End| |PgD| |VoD|VoU|Mut|End|PgD|Dow|Shif|Up | | 1| 2| 3| | | 114 | |Shift |End| |PgD| |VoD|VoU|Mut|End|PgD|Dow|Shif|Up | |MwL|McD|MwR| | |
| 115 | |---------------------------------------------------------| |-----------|Ent| | 115 | |---------------------------------------------------------| |-----------|Mb2| |
| 116 | |Ctrl |Alt | Space | \|Lft|Rgt|Dn | | 0| .| | | 116 | |Ctrl |Alt | Space |Gui | \|Lft|Rgt|Dn | | Mb1|Mb3| | |
| 117 | `---------------------------------------------------------' `---------------' | 117 | `---------------------------------------------------------' `---------------' |
| 118 | 118 | ||
| 119 | 119 | ||
| @@ -124,18 +124,3 @@ You can use [PJRC HID listen](http://www.pjrc.com/teensy/hid_listen.html) to see | |||
| 124 | 124 | ||
| 125 | The converter has some functions for debug, press `Alt+Gui+H` simultaneously to get help. | 125 | The converter has some functions for debug, press `Alt+Gui+H` simultaneously to get help. |
| 126 | These function is totally undocumented, tentative, inconsistent and buggy. | 126 | These function is totally undocumented, tentative, inconsistent and buggy. |
| 127 | |||
| 128 | |||
| 129 | |||
| 130 | Arrow Keys | ||
| 131 | ---------- | ||
| 132 | Dedicated arrow keys of the M0110A are transmitting the same scancodes as the keypad but also, | ||
| 133 | its [=], [/], [*] and [+] keys (hereafter referred to as "calc" keys) are not assigned new | ||
| 134 | scancodes but, instead, transmit a sequence of scancodes which emulates the [Shift] key press, | ||
| 135 | followed by the same scancode sequence of the arrow keys! | ||
| 136 | The problem with that approach is that, while in most cases it's easy to distinguish between | ||
| 137 | a user-generated [Shift] key event (press or release) followed by an arrow or a calc key and | ||
| 138 | a simulated [Shift] key event generated upon a calc key event, when the user is typing fairly | ||
| 139 | fast, it is possible that the two events become indistinguishable, and produce undesired results | ||
| 140 | -- nothing major, though, just one or two stray characters or cursor movements; it will NOT | ||
| 141 | format your drives, kill your cat or make your wife run away with the pizza boy. | ||
diff --git a/m0110_usb/config.h b/m0110_usb/config.h index de20d7c88..4563d6da5 100644 --- a/m0110_usb/config.h +++ b/m0110_usb/config.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> | 2 | Copyright 2011,2012 Jun Wako <wakojun@gmail.com> |
| 3 | 3 | ||
| 4 | This program is free software: you can redistribute it and/or modify | 4 | This program is free software: you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
diff --git a/m0110_usb/keymap.c b/m0110_usb/keymap.c index 31399c343..939010c6d 100644 --- a/m0110_usb/keymap.c +++ b/m0110_usb/keymap.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> | 2 | Copyright 2011,2012 Jun Wako <wakojun@gmail.com> |
| 3 | 3 | ||
| 4 | This program is free software: you can redistribute it and/or modify | 4 | This program is free software: you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
| @@ -88,7 +88,7 @@ static const uint8_t PROGMEM fn_keycode[] = { | |||
| 88 | static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 88 | static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { |
| 89 | /* | 89 | /* |
| 90 | * The keymap works with both M0110 and M0110A keyboards. As you can see, the M0110A is a superset | 90 | * The keymap works with both M0110 and M0110A keyboards. As you can see, the M0110A is a superset |
| 91 | * of the M0110 keyboard, with only one exception: the right Alt key(Enter in M0110) does not exist | 91 | * of the M0110 keyboard, with only one exception: 'Enter' in M0110 does not exist |
| 92 | * on the M0110A, but since it generates a unique scan code which is not used for some other key in | 92 | * on the M0110A, but since it generates a unique scan code which is not used for some other key in |
| 93 | * the M0110A, they are totally interchangeable. In fact, the M0110A is functionally (almost) | 93 | * the M0110A, they are totally interchangeable. In fact, the M0110A is functionally (almost) |
| 94 | * identical to the combination of the M0110 along with the M0120 keypad. The only difference | 94 | * identical to the combination of the M0110 along with the M0120 keypad. The only difference |
| @@ -110,18 +110,19 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 110 | * |Ctrl |Alt | Space |Gui| \|Lft|Rgt|Dn | | 0| .| | | 110 | * |Ctrl |Alt | Space |Gui| \|Lft|Rgt|Dn | | 0| .| | |
| 111 | * `---------------------------------------------------------' `---------------' | 111 | * `---------------------------------------------------------' `---------------' |
| 112 | * | 112 | * |
| 113 | * HHKB/WASD cursor Layer(Fn0): | 113 | * HHKB/WASD/Mouse Layer(Fn0): |
| 114 | * ,---------------------------------------------------------. ,---------------. | 114 | * ,---------------------------------------------------------. ,---------------. |
| 115 | * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delet| |Nlk| =| /| *| | 115 | * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delet| |Nlk|Mb1|Mb3|Mb2| |
| 116 | * |---------------------------------------------------------| |---------------| | 116 | * |---------------------------------------------------------| |---------------| |
| 117 | * |Caps |Hom| Up|PgU| | | | |Psc|Slk|Pau|Up |Ins| | | 7| 8| 9| -| | 117 | * |Caps |Hom| Up|PgU| | | | |Psc|Slk|Pau|Up |Ins| | |MwD|McU|MwU|MwU| |
| 118 | * |-----------------------------------------------------' | |---------------| | 118 | * |-----------------------------------------------------' | |---------------| |
| 119 | * |Fn0 |Lef|Dow|Rig| | | | |Hom|PgU|Lef|Rig|Return| | 4| 5| 6| +| | 119 | * |Fn0 |Lef|Dow|Rig| | | | |Hom|PgU|Lef|Rig|Return| |McL|McD|McR|MwD| |
| 120 | * |---------------------------------------------------------| |---------------| | 120 | * |---------------------------------------------------------| |---------------| |
| 121 | * |Shift |End| |PgD| |VoD|VoU|Mut|End|PgD|Dow|Shif|Up | | 1| 2| 3| | | 121 | * |Shift |End| |PgD| |VoD|VoU|Mut|End|PgD|Dow|Shif|Up | |MwL|McD|MwR| | |
| 122 | * |---------------------------------------------------------| |-----------|Ent| | 122 | * |---------------------------------------------------------| |-----------|Mb2| |
| 123 | * |Ctrl |Alt | Space |Gui | \|Lft|Rgt|Dn | | 0| .| | | 123 | * |Ctrl |Alt | Space |Gui | \|Lft|Rgt|Dn | | Mb1|Mb3| | |
| 124 | * `---------------------------------------------------------' `---------------' | 124 | * `---------------------------------------------------------' `---------------' |
| 125 | * Mb: Mouse Button / Mc: Mouse Cursor / Mw: Mouse Wheel | ||
| 125 | * | 126 | * |
| 126 | * NOTE: You can register Esc by hitting(press&release) Fn0 quickly. | 127 | * NOTE: You can register Esc by hitting(press&release) Fn0 quickly. |
| 127 | * NOTE: Gui between Space and \ is Enter on M0110 not exists on M0110A. | 128 | * NOTE: Gui between Space and \ is Enter on M0110 not exists on M0110A. |
| @@ -130,7 +131,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 130 | */ | 131 | */ |
| 131 | #ifndef HASU | 132 | #ifndef HASU |
| 132 | KEYMAP( | 133 | KEYMAP( |
| 133 | GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, LGUI,PEQL,PSLS,PAST, | 134 | GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, LGUI,EQL, PSLS,PAST, |
| 134 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, P7, P8, P9, PMNS, | 135 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, P7, P8, P9, PMNS, |
| 135 | FN0, A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, | 136 | FN0, A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, |
| 136 | LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, UP, P1, P2, P3, PENT, | 137 | LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, UP, P1, P2, P3, PENT, |
| @@ -138,17 +139,17 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 138 | ), | 139 | ), |
| 139 | // HHKB & WASD | 140 | // HHKB & WASD |
| 140 | KEYMAP( | 141 | KEYMAP( |
| 141 | ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,PEQL,PSLS,PAST, | 142 | ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,BTN1,BTN3,BTN2, |
| 142 | CAPS,HOME,UP, PGUP,NO, NO, NO, NO, PSCR,SLCK,BRK, UP, INS, P7, P8, P9, PMNS, | 143 | CAPS,HOME,UP, PGUP,NO, NO, NO, NO, PSCR,SLCK,BRK, UP, INS, WH_D,MS_U,WH_U,WH_U, |
| 143 | FN0, LEFT,DOWN,RGHT,NO, NO, NO, NO, HOME,PGUP,LEFT,RGHT, ENT, P4, P5, P6, PPLS, | 144 | FN0, LEFT,DOWN,RGHT,NO, NO, NO, NO, HOME,PGUP,LEFT,RGHT, ENT, MS_L,MS_D,MS_R,WH_D, |
| 144 | LSFT,END, NO, PGDN,NO, VOLD,VOLU,MUTE,END, PGDN,DOWN, UP, P1, P2, P3, PENT, | 145 | LSFT,END, NO, PGDN,NO, VOLD,VOLU,MUTE,END, PGDN,DOWN, UP, WH_L,MS_D,WH_R,BTN2, |
| 145 | LCTL,LALT, SPC, LGUI,BSLS,LEFT,RGHT,DOWN, P0, PDOT | 146 | LCTL,LALT, SPC, LGUI,BSLS,LEFT,RGHT,DOWN, BTN1, BTN3 |
| 146 | ), | 147 | ), |
| 147 | #else | 148 | #else |
| 148 | // hasu's keymap | 149 | // hasu's keymap |
| 149 | // To enable use this 'make' option: make EXTRAFLAGS=-DHASU | 150 | // To enable use this 'make' option: make EXTRAFLAGS=-DHASU |
| 150 | KEYMAP( | 151 | KEYMAP( |
| 151 | ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, ESC, PEQL,PSLS,PAST, | 152 | ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, LGUI,EQL, PSLS,PAST, |
| 152 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, P7, P8, P9, PMNS, | 153 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, P7, P8, P9, PMNS, |
| 153 | LCTL,A, S, D, F, G, H, J, K, L, FN1, QUOT, ENT, P4, P5, P6, PPLS, | 154 | LCTL,A, S, D, F, G, H, J, K, L, FN1, QUOT, ENT, P4, P5, P6, PPLS, |
| 154 | LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN2, FN3, P1, P2, P3, PENT, | 155 | LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN2, FN3, P1, P2, P3, PENT, |
| @@ -156,7 +157,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 156 | ), | 157 | ), |
| 157 | // HHKB & WASD | 158 | // HHKB & WASD |
| 158 | KEYMAP( | 159 | KEYMAP( |
| 159 | GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,PEQL,PSLS,PAST, | 160 | GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,EQL, PSLS,PAST, |
| 160 | CAPS,HOME,UP, PGUP,NO, NO, NO, NO, PSCR,SLCK,BRK, UP, INS, P7, P8, P9, PMNS, | 161 | CAPS,HOME,UP, PGUP,NO, NO, NO, NO, PSCR,SLCK,BRK, UP, INS, P7, P8, P9, PMNS, |
| 161 | LCTL,LEFT,DOWN,RGHT,NO, NO, NO, NO, HOME,PGUP,LEFT,RGHT, ENT, P4, P5, P6, PPLS, | 162 | LCTL,LEFT,DOWN,RGHT,NO, NO, NO, NO, HOME,PGUP,LEFT,RGHT, ENT, P4, P5, P6, PPLS, |
| 162 | LSFT,END, NO, PGDN,NO, VOLD,VOLU,MUTE,END, PGDN,DOWN, FN3, P1, P2, P3, PENT, | 163 | LSFT,END, NO, PGDN,NO, VOLD,VOLU,MUTE,END, PGDN,DOWN, FN3, P1, P2, P3, PENT, |
| @@ -164,7 +165,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 164 | ), | 165 | ), |
| 165 | // vi mousekeys | 166 | // vi mousekeys |
| 166 | KEYMAP( | 167 | KEYMAP( |
| 167 | GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,PEQL,PSLS,PAST, | 168 | GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,EQL, PSLS,PAST, |
| 168 | CAPS,NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,NO, NO, NO, P7, P8, P9, PMNS, | 169 | CAPS,NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,NO, NO, NO, P7, P8, P9, PMNS, |
| 169 | NO, VOLD,VOLU,MUTE,NO, NO, MS_L,MS_D,MS_U,MS_R,FN1, NO, ENT, P4, P5, P6, PPLS, | 170 | NO, VOLD,VOLU,MUTE,NO, NO, MS_L,MS_D,MS_U,MS_R,FN1, NO, ENT, P4, P5, P6, PPLS, |
| 170 | LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,NO, NO, NO, UP, P1, P2, P3, PENT, | 171 | LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,NO, NO, NO, UP, P1, P2, P3, PENT, |
| @@ -172,7 +173,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 172 | ), | 173 | ), |
| 173 | // vi cusorkeys | 174 | // vi cusorkeys |
| 174 | KEYMAP( | 175 | KEYMAP( |
| 175 | GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,PEQL,PSLS,PAST, | 176 | GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,EQL, PSLS,PAST, |
| 176 | CAPS,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, NO, NO, NO, P7, P8, P9, PMNS, | 177 | CAPS,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, NO, NO, NO, P7, P8, P9, PMNS, |
| 177 | NO, NO, NO, NO, NO, NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, P4, P5, P6, PPLS, | 178 | NO, NO, NO, NO, NO, NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, P4, P5, P6, PPLS, |
| 178 | LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, UP, P1, P2, P3, PENT, | 179 | LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, UP, P1, P2, P3, PENT, |
diff --git a/m0110_usb/matrix.c b/m0110_usb/matrix.c index b28045b9c..1ca6894c4 100644 --- a/m0110_usb/matrix.c +++ b/m0110_usb/matrix.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> | 2 | Copyright 2011,2012 Jun Wako <wakojun@gmail.com> |
| 3 | 3 | ||
| 4 | This program is free software: you can redistribute it and/or modify | 4 | This program is free software: you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
| @@ -36,11 +36,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 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 | |||
| 44 | 39 | ||
| 45 | static bool is_modified = false; | 40 | static bool is_modified = false; |
| 46 | 41 | ||
| @@ -48,9 +43,6 @@ static bool is_modified = false; | |||
| 48 | static uint8_t *matrix; | 43 | static uint8_t *matrix; |
| 49 | static uint8_t _matrix0[MATRIX_ROWS]; | 44 | static uint8_t _matrix0[MATRIX_ROWS]; |
| 50 | 45 | ||
| 51 | #ifdef MATRIX_HAS_GHOST | ||
| 52 | static bool matrix_has_ghost_in_row(uint8_t row); | ||
| 53 | #endif | ||
| 54 | static void register_key(uint8_t key); | 46 | static void register_key(uint8_t key); |
| 55 | 47 | ||
| 56 | 48 | ||
| @@ -100,20 +92,6 @@ uint8_t matrix_scan(void) | |||
| 100 | return 0; | 92 | return 0; |
| 101 | } else if (key == M0110_ERROR) { | 93 | } else if (key == M0110_ERROR) { |
| 102 | return 0; | 94 | 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); | ||
| 117 | } else { | 95 | } else { |
| 118 | #ifdef MATRIX_HAS_LOCKING_CAPS | 96 | #ifdef MATRIX_HAS_LOCKING_CAPS |
| 119 | if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { | 97 | if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { |
| @@ -133,7 +111,7 @@ uint8_t matrix_scan(void) | |||
| 133 | } | 111 | } |
| 134 | 112 | ||
| 135 | if (debug_enable) { | 113 | if (debug_enable) { |
| 136 | print("key: "); phex(key); print("\n"); | 114 | print("["); phex(key); print("]\n"); |
| 137 | } | 115 | } |
| 138 | return 1; | 116 | return 1; |
| 139 | } | 117 | } |
| @@ -146,12 +124,6 @@ bool matrix_is_modified(void) | |||
| 146 | inline | 124 | inline |
| 147 | bool matrix_has_ghost(void) | 125 | bool matrix_has_ghost(void) |
| 148 | { | 126 | { |
| 149 | #ifdef MATRIX_HAS_GHOST | ||
| 150 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 151 | if (matrix_has_ghost_in_row(i)) | ||
| 152 | return true; | ||
| 153 | } | ||
| 154 | #endif | ||
| 155 | return false; | 127 | return false; |
| 156 | } | 128 | } |
| 157 | 129 | ||
| @@ -186,23 +158,6 @@ uint8_t matrix_key_count(void) | |||
| 186 | return count; | 158 | return count; |
| 187 | } | 159 | } |
| 188 | 160 | ||
| 189 | #ifdef MATRIX_HAS_GHOST | ||
| 190 | inline | ||
| 191 | static bool matrix_has_ghost_in_row(uint8_t row) | ||
| 192 | { | ||
| 193 | // no ghost exists in case less than 2 keys on | ||
| 194 | if (((matrix[row] - 1) & matrix[row]) == 0) | ||
| 195 | return false; | ||
| 196 | |||
| 197 | // ghost exists in case same state as other row | ||
| 198 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 199 | if (i != row && (matrix[i] & matrix[row]) == matrix[row]) | ||
| 200 | return true; | ||
| 201 | } | ||
| 202 | return false; | ||
| 203 | } | ||
| 204 | #endif | ||
| 205 | |||
| 206 | inline | 161 | inline |
| 207 | static void register_key(uint8_t key) | 162 | static void register_key(uint8_t key) |
| 208 | { | 163 | { |
