VirtualBox

Ticket #1231: evdev_patch

File evdev_patch, 5.1 KB (added by Josh Wright, 17 years ago)
Line 
1--- VBoxSDL.cpp 2008-02-21 14:49:16.000000000 -0500
2+++ VBoxSDL.cpp.new 2008-02-22 08:00:05.000000000 -0500
3@@ -184,6 +184,7 @@
4 static SDL_Cursor *gpDefaultCursor = NULL;
5 #ifdef RT_OS_LINUX
6 static Cursor gpDefaultOrigX11Cursor;
7+static BOOL useEvdevKeymap = FALSE;
8 #endif
9 static SDL_Cursor *gpCustomCursor = NULL;
10 static WMcursor *gpCustomOrigWMcursor = NULL;
11@@ -643,6 +644,7 @@
12 #if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) /** @todo UNIXISH_TAP stuff out of main and up to Config.kmk! */
13 " -tapdev<1-N> <dev> Use existing persistent TAP device with the given name\n"
14 " -tapfd<1-N> <fd> Use existing TAP device, don't allocate\n"
15+ " -evdevkeymap Use evdev keycode map\n"
16 #endif
17 #ifdef VBOX_VRDP
18 " -vrdp <port> Listen for VRDP connections on port (default if not specified)\n"
19@@ -1151,6 +1153,12 @@
20 break;
21 }
22 }
23+#ifdef RT_OS_LINUX
24+ else if (strcmp(argv[curArg], "-evdevkeymap") == 0)
25+ {
26+ useEvdevKeymap = TRUE;
27+ }
28+#endif /* RT_OS_LINUX */
29 #if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
30 else if (strncmp(argv[curArg], "-tapdev", 7) == 0)
31 {
32@@ -2839,6 +2847,79 @@
33 0x53, /* 157 KP_Del */
34 };
35
36+ // workaround for SDL keyboard translation issues on EVDEV
37+ // keycodes > 0x100 are sent as 0xe0 keycode
38+ // these values are simply pulled from x_keycode_to_pc_keycode
39+ // not a whole lot of testing of the 'weird' values has taken
40+ // place (I don't own a Japanese or Korean keyboard)
41+ static const uint16_t evdev_keycode_to_pc_keycode[61] =
42+ {
43+ 0x0, /* 97 EVDEV - RO ("Internet" Keyboards) */
44+ 0x0, /* 98 EVDEV - KATA (Katakana) */
45+ 0x0, /* 99 EVDEV - HIRA (Hiragana) */
46+ 0x79, /* 100 EVDEV - HENK (Henkan) */
47+ 0x70, /* 101 EVDEV - HKTG (Hiragana/Katakana toggle) */
48+ 0x7b, /* 102 EVDEV - MUHE (Muhenkan) */
49+ 0x0, /* 103 EVDEV - JPCM (KPJPComma) */
50+ 0x1c|0x100, /* 104 EVDEV - KPEN */
51+ 0x1d|0x100, /* 105 EVDEV - RCTL */
52+ 0x35|0x100, /* 106 EVDEV - KPDV */
53+ 0x37|0x100, /* 107 EVDEV - PRSC ***FIXME*** */
54+ 0x38|0x100, /* 108 EVDEV - RALT */
55+ 0x0, /* 109 EVDEV - LNFD ("Internet" Keyboards) */
56+ 0x47|0x100, /* 110 EVDEV - HOME ***FIXME*** */
57+ 0x48|0x100, /* 111 EVDEV - UP */
58+ 0x49|0x100, /* 112 EVDEV - PGUP */
59+ 0x4b|0x100, /* 113 EVDEV - LEFT */
60+ 0x4d|0x100, /* 114 EVDEV - RGHT */
61+ 0x4f|0x100, /* 115 EVDEV - END */
62+ 0x50|0x100, /* 116 EVDEV - DOWN */
63+ 0x51|0x100, /* 117 EVDEV - PGDN */
64+ 0x52|0x100, /* 118 EVDEV - INS */
65+ 0x53|0x100, /* 119 EVDEV - DELE */
66+ 0x0, /* 120 EVDEV - I120 ("Internet" Keyboards) */
67+ //121-124 Solaris Compatibilty Stuff
68+ 0x0, /* 121 EVDEV - MUTE */
69+ 0x0, /* 122 EVDEV - VOL- */
70+ 0x0, /* 123 EVDEV - VOL+ */
71+ 0x0, /* 124 EVDEV - POWR */
72+ 0x0, /* 125 EVDEV - KPEQ */
73+ 0x0, /* 126 EVDEV - I126 ("Internet" Keyboards) */
74+ 0x0, /* 127 EVDEV - PAUS */
75+ 0x0, /* 128 EVDEV - ???? */
76+ 0x0, /* 129 EVDEV - I129 ("Internet" Keyboards) */
77+ 0xf1, /* 130 EVDEV - HNGL (Korean Hangul Latin toggle) */
78+ 0xf2, /* 131 EVDEV - HJCV (Korean Hangul Hanja toggle) */
79+ 0x7d, /* 132 EVDEV - AE13 (Yen) */
80+ 0x5b|0x100, /* 133 EVDEV - LWIN */
81+ 0x5c|0x100, /* 134 EVDEV - RWIN */
82+ 0x5d|0x100, /* 135 EVDEV - MENU */
83+ //136-146 Solaris Stuff
84+ 0x0, /* 136 EVDEV - STOP */
85+ 0x0, /* 137 EVDEV - AGAI */
86+ 0x0, /* 138 EVDEV - PROP */
87+ 0x0, /* 139 EVDEV - UNDO */
88+ 0x0, /* 140 EVDEV - FRNT */
89+ 0x0, /* 141 EVDEV - COPY */
90+ 0x0, /* 142 EVDEV - OPEN */
91+ 0x0, /* 143 EVDEV - PAST */
92+ 0x0, /* 144 EVDEV - FIND */
93+ 0x0, /* 145 EVDEV - CUT */
94+ 0x0, /* 146 EVDEV - HELP */
95+ //Extended Keys ("Internet" Keyboards)
96+ 0x0, /* 147 EVDEV - I147 */
97+ 0x0, /* 148 EVDEV - I148 */
98+ 0x0, /* 149 EVDEV - I149 */
99+ 0x0, /* 150 EVDEV - I150 */
100+ 0x0, /* 151 EVDEV - I151 */
101+ 0x0, /* 152 EVDEV - I152 */
102+ 0x0, /* 153 EVDEV - I153 */
103+ 0x0, /* 154 EVDEV - I154 */
104+ 0x0, /* 155 EVDEV - I156 */
105+ 0x0, /* 156 EVDEV - I157 */
106+ 0x0, /* 157 EVDEV - I158 */
107+ };
108+
109 if (keycode < 9)
110 {
111 keycode = 0;
112@@ -2848,6 +2929,11 @@
113 // just an offset (Xorg MIN_KEYCODE)
114 keycode -= 8;
115 }
116+ else if (keycode < 158 && useEvdevKeymap)
117+ {
118+ // apply EVDEV conversion table
119+ keycode = evdev_keycode_to_pc_keycode[keycode - 97];
120+ }
121 else if (keycode < 158)
122 {
123 // apply conversion table

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy