4 #include "../unix/fb_private_console.h"
8 #include <linux/keyboard.h>
11 #define KEY_BUFFER_SIZE 16
12 #define NUM_PAD_KEYS 17
18 #include "../fb_private_hdynload.h"
19 #include "../unix/fb_private_scancodes_x11.h"
44 static const char pad_ascii[
NUM_PAD_KEYS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
'+',
'-',
'*',
'/',
'\r', 0, 0 };
99 unsigned char buffer[128], scancode;
100 int pressed, repeated, num_bytes, i,
key, extended;
102 struct kbentry entry;
103 struct vt_stat vt_state;
105 num_bytes = read(
key_fd, &buffer,
sizeof(buffer));
107 for (i = 0; i < num_bytes; i++) {
109 pressed = (buffer[i] & 0x80) ^ 0x80;
110 repeated = pressed &&
key_state[scancode];
111 key_state[scancode] = pressed;
129 entry.kb_table |= 0x1;
131 entry.kb_table |= 0x2;
133 entry.kb_table |= 0x4;
135 entry.kb_table |= 0x8;
136 entry.kb_index = scancode;
137 ioctl(
key_fd, KDGKBENT, &entry);
141 else if (entry.kb_value == K_NOSUCHMAP)
144 key = KVAL(entry.kb_value);
145 switch (KTYP(entry.kb_value)) {
169 if( pressed && (ioctl(
key_fd, VT_GETSTATE, &vt_state) >= 0) ) {
170 orig_vt = vt_state.v_active;
174 ioctl(
key_fd, KDSETMODE, KD_TEXT);
176 ioctl(
key_fd, VT_ACTIVATE, vt);
177 ioctl(
key_fd, VT_WAITACTIVE, vt);
178 while (ioctl(
key_fd, VT_WAITACTIVE, orig_vt) < 0)
181 ioctl(
key_fd, KDSETMODE, KD_GRAPHICS);
184 memset(key_state,
FALSE, 128);
186 key_state[scancode] =
FALSE;
201 if( pressed && key ) {
221 unsigned char keymap[32];
228 for (i = 0; i < 256; i++) {
229 if (keymap[i / 8] & (1 << (i & 0x7)))
238 const char *funcs[] = {
239 "XOpenDisplay",
"XCloseDisplay",
"XQueryKeymap",
"XDisplayKeycodes",
"XGetKeyboardMapping",
NULL
254 term.c_cc[VTIME] = 0;
257 (tcsetattr(
key_fd, TCSANOW, &term) < 0) ||
258 (ioctl(
key_fd, KDSKBMODE, K_MEDIUMRAW) < 0)) {
337 void (*gfx_exit)(
void),
339 void (*restore)(
void),
340 void (*key_handler)(
int,
int,
int,
int)
361 ioctl(
key_fd, KDSETMODE, KD_GRAPHICS);
364 ioctl(
key_fd, KDSETMODE, KD_TEXT);