35 {SDL_SCANCODE_GRAVE, 0x0e}, {SDL_SCANCODE_BACKSPACE, 0x66}, {SDL_SCANCODE_TAB, 0xd}, {SDL_SCANCODE_CLEAR, 0}, {SDL_SCANCODE_RETURN, 0x5a},
36 {SDL_SCANCODE_PAUSE, 0}, {SDL_SCANCODE_ESCAPE, 0x76}, {SDL_SCANCODE_SPACE, 0x29}, {SDL_SCANCODE_APOSTROPHE, 0x52}, {SDL_SCANCODE_COMMA, 0x41},
37 {SDL_SCANCODE_MINUS, 0x4e}, {SDL_SCANCODE_PERIOD, 0x49}, {SDL_SCANCODE_SLASH, 0x4a}, {SDL_SCANCODE_0, 0x45}, {SDL_SCANCODE_1, 0x16},
38 {SDL_SCANCODE_2, 0x1e}, {SDL_SCANCODE_3, 0x26}, {SDL_SCANCODE_4, 0x25}, {SDL_SCANCODE_5, 0x2e}, {SDL_SCANCODE_6, 0x36},
39 {SDL_SCANCODE_7, 0x3d}, {SDL_SCANCODE_8, 0x3e}, {SDL_SCANCODE_9, 0x46}, {SDL_SCANCODE_SEMICOLON, 0x4c}, {SDL_SCANCODE_EQUALS, 0x55},
40 {SDL_SCANCODE_LEFTBRACKET, 0x54}, {SDL_SCANCODE_BACKSLASH, 0x5d}, {SDL_SCANCODE_RIGHTBRACKET, 0x5b}, {SDL_SCANCODE_A, 0x1c}, {SDL_SCANCODE_B, 0x32},
41 {SDL_SCANCODE_C, 0x21}, {SDL_SCANCODE_D, 0x23}, {SDL_SCANCODE_E, 0x24}, {SDL_SCANCODE_F, 0x2b}, {SDL_SCANCODE_G, 0x34},
42 {SDL_SCANCODE_H, 0x33}, {SDL_SCANCODE_I, 0x43}, {SDL_SCANCODE_J, 0x3B}, {SDL_SCANCODE_K, 0x42}, {SDL_SCANCODE_L, 0x4B},
43 {SDL_SCANCODE_M, 0x3A}, {SDL_SCANCODE_N, 0x31}, {SDL_SCANCODE_O, 0x44}, {SDL_SCANCODE_P, 0x4D}, {SDL_SCANCODE_Q, 0x15},
44 {SDL_SCANCODE_R, 0x2D}, {SDL_SCANCODE_S, 0x1B}, {SDL_SCANCODE_T, 0x2C}, {SDL_SCANCODE_U, 0x3C}, {SDL_SCANCODE_V, 0x2A},
45 {SDL_SCANCODE_W, 0x1D}, {SDL_SCANCODE_X, 0x22}, {SDL_SCANCODE_Y, 0x35}, {SDL_SCANCODE_Z, 0x1A}, {SDL_SCANCODE_DELETE, 0},
46 {SDL_SCANCODE_UP, 0x175}, {SDL_SCANCODE_DOWN, 0x172}, {SDL_SCANCODE_RIGHT, 0x174}, {SDL_SCANCODE_LEFT, 0x16b}, {SDL_SCANCODE_INSERT, 0},
47 {SDL_SCANCODE_HOME, 0x16c}, {SDL_SCANCODE_END, 0}, {SDL_SCANCODE_PAGEUP, 0}, {SDL_SCANCODE_PAGEDOWN, 0}, {SDL_SCANCODE_F1, 0x05},
48 {SDL_SCANCODE_F2, 0x06}, {SDL_SCANCODE_F3, 0x04}, {SDL_SCANCODE_F4, 0x0c}, {SDL_SCANCODE_F5, 0x03}, {SDL_SCANCODE_F6, 0x0b},
49 {SDL_SCANCODE_F7, 0x83}, {SDL_SCANCODE_F8, 0x0a}, {SDL_SCANCODE_F9, 0x01}, {SDL_SCANCODE_F10, 0x09}, {SDL_SCANCODE_F11, 0x78},
50 {SDL_SCANCODE_F12, 0x07}, {SDL_SCANCODE_RSHIFT, 0x59}, {SDL_SCANCODE_LSHIFT, 0x12}, {SDL_SCANCODE_LCTRL, 0x14}, {SDL_SCANCODE_RCTRL, 0x114},
51 {SDL_SCANCODE_LALT, 0x11}, {SDL_SCANCODE_RALT, 0x111}, {SDL_SCANCODE_NONUSBACKSLASH, 0x61}, {SDL_SCANCODE_KP_ENTER, 0x15a}, {SDL_SCANCODE_KP_0, 0x70},
52 {SDL_SCANCODE_KP_1, 0x69}, {SDL_SCANCODE_KP_2, 0x72}, {SDL_SCANCODE_KP_3, 0x7a}, {SDL_SCANCODE_KP_4, 0x6b}, {SDL_SCANCODE_KP_5, 0x73},
53 {SDL_SCANCODE_KP_6, 0x74}, {SDL_SCANCODE_KP_7, 0x6c}, {SDL_SCANCODE_KP_8, 0x75}, {SDL_SCANCODE_KP_9, 0x7d}, {SDL_SCANCODE_KP_PERIOD, 0x71},
54 {SDL_SCANCODE_KP_PLUS, 0x79}, {SDL_SCANCODE_KP_MINUS, 0x7b}, {SDL_SCANCODE_KP_MULTIPLY, 0x7c}, {SDL_SCANCODE_KP_DIVIDE, 0x14a}, {0, -1}
66 static Uint8 ps2_stream[128];
67 static int ps2_stream_w_pos = 0;
68 static Uint64 virt_cycle_last_read;
75 if (ps2_stream_w_pos) {
84 memmove(ps2_stream, ps2_stream + 1, --ps2_stream_w_pos);
97 static void queue_ps2_device_packet (
Uint8 data )
100 ps2_stream[ps2_stream_w_pos++] = 0;
102 for (
int a = 0; a < 8; a++, data >>=1 ) {
103 ps2_stream[ps2_stream_w_pos++] = (
data & 1);
107 ps2_stream[ps2_stream_w_pos++] = parity;
108 ps2_stream[ps2_stream_w_pos++] = 1;
112 static XEMU_INLINE void emit_ps2_event ( SDL_Scancode
key,
int pressed )
117 if (ps2_stream_w_pos <
sizeof(ps2_stream) - 12 * 3) {
121 queue_ps2_device_packet(0xE0);
123 queue_ps2_device_packet(0xF0);
124 queue_ps2_device_packet(ps2 & 0xFF);
143 if (pos == -1 && handled == 0)
144 emit_ps2_event(
key, pressed);