rendered paste body--- VBoxSDL.cpp 2008-02-21 14:49:16.000000000 -0500
+++ VBoxSDL.cpp.new 2008-02-21 15:54:25.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;
@@ -1151,6 +1152,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 +2846,77 @@
0x53, /* 157 KP_Del */
};
+ // workaround for SDL keyboard translation issues on EVDEV
+ // keycodes > 0x100 are sent as 0xe0 keycode
+ static const uint16_t evdev_keycode_to_pc_keycode[61] =
+ {
+ 0x0, /* 97 EVDEV - RO */
+ //Japanese Keys
+ 0x0, /* 98 EVDEV - KATA */
+ 0x0, /* 99 EVDEV - HIRA */
+ 0x0, /* 100 EVDEV - HENK */
+ 0x0, /* 101 EVDEV - HKTG */
+ 0x0, /* 102 EVDEV - MUHE */
+ 0x0, /* 103 EVDEV - JPCM */
+ //"Normal" Keys
+ 0x1c|0x100, /* 104 EVDEV - KPEN */
+ 0x1d|0x100, /* 105 EVDEV - RCTL */
+ 0x35|0x100, /* 106 EVDEV - KPDV */
+ 0x37|0x100, /* 107 EVDEV - PRSC */
+ 0x38|0x100, /* 108 EVDEV - RALT */
+ 0x0, /* 109 EVDEV - LNFD */
+ 0x47|0x100, /* 110 EVDEV - HOME */
+ 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 */
+ 0x0, /* 121 EVDEV - MUTE */
+ 0x0, /* 122 EVDEV - VOL- */
+ 0x0, /* 123 EVDEV - VOL+ */
+ 0x0, /* 124 EVDEV - POWR */
+ 0x0, /* 125 EVDEV - KPEQ */
+ 0x0, /* 126 EVDEV - I126 */
+ 0x0, /* 127 EVDEV - PAUS */
+ 0x0, /* 128 EVDEV - ???? */
+ 0x0, /* 129 EVDEV - I129 */
+ 0x0, /* 130 EVDEV - HNGL */
+ 0x0, /* 131 EVDEV - HJCV */
+ 0x0, /* 132 EVDEV - AE13 */
+ 0x5b|0x100, /* 133 EVDEV - LWIN */
+ 0x5c|0x100, /* 134 EVDEV - RWIN */
+ 0x5d|0x100, /* 135 EVDEV - MENU */
+ //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
+ 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 +2926,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