MCPcopy Create free account
hub / github.com/PaulStoffregen/PS2Keyboard / get_iso8859_code

Function get_iso8859_code

PS2Keyboard.cpp:280–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278#define ALTGR 0x10
279
280static char get_iso8859_code(void)
281{
282 static uint8_t state=0;
283 uint8_t s;
284 char c;
285
286 while (1) {
287 s = get_scan_code();
288 if (!s) return 0;
289 if (s == 0xF0) {
290 state |= BREAK;
291 } else if (s == 0xE0) {
292 state |= MODIFIER;
293 } else {
294 if (state & BREAK) {
295 if (s == 0x12) {
296 state &= ~SHIFT_L;
297 } else if (s == 0x59) {
298 state &= ~SHIFT_R;
299 } else if (s == 0x11 && (state & MODIFIER)) {
300 state &= ~ALTGR;
301 }
302 // CTRL, ALT & WIN keys could be added
303 // but is that really worth the overhead?
304 state &= ~(BREAK | MODIFIER);
305 continue;
306 }
307 if (s == 0x12) {
308 state |= SHIFT_L;
309 continue;
310 } else if (s == 0x59) {
311 state |= SHIFT_R;
312 continue;
313 } else if (s == 0x11 && (state & MODIFIER)) {
314 state |= ALTGR;
315 }
316 c = 0;
317 if (state & MODIFIER) {
318 switch (s) {
319 case 0x70: c = PS2_INSERT; break;
320 case 0x6C: c = PS2_HOME; break;
321 case 0x7D: c = PS2_PAGEUP; break;
322 case 0x71: c = PS2_DELETE; break;
323 case 0x69: c = PS2_END; break;
324 case 0x7A: c = PS2_PAGEDOWN; break;
325 case 0x75: c = PS2_UPARROW; break;
326 case 0x6B: c = PS2_LEFTARROW; break;
327 case 0x72: c = PS2_DOWNARROW; break;
328 case 0x74: c = PS2_RIGHTARROW; break;
329 case 0x4A: c = '/'; break;
330 case 0x5A: c = PS2_ENTER; break;
331 default: break;
332 }
333 } else if ((state & ALTGR) && keymap->uses_altgr) {
334 if (s < PS2_KEYMAP_SIZE)
335 c = pgm_read_byte(keymap->altgr + s);
336 } else if (state & (SHIFT_L | SHIFT_R)) {
337 if (s < PS2_KEYMAP_SIZE)

Callers 3

availableMethod · 0.85
readMethod · 0.85
readUnicodeMethod · 0.85

Calls 1

get_scan_codeFunction · 0.85

Tested by

no test coverage detected