29 |
#define KEYMAP_SIZE 4096 |
#define KEYMAP_SIZE 4096 |
30 |
#define KEYMAP_MASK (KEYMAP_SIZE - 1) |
#define KEYMAP_MASK (KEYMAP_SIZE - 1) |
31 |
|
|
32 |
|
extern Display *display; |
33 |
extern char keymapname[16]; |
extern char keymapname[16]; |
34 |
extern int keylayout; |
extern int keylayout; |
35 |
|
|
43 |
char *keyname, *p; |
char *keyname, *p; |
44 |
KeySym keysym; |
KeySym keysym; |
45 |
unsigned char keycode; |
unsigned char keycode; |
|
unsigned int mapcode = 0; |
|
46 |
|
|
47 |
strcpy(path, KEYMAP_PATH); |
strcpy(path, KEYMAP_PATH); |
48 |
strncat(path, mapname, sizeof(path) - sizeof(KEYMAP_PATH)); |
strncat(path, mapname, sizeof(path) - sizeof(KEYMAP_PATH)); |
98 |
return True; |
return True; |
99 |
} |
} |
100 |
|
|
101 |
void xkeymap_init(Display *display) |
void xkeymap_init(void) |
102 |
{ |
{ |
103 |
unsigned int max_keycode; |
unsigned int max_keycode; |
104 |
|
|
108 |
xkeymap_read(keymapname); |
xkeymap_read(keymapname); |
109 |
} |
} |
110 |
|
|
111 |
uint8 xkeymap_translate_key(KeySym keysym, unsigned int keycode) |
uint8 xkeymap_translate_key(unsigned int keysym, unsigned int keycode, uint16 *flags) |
112 |
{ |
{ |
113 |
uint8 scancode; |
uint8 scancode; |
114 |
|
|
115 |
scancode = keymap[keysym & KEYMAP_MASK]; |
scancode = keymap[keysym & KEYMAP_MASK]; |
116 |
if (scancode != 0) |
if (scancode != 0) |
117 |
return scancode; |
{ |
118 |
|
if (scancode & 0x80) |
119 |
|
*flags |= KBD_FLAG_EXT; |
120 |
|
|
121 |
|
return (scancode & 0x7f); |
122 |
|
} |
123 |
|
|
124 |
/* not in keymap, try to interpret the raw scancode */ |
/* not in keymap, try to interpret the raw scancode */ |
125 |
|
|
126 |
if ((keycode >= min_keycode) && (keycode <= 0x60)) |
if ((keycode >= min_keycode) && (keycode <= 0x60)) |
127 |
return (uint8)(keycode - min_keycode); |
return (uint8)(keycode - min_keycode); |
128 |
|
|
129 |
|
*flags |= KBD_FLAG_EXT; |
130 |
|
|
131 |
switch (keycode) |
switch (keycode) |
132 |
{ |
{ |
133 |
case 0x61: /* home */ |
case 0x61: /* home */ |
134 |
return 0x47 | 0x80; |
return 0x47; |
135 |
case 0x62: /* up arrow */ |
case 0x62: /* up arrow */ |
136 |
return 0x48 | 0x80; |
return 0x48; |
137 |
case 0x63: /* page up */ |
case 0x63: /* page up */ |
138 |
return 0x49 | 0x80; |
return 0x49; |
139 |
case 0x64: /* left arrow */ |
case 0x64: /* left arrow */ |
140 |
return 0x4b | 0x80; |
return 0x4b; |
141 |
case 0x66: /* right arrow */ |
case 0x66: /* right arrow */ |
142 |
return 0x4d | 0x80; |
return 0x4d; |
143 |
case 0x67: /* end */ |
case 0x67: /* end */ |
144 |
return 0x4f | 0x80; |
return 0x4f; |
145 |
case 0x68: /* down arrow */ |
case 0x68: /* down arrow */ |
146 |
return 0x50 | 0x80; |
return 0x50; |
147 |
case 0x69: /* page down */ |
case 0x69: /* page down */ |
148 |
return 0x51 | 0x80; |
return 0x51; |
149 |
case 0x6a: /* insert */ |
case 0x6a: /* insert */ |
150 |
return 0x52 | 0x80; |
return 0x52; |
151 |
case 0x6b: /* delete */ |
case 0x6b: /* delete */ |
152 |
return 0x53 | 0x80; |
return 0x53; |
153 |
case 0x6c: /* keypad enter */ |
case 0x6c: /* keypad enter */ |
154 |
return 0x1c | 0x80; |
return 0x1c; |
155 |
case 0x6d: /* right ctrl */ |
case 0x6d: /* right ctrl */ |
156 |
return 0x1d | 0x80; |
return 0x1d; |
157 |
case 0x6f: /* ctrl - print screen */ |
case 0x6f: /* ctrl - print screen */ |
158 |
return 0x37 | 0x80; |
return 0x37; |
159 |
case 0x70: /* keypad '/' */ |
case 0x70: /* keypad '/' */ |
160 |
return 0x35 | 0x80; |
return 0x35; |
161 |
case 0x71: /* right alt */ |
case 0x71: /* right alt */ |
162 |
return 0x38 | 0x80; |
return 0x38; |
163 |
case 0x72: /* ctrl break */ |
case 0x72: /* ctrl break */ |
164 |
return 0x46 | 0x80; |
return 0x46; |
165 |
case 0x73: /* left window key */ |
case 0x73: /* left window key */ |
166 |
return 0x5b | 0x80; |
return 0x5b; |
167 |
case 0x74: /* right window key */ |
case 0x74: /* right window key */ |
168 |
return 0x5c | 0x80; |
return 0x5c; |
169 |
case 0x75: /* menu key */ |
case 0x75: /* menu key */ |
170 |
return 0x5d | 0x80; |
return 0x5d; |
171 |
} |
} |
172 |
|
|
173 |
return 0; |
return 0; |
183 |
return MOUSE_FLAG_BUTTON3; |
return MOUSE_FLAG_BUTTON3; |
184 |
case Button3: /* right */ |
case Button3: /* right */ |
185 |
return MOUSE_FLAG_BUTTON2; |
return MOUSE_FLAG_BUTTON2; |
186 |
|
case Button4: /* wheel up */ |
187 |
|
return MOUSE_FLAG_BUTTON4; |
188 |
|
case Button5: /* wheel down */ |
189 |
|
return MOUSE_FLAG_BUTTON5; |
190 |
} |
} |
191 |
|
|
192 |
return 0; |
return 0; |