--- VBoxSDL.cpp 2008-02-21 14:49:16.000000000 -0500 +++ VBoxSDL.cpp.new 2008-02-22 08:00:05.000000000 -0500 @@ -184,6 +184,7 @@ static SDL_Cursor *gpDefaultCursor = NULL; #ifdef RT_OS_LINUX static Cursor gpDefaultOrigX11Cursor; +static BOOL useEvdevKeymap = FALSE; #endif static SDL_Cursor *gpCustomCursor = NULL; static WMcursor *gpCustomOrigWMcursor = NULL; @@ -643,6 +644,7 @@ #if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) /** @todo UNIXISH_TAP stuff out of main and up to Config.kmk! */ " -tapdev<1-N> Use existing persistent TAP device with the given name\n" " -tapfd<1-N> Use existing TAP device, don't allocate\n" + " -evdevkeymap Use evdev keycode map\n" #endif #ifdef VBOX_VRDP " -vrdp Listen for VRDP connections on port (default if not specified)\n" @@ -1151,6 +1153,12 @@ break; } } +#ifdef RT_OS_LINUX + else if (strcmp(argv[curArg], "-evdevkeymap") == 0) + { + useEvdevKeymap = TRUE; + } +#endif /* RT_OS_LINUX */ #if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) else if (strncmp(argv[curArg], "-tapdev", 7) == 0) { @@ -2839,6 +2847,79 @@ 0x53, /* 157 KP_Del */ }; + // workaround for SDL keyboard translation issues on EVDEV + // keycodes > 0x100 are sent as 0xe0 keycode + // these values are simply pulled from x_keycode_to_pc_keycode + // not a whole lot of testing of the 'weird' values has taken + // place (I don't own a Japanese or Korean keyboard) + static const uint16_t evdev_keycode_to_pc_keycode[61] = + { + 0x0, /* 97 EVDEV - RO ("Internet" Keyboards) */ + 0x0, /* 98 EVDEV - KATA (Katakana) */ + 0x0, /* 99 EVDEV - HIRA (Hiragana) */ + 0x79, /* 100 EVDEV - HENK (Henkan) */ + 0x70, /* 101 EVDEV - HKTG (Hiragana/Katakana toggle) */ + 0x7b, /* 102 EVDEV - MUHE (Muhenkan) */ + 0x0, /* 103 EVDEV - JPCM (KPJPComma) */ + 0x1c|0x100, /* 104 EVDEV - KPEN */ + 0x1d|0x100, /* 105 EVDEV - RCTL */ + 0x35|0x100, /* 106 EVDEV - KPDV */ + 0x37|0x100, /* 107 EVDEV - PRSC ***FIXME*** */ + 0x38|0x100, /* 108 EVDEV - RALT */ + 0x0, /* 109 EVDEV - LNFD ("Internet" Keyboards) */ + 0x47|0x100, /* 110 EVDEV - HOME ***FIXME*** */ + 0x48|0x100, /* 111 EVDEV - UP */ + 0x49|0x100, /* 112 EVDEV - PGUP */ + 0x4b|0x100, /* 113 EVDEV - LEFT */ + 0x4d|0x100, /* 114 EVDEV - RGHT */ + 0x4f|0x100, /* 115 EVDEV - END */ + 0x50|0x100, /* 116 EVDEV - DOWN */ + 0x51|0x100, /* 117 EVDEV - PGDN */ + 0x52|0x100, /* 118 EVDEV - INS */ + 0x53|0x100, /* 119 EVDEV - DELE */ + 0x0, /* 120 EVDEV - I120 ("Internet" Keyboards) */ + //121-124 Solaris Compatibilty Stuff + 0x0, /* 121 EVDEV - MUTE */ + 0x0, /* 122 EVDEV - VOL- */ + 0x0, /* 123 EVDEV - VOL+ */ + 0x0, /* 124 EVDEV - POWR */ + 0x0, /* 125 EVDEV - KPEQ */ + 0x0, /* 126 EVDEV - I126 ("Internet" Keyboards) */ + 0x0, /* 127 EVDEV - PAUS */ + 0x0, /* 128 EVDEV - ???? */ + 0x0, /* 129 EVDEV - I129 ("Internet" Keyboards) */ + 0xf1, /* 130 EVDEV - HNGL (Korean Hangul Latin toggle) */ + 0xf2, /* 131 EVDEV - HJCV (Korean Hangul Hanja toggle) */ + 0x7d, /* 132 EVDEV - AE13 (Yen) */ + 0x5b|0x100, /* 133 EVDEV - LWIN */ + 0x5c|0x100, /* 134 EVDEV - RWIN */ + 0x5d|0x100, /* 135 EVDEV - MENU */ + //136-146 Solaris Stuff + 0x0, /* 136 EVDEV - STOP */ + 0x0, /* 137 EVDEV - AGAI */ + 0x0, /* 138 EVDEV - PROP */ + 0x0, /* 139 EVDEV - UNDO */ + 0x0, /* 140 EVDEV - FRNT */ + 0x0, /* 141 EVDEV - COPY */ + 0x0, /* 142 EVDEV - OPEN */ + 0x0, /* 143 EVDEV - PAST */ + 0x0, /* 144 EVDEV - FIND */ + 0x0, /* 145 EVDEV - CUT */ + 0x0, /* 146 EVDEV - HELP */ + //Extended Keys ("Internet" Keyboards) + 0x0, /* 147 EVDEV - I147 */ + 0x0, /* 148 EVDEV - I148 */ + 0x0, /* 149 EVDEV - I149 */ + 0x0, /* 150 EVDEV - I150 */ + 0x0, /* 151 EVDEV - I151 */ + 0x0, /* 152 EVDEV - I152 */ + 0x0, /* 153 EVDEV - I153 */ + 0x0, /* 154 EVDEV - I154 */ + 0x0, /* 155 EVDEV - I156 */ + 0x0, /* 156 EVDEV - I157 */ + 0x0, /* 157 EVDEV - I158 */ + }; + if (keycode < 9) { keycode = 0; @@ -2848,6 +2929,11 @@ // just an offset (Xorg MIN_KEYCODE) keycode -= 8; } + else if (keycode < 158 && useEvdevKeymap) + { + // apply EVDEV conversion table + keycode = evdev_keycode_to_pc_keycode[keycode - 97]; + } else if (keycode < 158) { // apply conversion table