diff options
| author | tmk <nobody@nowhere> | 2013-05-04 14:46:42 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-05-04 14:46:42 +0900 |
| commit | 95001dd6e43645ba7b6d586c6af8d5c421a569fb (patch) | |
| tree | 9d733d29acf33a85407d5d5e36904013f6aad5c3 /converter/terminal_usb/matrix.c | |
| parent | dad9dab995c75b6d6ac54303bc385bb484f63a88 (diff) | |
| download | qmk_firmware-95001dd6e43645ba7b6d586c6af8d5c421a569fb.tar.gz qmk_firmware-95001dd6e43645ba7b6d586c6af8d5c421a569fb.zip | |
Add support of Model F 122 terminal keyboard
- change initialize of keyboard in matrix_scan()
- keymap for 122 keys
- Mafilefie and config.h for LUFA and PS/2 USART
Diffstat (limited to 'converter/terminal_usb/matrix.c')
| -rw-r--r-- | converter/terminal_usb/matrix.c | 110 |
1 files changed, 73 insertions, 37 deletions
diff --git a/converter/terminal_usb/matrix.c b/converter/terminal_usb/matrix.c index a6eff8c1e..36901536f 100644 --- a/converter/terminal_usb/matrix.c +++ b/converter/terminal_usb/matrix.c | |||
| @@ -66,20 +66,12 @@ uint8_t matrix_cols(void) | |||
| 66 | 66 | ||
| 67 | void matrix_init(void) | 67 | void matrix_init(void) |
| 68 | { | 68 | { |
| 69 | print_enable = true; | ||
| 70 | debug_enable = true; | 69 | debug_enable = true; |
| 71 | //debug_matrix = true; | 70 | //debug_matrix = true; |
| 72 | //debug_keyboard = true; | 71 | //debug_keyboard = true; |
| 73 | //debug_mouse = false; | 72 | //debug_mouse = false; |
| 74 | 73 | ||
| 75 | ps2_host_init(); | 74 | ps2_host_init(); |
| 76 | // Make and Break code without Typematic | ||
| 77 | while (ps2_host_send(0xF8) != 0xFA) { | ||
| 78 | debug("send F8: failed\n"); | ||
| 79 | _delay_ms(500); | ||
| 80 | } | ||
| 81 | debug("send F8: OK\n"); | ||
| 82 | |||
| 83 | 75 | ||
| 84 | // initialize matrix state: all keys off | 76 | // initialize matrix state: all keys off |
| 85 | for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00; | 77 | for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00; |
| @@ -92,46 +84,90 @@ uint8_t matrix_scan(void) | |||
| 92 | 84 | ||
| 93 | // scan code reading states | 85 | // scan code reading states |
| 94 | static enum { | 86 | static enum { |
| 95 | INIT, | 87 | RESET, |
| 88 | RESET_RESPONSE, | ||
| 89 | KBD_ID0, | ||
| 90 | KBD_ID1, | ||
| 91 | CONFIG, | ||
| 92 | READY, | ||
| 96 | F0, | 93 | F0, |
| 97 | } state = INIT; | 94 | } state = RESET; |
| 98 | |||
| 99 | 95 | ||
| 100 | is_modified = false; | 96 | is_modified = false; |
| 101 | 97 | ||
| 102 | uint8_t code; | 98 | uint8_t code; |
| 103 | while ((code = ps2_host_recv())) { | 99 | if ((code = ps2_host_recv())) { |
| 104 | debug_hex(code); | 100 | debug("r"); debug_hex(code); debug(" "); |
| 105 | switch (state) { | 101 | } |
| 106 | case INIT: | 102 | |
| 107 | switch (code) { | 103 | switch (state) { |
| 108 | case 0xF0: | 104 | case RESET: |
| 109 | state = F0; | 105 | debug("wFF "); |
| 110 | debug(" "); | 106 | if (ps2_host_send(0xFF) == 0xFA) { |
| 111 | break; | 107 | debug("[ack]\nRESET_RESPONSE: "); |
| 112 | default: // normal key make | 108 | state = RESET_RESPONSE; |
| 113 | if (code < 0x88) { | 109 | } |
| 114 | matrix_make(code); | 110 | break; |
| 115 | } else { | 111 | case RESET_RESPONSE: |
| 116 | debug("unexpected scan code at INIT: "); debug_hex(code); debug("\n"); | 112 | if (code == 0xAA) { |
| 117 | } | 113 | debug("[ok]\nKBD_ID: "); |
| 118 | state = INIT; | 114 | state = KBD_ID0; |
| 119 | debug("\n"); | 115 | } else if (code) { |
| 120 | } | 116 | debug("err\nRESET: "); |
| 121 | break; | 117 | state = RESET; |
| 122 | case F0: // Break code | 118 | } |
| 123 | switch (code) { | 119 | break; |
| 124 | default: | 120 | // after reset receive keyboad ID(2 bytes) |
| 121 | case KBD_ID0: | ||
| 122 | if (code) { | ||
| 123 | state = KBD_ID1; | ||
| 124 | } | ||
| 125 | break; | ||
| 126 | case KBD_ID1: | ||
| 127 | if (code) { | ||
| 128 | debug("\nCONFIG: "); | ||
| 129 | state = CONFIG; | ||
| 130 | } | ||
| 131 | break; | ||
| 132 | case CONFIG: | ||
| 133 | debug("wF8 "); | ||
| 134 | if (ps2_host_send(0xF8) == 0xFA) { | ||
| 135 | debug("[ack]\nREADY\n"); | ||
| 136 | state = READY; | ||
| 137 | } | ||
| 138 | break; | ||
| 139 | case READY: | ||
| 140 | switch (code) { | ||
| 141 | case 0x00: | ||
| 142 | break; | ||
| 143 | case 0xF0: | ||
| 144 | state = F0; | ||
| 145 | debug(" "); | ||
| 146 | break; | ||
| 147 | default: // normal key make | ||
| 148 | if (code < 0x88) { | ||
| 149 | matrix_make(code); | ||
| 150 | } else { | ||
| 151 | debug("unexpected scan code at READY: "); debug_hex(code); debug("\n"); | ||
| 152 | } | ||
| 153 | state = READY; | ||
| 154 | debug("\n"); | ||
| 155 | } | ||
| 156 | break; | ||
| 157 | case F0: // Break code | ||
| 158 | switch (code) { | ||
| 159 | case 0x00: | ||
| 160 | break; | ||
| 161 | default: | ||
| 125 | if (code < 0x88) { | 162 | if (code < 0x88) { |
| 126 | matrix_break(code); | 163 | matrix_break(code); |
| 127 | } else { | 164 | } else { |
| 128 | debug("unexpected scan code at F0: "); debug_hex(code); debug("\n"); | 165 | debug("unexpected scan code at F0: "); debug_hex(code); debug("\n"); |
| 129 | } | 166 | } |
| 130 | state = INIT; | 167 | state = READY; |
| 131 | debug("\n"); | 168 | debug("\n"); |
| 132 | } | 169 | } |
| 133 | break; | 170 | break; |
| 134 | } | ||
| 135 | } | 171 | } |
| 136 | return 1; | 172 | return 1; |
| 137 | } | 173 | } |
