--- sourceforge.net/trunk/rdesktop/xkeymap.c 2002/04/19 12:06:08 49 +++ sourceforge.net/trunk/rdesktop/xkeymap.c 2002/04/20 09:41:03 50 @@ -29,6 +29,7 @@ #define KEYMAP_SIZE 4096 #define KEYMAP_MASK (KEYMAP_SIZE - 1) +extern Display *display; extern char keymapname[16]; extern int keylayout; @@ -42,7 +43,6 @@ char *keyname, *p; KeySym keysym; unsigned char keycode; - unsigned int mapcode = 0; strcpy(path, KEYMAP_PATH); strncat(path, mapname, sizeof(path) - sizeof(KEYMAP_PATH)); @@ -98,7 +98,7 @@ return True; } -void xkeymap_init(Display *display) +void xkeymap_init(void) { unsigned int max_keycode; @@ -108,59 +108,66 @@ xkeymap_read(keymapname); } -uint8 xkeymap_translate_key(KeySym keysym, unsigned int keycode) +uint8 xkeymap_translate_key(unsigned int keysym, unsigned int keycode, uint16 *flags) { uint8 scancode; scancode = keymap[keysym & KEYMAP_MASK]; if (scancode != 0) - return scancode; + { + if (scancode & 0x80) + *flags |= KBD_FLAG_EXT; + + return (scancode & 0x7f); + } /* not in keymap, try to interpret the raw scancode */ if ((keycode >= min_keycode) && (keycode <= 0x60)) return (uint8)(keycode - min_keycode); + *flags |= KBD_FLAG_EXT; + switch (keycode) { case 0x61: /* home */ - return 0x47 | 0x80; + return 0x47; case 0x62: /* up arrow */ - return 0x48 | 0x80; + return 0x48; case 0x63: /* page up */ - return 0x49 | 0x80; + return 0x49; case 0x64: /* left arrow */ - return 0x4b | 0x80; + return 0x4b; case 0x66: /* right arrow */ - return 0x4d | 0x80; + return 0x4d; case 0x67: /* end */ - return 0x4f | 0x80; + return 0x4f; case 0x68: /* down arrow */ - return 0x50 | 0x80; + return 0x50; case 0x69: /* page down */ - return 0x51 | 0x80; + return 0x51; case 0x6a: /* insert */ - return 0x52 | 0x80; + return 0x52; case 0x6b: /* delete */ - return 0x53 | 0x80; + return 0x53; case 0x6c: /* keypad enter */ - return 0x1c | 0x80; + return 0x1c; case 0x6d: /* right ctrl */ - return 0x1d | 0x80; + return 0x1d; case 0x6f: /* ctrl - print screen */ - return 0x37 | 0x80; + return 0x37; case 0x70: /* keypad '/' */ - return 0x35 | 0x80; + return 0x35; case 0x71: /* right alt */ - return 0x38 | 0x80; + return 0x38; case 0x72: /* ctrl break */ - return 0x46 | 0x80; + return 0x46; case 0x73: /* left window key */ - return 0x5b | 0x80; + return 0x5b; case 0x74: /* right window key */ - return 0x5c | 0x80; + return 0x5c; case 0x75: /* menu key */ - return 0x5d | 0x80; + return 0x5d; } return 0;