Receive the keyboard scancodes from the AT keyboard */
| 172 | |
| 173 | /* Receive the keyboard scancodes from the AT keyboard */ |
| 174 | void Input_EventHandler(uint8 key) |
| 175 | { |
| 176 | uint8 state; |
| 177 | uint8 i; |
| 178 | |
| 179 | state = 0; |
| 180 | |
| 181 | /* escape code for escaped scancodes */ |
| 182 | if (key == 0xE0) { |
| 183 | s_input_extendedKey = true; |
| 184 | return; |
| 185 | } |
| 186 | |
| 187 | /* Key up */ |
| 188 | if ((key & 0x80) != 0) { |
| 189 | key &= 0x7F; |
| 190 | state |= 0x08; /* KEYUP */ |
| 191 | } |
| 192 | |
| 193 | if (s_input_extendedKey) { |
| 194 | s_input_extendedKey = false; |
| 195 | |
| 196 | for (i = 0; i < lengthof(s_translateExtendedMap); i++) { |
| 197 | if (s_translateExtendedMap[i] == key) { |
| 198 | key = s_translateMap[i]; |
| 199 | break; |
| 200 | } |
| 201 | } |
| 202 | if (i == 16) return; |
| 203 | } else if (key == 0x7A) { |
| 204 | key = 0x80; |
| 205 | } else { |
| 206 | key = s_keyTranslate[key & 0x7F]; |
| 207 | } |
| 208 | |
| 209 | if ((s_activeInputMap[7] & 0x4) != 0) return; /* 0x3a : LCTRL */ |
| 210 | if ((s_activeInputMap[7] & 0x50) != 0) state |= 0x04; /* 0x3c 0x3e : LALT RALT => ALT */ |
| 211 | |
| 212 | key = Input_Keyboard_Translate(key) & 0xFF; |
| 213 | |
| 214 | if ((s_activeInputMap[7] & 0x2) != 0) state |= 0x01; /* 0x39 : RSHIFT */ |
| 215 | |
| 216 | if (state == 0x06 && key == 0x68) return; /* state == ALT+??? && key == KP DEL */ |
| 217 | if (state == 0x06 && key == 0x4C) return; /* state == ALT+??? && key == DELETE */ |
| 218 | |
| 219 | Input_HandleInput((state << 8) | key); |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * Clears the given bits in input flags. |
no test coverage detected