Пример #1
0
extern void refresh_ps2_controller () {
  static u8 ignore = 0;

  while (((INB(I8042_COMMAND)) & 1) == 0)
      ;

  u8 c = INB (0x60);

  if (ignore) {
    ignore = 0;
    return;
  }
  if (c == 0xE0) {
    ignore = 1;
    return;
  }

  if (get_type(c) != KEYRELEASED)
    return;
  u8 sc = get_scan_code (c);
  scan_to_ascii (sc, W_NULL);
}
Пример #2
0
static char get_ascii_code(void)
{
	static uint8_t state=0;
	uint8_t s;
	char c;

	while (1) {
		s = get_scan_code();
		if (!s) return 0;
		if (s == 0xF0) {
			state |= BREAK;
		} else if (s == 0xE0) {
			state |= MODIFIER;
		} else {
			if (state & BREAK) {
				if (s == 0x12) {
					state &= ~SHIFT_L;
				} else if (s == 0x59) {
					state &= ~SHIFT_R;
                                //start K3NG modification
				} else if (s == 0x14) {
                                        state &= ~CTRL;
                                } else if (s == 0x11) {
                                        state &= ~ALT;
                                }
                                // end K3NG modification
				state &= ~(BREAK | MODIFIER);
				continue;
			}
			if (s == 0x12) {
				state |= SHIFT_L;
				continue;
			} else if (s == 0x59) {
				state |= SHIFT_R;
				continue;
			} else if (s == 0x14) {
                                state |= CTRL;
                                continue;
			} else if (s == 0x11) {
                                state |= ALT;
                                continue;
                        }
			c = 0;
			if (state & MODIFIER) {
				switch (s) {
				  case 0x70: c = PS2_INSERT;      break;
				  case 0x6C: c = PS2_HOME;        break;
				  case 0x7D: c = PS2_PAGEUP;      break;
				  case 0x71: c = PS2_DELETE;      break;
				  case 0x69: c = PS2_END;         break;
				  case 0x7A: c = PS2_PAGEDOWN;    break;
				  case 0x75: c = PS2_UPARROW;     break;
				  case 0x6B: c = PS2_LEFTARROW;   break;
				  case 0x72: c = PS2_DOWNARROW;   break;
				  case 0x74: c = PS2_RIGHTARROW;  break;
				  case 0x4A: c = '/';             break;
				  case 0x5A: c = PS2_ENTER;       break;
				  default: break;
				}
			} else if (state & (SHIFT_L | SHIFT_R)) {
				if (s < sizeof(scan2ascii_shift))
					c = pgm_read_byte(scan2ascii_shift + s);
                        //start K3NG modification
                        } else if ((state & CTRL)) {
				if (s < sizeof(scan2ascii_ctrl))
					c = pgm_read_byte(scan2ascii_ctrl + s);
                        } else if ((state & ALT)) {
				if (s < sizeof(scan2ascii_alt))
					c = pgm_read_byte(scan2ascii_alt + s);
                        //end K3NG modification
			} else {
				if (s < sizeof(scan2ascii_noshift))
					c = pgm_read_byte(scan2ascii_noshift + s);
			}
			state &= ~(BREAK | MODIFIER);
			if (c) return c;
		}
	}
}