• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

FreeBSD bhyve keyboard layout patch


コミットメタ情報

リビジョン741ffcc84dfa04e286c6fcd7b197d7d7bde29e62 (tree)
日時2021-01-24 19:51:56
作者Koine Yuusuke(koinec) <koinec@user...>
コミッターKoine Yuusuke(koinec)

ログメッセージ

Fix bugs.

変更サマリ

差分

--- a/work/generate_keymap_tools/generate_kbdmap.c
+++ b/work/generate_keymap_tools/generate_kbdmap.c
@@ -34,7 +34,9 @@
3434 #include<unistd.h>
3535 #include<string.h>
3636
37-// Dup: 0x41->0x02/0x83, 0x54->0x7f/0x84
37+
38+// Intel 8042 Keyboard Controler DeTranslation Table ------------------------
39+// XXX: Duplicate: 0x41->0x02/0x83, 0x54->0x7f/0x84
3840 const uint8_t i8042_detranslation[256] = {
3941 /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
4042 0, 0x76, 0x16, 0x1E, 0x26, 0x25, 0x2e, 0x36, 0x3d, 0x3e, 0x46, 0x45, 0x4e, 0x55, 0x66, 0x0d,
@@ -58,6 +60,7 @@ const uint8_t i8042_detranslation[256] = {
5860 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFa, 0xFb, 0xFc, 0xFd, 0xFe, 0xFf
5961 };
6062
63+// FreeBSD VT kbdmap key str => Xorg keysym value Table ---------------------
6164 struct kbdmap_define {
6265 char keyname[8];
6366 char lockstate;
@@ -73,10 +76,10 @@ struct kbdmap_define kbdmaps[] = {
7376 {"rshift", 'O', {0xffe2, 0, 0}}, /* Right shift */
7477 {"lctrl", 'O', {0xffe3, 0, 0}}, /* Left control */
7578 {"ctrl", 'O', {0xffe3, 0, 0}}, /* Left control (alias name) */
76- {"rctrl", 'O', { 0, 0, 0xffe4}}, /* Right control */
79+ {"rctrl", 'O', {0xffe4, 0, 0}}, /* Right control */
7780 {"lalt", 'O', {0xffe9, 0, 0}}, /* Left alt */
7881 {"alt", 'O', {0xffe9, 0, 0}}, /* Left alt (alias name) */
79- {"ralt", 'O', { 0, 0, 0xffea}}, /* Right alt */
82+ {"ralt", 'O', {0xffea, 0, 0}}, /* Right alt */
8083 {"fkey01", 'O', {0xffbe, 0, 0}}, /* F1 */
8184 {"fkey02", 'O', {0xffbf, 0, 0}}, /* F2 */
8285 {"fkey03", 'O', {0xffc0, 0, 0}}, /* F3 */
@@ -92,21 +95,33 @@ struct kbdmap_define kbdmaps[] = {
9295 {"del", 'O', {0xffff, 0, 0}}, /* Del */
9396 {"slock", 'O', {0xff14, 0, 0}}, /* ScrollLock */
9497 {"nlock", 'O', {0xff7f, 0, 0}}, /* NumLock */
95- {"fkey49", 'N', {0xff95, 0xffb7, 0xff50}}, /* Kyepad home / Keypad 7 / Grey Home */
96- {"fkey50", 'N', {0xff97, 0xffb8, 0xff52}}, /* Keypad up arrow / Keypad 8 / Grey Up arrow */
97- {"fkey51", 'N', {0xff9a, 0xffb9, 0xff55}}, /* Keypad PgUp / Keypad 9 / Grey PgUp*/
98+ {"fkey49", 'N', {0xff95, 0xffb7, 0}}, /* Keypad home / Keypad 7 */
99+ {"fkey49", 'O', {0xff50, 0, 0}}, /* Grey Home */
100+ {"fkey50", 'N', {0xff97, 0xffb8, 0}}, /* Keypad up arrow / Keypad 8 */
101+ {"fkey50", 'O', {0xff52, 0, 0}}, /* Grey Up arrow */
102+ {"fkey51", 'N', {0xff9a, 0xffb9, 0}}, /* Keypad PgUp / Keypad 9 */
103+ {"fkey51", 'O', {0xff55, 0, 0}}, /* Grey PgUp */
98104 {"fkey52", 'N', {0xffad, 0, 0}}, /* Keypad minus */
99- {"fkey53", 'N', {0xff96, 0xffb4, 0xff51}}, /* Keypad left arrow / Keypad 4 / Grey Left Arrow*/
105+ {"fkey53", 'N', {0xff96, 0xffb4, 0}}, /* Keypad left arrow / Keypad 4 */
106+ {"fkey53", 'O', {0xff51, 0, 0}}, /* Grey Left Arrow */
100107 {"fkey54", 'N', {0xffb5, 0, 0}}, /* Keypad 5 */
101- {"fkey55", 'N', {0xff98, 0xffb6, 0xff53}}, /* Keypad right arrow / Keypad 6 / Grey Right arrow */
108+ {"fkey55", 'N', {0xff98, 0xffb6, 0}}, /* Keypad right arrow / Keypad 6 */
109+ {"fkey55", 'O', {0xff53, 0, 0}}, /* Grey Right arrow */
102110 {"fkey56", 'N', {0xffab, 0, 0}}, /* Keypad plus */
103- {"fkey57", 'N', {0xff9c, 0xffb1, 0xff57}}, /* Keypad end / Keypad 1 / Grey End */
104- {"fkey58", 'N', {0xff99, 0xffb2, 0xff54}}, /* Keypad down arrow / Keypad 2 / Grey Down arrow */
105- {"fkey59", 'N', {0xff9b, 0xffb3, 0xff56}}, /* Keypad PgDown / Keypad 3 / Grey PgDown */
106- {"fkey60", 'N', {0xff9e, 0xffb0, 0xff63}}, /* Keypad ins / Keypad 0 / Grey Ins */
111+ {"fkey57", 'N', {0xff9c, 0xffb1, 0}}, /* Keypad end / Keypad 1 */
112+ {"fkey57", 'O', {0xff57, 0, 0}}, /* Grey End */
113+ {"fkey58", 'N', {0xff99, 0xffb2, 0}}, /* Keypad down arrow / Keypad 2 */
114+ {"fkey58", 'O', {0xff54, 0, 0}}, /* Grey Down arrow */
115+ {"fkey59", 'N', {0xff9b, 0xffb3, 0}}, /* Keypad PgDown / Keypad 3 */
116+ {"fkey59", 'O', {0xff56, 0, 0}}, /* Grey PgDown */
117+ {"fkey60", 'N', {0xff9e, 0xffb0, 0}}, /* Keypad ins / Keypad 0 */
118+ {"fkey60", 'O', {0xff63, 0, 0}}, /* Grey Ins */
107119 {"fkey61", 'N', {0xff9f, 0, 0}}, /* Keypad del */
120+ {"fkey62", 'O', {0xffeb, 0, 0}}, /* Left Windows */
121+ {"fkey63", 'O', {0xffec, 0, 0}}, /* Right Windows */
108122 {"null", 'E', { 0, 0, 0}} /* Array Terminator */
109123
124+ // Non Use Keysym
110125 //{"fkey54", '0', {0xff9d, 0, 0}}, /* Keypad empty */
111126 //{"", '0', 0xffaf}, /* Keypad slash */
112127 //{"", '0', 0xffaa}, /* Keypad asterisk */
@@ -114,193 +129,192 @@ struct kbdmap_define kbdmaps[] = {
114129 //{"", '0', 0xffe7, XXX}, Left meta */
115130 //{"", '0', 0xffe8, XXX}, Right meta */
116131 //{"", '0', 0xfe03}, /* AltGr */
117- //{"", '0', 0xffeb}, /* Left Windows */
118- //{"", '0', 0xffec}, /* Right Windows */
119132 };
120133
121134
135+// Xorg-keysym & Keyboard ScanCode Table (default value is US keyboard layout.) --
122136 struct keytranslation {
123137 uint16_t keysym;
124138 uint8_t scancode;
125139 uint8_t prefix;
126140 uint8_t mode;
127141 uint8_t uscode;
142+ char comment[32];
128143 };
129144
130-
131145 struct keytranslation keytrans[] = {
132146 /* 0x2* */
133- { 0x20, 0x29, 0x00, 0xff, 0x29},
134- { 0x21, 0x16, 0x00, 0xff, 0x16},
135- { 0x22, 0x52, 0x00, 0xff, 0x52},
136- { 0x23, 0x26, 0x00, 0xff, 0x26},
137- { 0x24, 0x25, 0x00, 0xff, 0x25},
138- { 0x25, 0x2e, 0x00, 0xff, 0x2e},
139- { 0x26, 0x3d, 0x00, 0xff, 0x3d},
140- { 0x27, 0x52, 0x00, 0xff, 0x52},
141- { 0x28, 0x46, 0x00, 0xff, 0x46},
142- { 0x29, 0x45, 0x00, 0xff, 0x45},
143- { 0x2a, 0x3e, 0x00, 0xff, 0x3e},
144- { 0x2b, 0x55, 0x00, 0xff, 0x55},
145- { 0x2c, 0x41, 0x00, 0xff, 0x41},
146- { 0x2d, 0x4e, 0x00, 0xff, 0x4e},
147- { 0x2e, 0x49, 0x00, 0xff, 0x49},
148- { 0x2f, 0x4a, 0x00, 0xff, 0x4a},
147+ { 0x20, 0x29, 0, 0xff, 0x29, ""},
148+ { 0x21, 0x16, 0, 0xff, 0x16, ""},
149+ { 0x22, 0x52, 0, 0xff, 0x52, ""},
150+ { 0x23, 0x26, 0, 0xff, 0x26, ""},
151+ { 0x24, 0x25, 0, 0xff, 0x25, ""},
152+ { 0x25, 0x2e, 0, 0xff, 0x2e, ""},
153+ { 0x26, 0x3d, 0, 0xff, 0x3d, ""},
154+ { 0x27, 0x52, 0, 0xff, 0x52, ""},
155+ { 0x28, 0x46, 0, 0xff, 0x46, ""},
156+ { 0x29, 0x45, 0, 0xff, 0x45, ""},
157+ { 0x2a, 0x3e, 0, 0xff, 0x3e, ""},
158+ { 0x2b, 0x55, 0, 0xff, 0x55, ""},
159+ { 0x2c, 0x41, 0, 0xff, 0x41, ""},
160+ { 0x2d, 0x4e, 0, 0xff, 0x4e, ""},
161+ { 0x2e, 0x49, 0, 0xff, 0x49, ""},
162+ { 0x2f, 0x4a, 0, 0xff, 0x4a, ""},
149163 /* 0x3* */
150- { 0x30, 0x45, 0x00, 0xff, 0x45},
151- { 0x31, 0x16, 0x00, 0xff, 0x16},
152- { 0x32, 0x1e, 0x00, 0xff, 0x1e},
153- { 0x33, 0x26, 0x00, 0xff, 0x26},
154- { 0x34, 0x25, 0x00, 0xff, 0x25},
155- { 0x35, 0x2e, 0x00, 0xff, 0x2e},
156- { 0x36, 0x36, 0x00, 0xff, 0x36},
157- { 0x37, 0x3d, 0x00, 0xff, 0x3d},
158- { 0x38, 0x3e, 0x00, 0xff, 0x3e},
159- { 0x39, 0x46, 0x00, 0xff, 0x46},
160- { 0x3a, 0x4c, 0x00, 0xff, 0x4c},
161- { 0x3b, 0x4c, 0x00, 0xff, 0x4c},
162- { 0x3c, 0x41, 0x00, 0xff, 0x41},
163- { 0x3d, 0x55, 0x00, 0xff, 0x55},
164- { 0x3e, 0x49, 0x00, 0xff, 0x49},
165- { 0x3f, 0x4a, 0x00, 0xff, 0x4a},
164+ { 0x30, 0x45, 0, 0xff, 0x45, ""},
165+ { 0x31, 0x16, 0, 0xff, 0x16, ""},
166+ { 0x32, 0x1e, 0, 0xff, 0x1e, ""},
167+ { 0x33, 0x26, 0, 0xff, 0x26, ""},
168+ { 0x34, 0x25, 0, 0xff, 0x25, ""},
169+ { 0x35, 0x2e, 0, 0xff, 0x2e, ""},
170+ { 0x36, 0x36, 0, 0xff, 0x36, ""},
171+ { 0x37, 0x3d, 0, 0xff, 0x3d, ""},
172+ { 0x38, 0x3e, 0, 0xff, 0x3e, ""},
173+ { 0x39, 0x46, 0, 0xff, 0x46, ""},
174+ { 0x3a, 0x4c, 0, 0xff, 0x4c, ""},
175+ { 0x3b, 0x4c, 0, 0xff, 0x4c, ""},
176+ { 0x3c, 0x41, 0, 0xff, 0x41, ""},
177+ { 0x3d, 0x55, 0, 0xff, 0x55, ""},
178+ { 0x3e, 0x49, 0, 0xff, 0x49, ""},
179+ { 0x3f, 0x4a, 0, 0xff, 0x4a, ""},
166180 /* 0x4* */
167- { 0x40, 0x1e, 0x00, 0xff, 0x1e},
168- { 0x41, 0x1c, 0x00, 0xff, 0x1c},
169- { 0x42, 0x32, 0x00, 0xff, 0x32},
170- { 0x43, 0x21, 0x00, 0xff, 0x21},
171- { 0x44, 0x23, 0x00, 0xff, 0x23},
172- { 0x45, 0x24, 0x00, 0xff, 0x24},
173- { 0x46, 0x2b, 0x00, 0xff, 0x2b},
174- { 0x47, 0x34, 0x00, 0xff, 0x34},
175- { 0x48, 0x33, 0x00, 0xff, 0x33},
176- { 0x49, 0x43, 0x00, 0xff, 0x43},
177- { 0x4a, 0x3b, 0x00, 0xff, 0x3b},
178- { 0x4b, 0x42, 0x00, 0xff, 0x42},
179- { 0x4c, 0x4b, 0x00, 0xff, 0x4b},
180- { 0x4d, 0x3a, 0x00, 0xff, 0x3a},
181- { 0x4e, 0x31, 0x00, 0xff, 0x31},
182- { 0x4f, 0x44, 0x00, 0xff, 0x44},
181+ { 0x40, 0x1e, 0, 0xff, 0x1e, ""},
182+ { 0x41, 0x1c, 0, 0xff, 0x1c, ""},
183+ { 0x42, 0x32, 0, 0xff, 0x32, ""},
184+ { 0x43, 0x21, 0, 0xff, 0x21, ""},
185+ { 0x44, 0x23, 0, 0xff, 0x23, ""},
186+ { 0x45, 0x24, 0, 0xff, 0x24, ""},
187+ { 0x46, 0x2b, 0, 0xff, 0x2b, ""},
188+ { 0x47, 0x34, 0, 0xff, 0x34, ""},
189+ { 0x48, 0x33, 0, 0xff, 0x33, ""},
190+ { 0x49, 0x43, 0, 0xff, 0x43, ""},
191+ { 0x4a, 0x3b, 0, 0xff, 0x3b, ""},
192+ { 0x4b, 0x42, 0, 0xff, 0x42, ""},
193+ { 0x4c, 0x4b, 0, 0xff, 0x4b, ""},
194+ { 0x4d, 0x3a, 0, 0xff, 0x3a, ""},
195+ { 0x4e, 0x31, 0, 0xff, 0x31, ""},
196+ { 0x4f, 0x44, 0, 0xff, 0x44, ""},
183197 /* 0x5* */
184- { 0x50, 0x4d, 0x00, 0xff, 0x4d},
185- { 0x51, 0x15, 0x00, 0xff, 0x15},
186- { 0x52, 0x2d, 0x00, 0xff, 0x2d},
187- { 0x53, 0x1b, 0x00, 0xff, 0x1b},
188- { 0x54, 0x2c, 0x00, 0xff, 0x2c},
189- { 0x55, 0x3c, 0x00, 0xff, 0x3c},
190- { 0x56, 0x2a, 0x00, 0xff, 0x2a},
191- { 0x57, 0x1d, 0x00, 0xff, 0x1d},
192- { 0x58, 0x22, 0x00, 0xff, 0x22},
193- { 0x59, 0x35, 0x00, 0xff, 0x35},
194- { 0x5a, 0x1a, 0x00, 0xff, 0x1a},
195- { 0x5b, 0x54, 0x00, 0xff, 0x54},
196- { 0x5c, 0x5d, 0x00, 0xff, 0x5d},
197- { 0x5d, 0x5b, 0x00, 0xff, 0x5b},
198- { 0x5e, 0x36, 0x00, 0xff, 0x36},
199- { 0x5f, 0x4e, 0x00, 0xff, 0x4e},
198+ { 0x50, 0x4d, 0, 0xff, 0x4d, ""},
199+ { 0x51, 0x15, 0, 0xff, 0x15, ""},
200+ { 0x52, 0x2d, 0, 0xff, 0x2d, ""},
201+ { 0x53, 0x1b, 0, 0xff, 0x1b, ""},
202+ { 0x54, 0x2c, 0, 0xff, 0x2c, ""},
203+ { 0x55, 0x3c, 0, 0xff, 0x3c, ""},
204+ { 0x56, 0x2a, 0, 0xff, 0x2a, ""},
205+ { 0x57, 0x1d, 0, 0xff, 0x1d, ""},
206+ { 0x58, 0x22, 0, 0xff, 0x22, ""},
207+ { 0x59, 0x35, 0, 0xff, 0x35, ""},
208+ { 0x5a, 0x1a, 0, 0xff, 0x1a, ""},
209+ { 0x5b, 0x54, 0, 0xff, 0x54, ""},
210+ { 0x5c, 0x5d, 0, 0xff, 0x5d, ""},
211+ { 0x5d, 0x5b, 0, 0xff, 0x5b, ""},
212+ { 0x5e, 0x36, 0, 0xff, 0x36, ""},
213+ { 0x5f, 0x4e, 0, 0xff, 0x4e, ""},
200214 /* 0x6* */
201- { 0x60, 0x0e, 0x00, 0xff, 0x0e},
202- { 0x61, 0x1c, 0x00, 0xff, 0x1c},
203- { 0x62, 0x32, 0x00, 0xff, 0x32},
204- { 0x63, 0x21, 0x00, 0xff, 0x21},
205- { 0x64, 0x23, 0x00, 0xff, 0x23},
206- { 0x65, 0x24, 0x00, 0xff, 0x24},
207- { 0x66, 0x2b, 0x00, 0xff, 0x2b},
208- { 0x67, 0x34, 0x00, 0xff, 0x34},
209- { 0x68, 0x33, 0x00, 0xff, 0x33},
210- { 0x69, 0x43, 0x00, 0xff, 0x43},
211- { 0x6a, 0x3b, 0x00, 0xff, 0x3b},
212- { 0x6b, 0x42, 0x00, 0xff, 0x42},
213- { 0x6c, 0x4b, 0x00, 0xff, 0x4b},
214- { 0x6d, 0x3a, 0x00, 0xff, 0x3a},
215- { 0x6e, 0x31, 0x00, 0xff, 0x31},
216- { 0x6f, 0x44, 0x00, 0xff, 0x44},
215+ { 0x60, 0x0e, 0, 0xff, 0x0e, ""},
216+ { 0x61, 0x1c, 0, 0xff, 0x1c, ""},
217+ { 0x62, 0x32, 0, 0xff, 0x32, ""},
218+ { 0x63, 0x21, 0, 0xff, 0x21, ""},
219+ { 0x64, 0x23, 0, 0xff, 0x23, ""},
220+ { 0x65, 0x24, 0, 0xff, 0x24, ""},
221+ { 0x66, 0x2b, 0, 0xff, 0x2b, ""},
222+ { 0x67, 0x34, 0, 0xff, 0x34, ""},
223+ { 0x68, 0x33, 0, 0xff, 0x33, ""},
224+ { 0x69, 0x43, 0, 0xff, 0x43, ""},
225+ { 0x6a, 0x3b, 0, 0xff, 0x3b, ""},
226+ { 0x6b, 0x42, 0, 0xff, 0x42, ""},
227+ { 0x6c, 0x4b, 0, 0xff, 0x4b, ""},
228+ { 0x6d, 0x3a, 0, 0xff, 0x3a, ""},
229+ { 0x6e, 0x31, 0, 0xff, 0x31, ""},
230+ { 0x6f, 0x44, 0, 0xff, 0x44, ""},
217231 /* 0x7* */
218- { 0x70, 0x4d, 0x00, 0xff, 0x4d},
219- { 0x71, 0x15, 0x00, 0xff, 0x15},
220- { 0x72, 0x2d, 0x00, 0xff, 0x2d},
221- { 0x73, 0x1b, 0x00, 0xff, 0x1b},
222- { 0x74, 0x2c, 0x00, 0xff, 0x2c},
223- { 0x75, 0x3c, 0x00, 0xff, 0x3c},
224- { 0x76, 0x2a, 0x00, 0xff, 0x2a},
225- { 0x77, 0x1d, 0x00, 0xff, 0x1d},
226- { 0x78, 0x22, 0x00, 0xff, 0x22},
227- { 0x79, 0x35, 0x00, 0xff, 0x35},
228- { 0x7a, 0x1a, 0x00, 0xff, 0x1a},
229- { 0x7b, 0x54, 0x00, 0xff, 0x54},
230- { 0x7c, 0x5d, 0x00, 0xff, 0x5d},
231- { 0x7d, 0x5b, 0x00, 0xff, 0x5b},
232- { 0x7e, 0x0e, 0x00, 0xff, 0x0e},
233- /*{ 0x7f, 0x00, 0x00, 0xff, 0x00}, */
232+ { 0x70, 0x4d, 0, 0xff, 0x4d, ""},
233+ { 0x71, 0x15, 0, 0xff, 0x15, ""},
234+ { 0x72, 0x2d, 0, 0xff, 0x2d, ""},
235+ { 0x73, 0x1b, 0, 0xff, 0x1b, ""},
236+ { 0x74, 0x2c, 0, 0xff, 0x2c, ""},
237+ { 0x75, 0x3c, 0, 0xff, 0x3c, ""},
238+ { 0x76, 0x2a, 0, 0xff, 0x2a, ""},
239+ { 0x77, 0x1d, 0, 0xff, 0x1d, ""},
240+ { 0x78, 0x22, 0, 0xff, 0x22, ""},
241+ { 0x79, 0x35, 0, 0xff, 0x35, ""},
242+ { 0x7a, 0x1a, 0, 0xff, 0x1a, ""},
243+ { 0x7b, 0x54, 0, 0xff, 0x54, ""},
244+ { 0x7c, 0x5d, 0, 0xff, 0x5d, ""},
245+ { 0x7d, 0x5b, 0, 0xff, 0x5b, ""},
246+ { 0x7e, 0x0e, 0, 0xff, 0x0e, ""},
247+ /*{ 0x7f, 0, 0, 0xff, 0}, */
234248
235249 /* Functional Key --------------- */
236- {0xff08, 0x66, 0x00, 0xff, 0x66}, /* Back space */
237- {0xff09, 0x0d, 0x00, 0xff, 0x0d}, /* Tab */
238- {0xff0d, 0x5a, 0x00, 0xff, 0x5a}, /* Return */
239- {0xff1b, 0x76, 0x00, 0xff, 0x76}, /* Escape */
240- {0xff50, 0x6c, 0xe0, 0xff, 0x6c}, /* Home */
241- {0xff51, 0x6b, 0xe0, 0xff, 0x6b}, /* Left arrow */
242- {0xff52, 0x75, 0xe0, 0xff, 0x75}, /* Up arrow */
243- {0xff53, 0x74, 0xe0, 0xff, 0x74}, /* Right arrow */
244- {0xff54, 0x72, 0xe0, 0xff, 0x72}, /* Down arrow */
245- {0xff55, 0x7d, 0xe0, 0xff, 0x7d}, /* PgUp */
246- {0xff56, 0x7a, 0xe0, 0xff, 0x7a}, /* PgDown */
247- {0xff57, 0x69, 0xe0, 0xff, 0x69}, /* End */
248- {0xff63, 0x70, 0xe0, 0xff, 0x70}, /* Ins */
249- {0xff8d, 0x5a, 0xe0, 0xff, 0x5a}, /* Keypad Enter */
250- {0xffe1, 0x12, 0x00, 0xff, 0x12}, /* Left shift */
251- {0xffe2, 0x59, 0x00, 0xff, 0x59}, /* Right shift */
252- {0xffe3, 0x14, 0x00, 0xff, 0x14}, /* Left control */
253- {0xffe4, 0x14, 0xe0, 0xff, 0x14}, /* Right control */
254- /* {0xffe7, XXX}, Left meta */
255- /* {0xffe8, XXX}, Right meta */
256- {0xffe9, 0x11, 0x00, 0xff, 0x11}, /* Left alt */
257- {0xfe03, 0x11, 0xe0, 0xff, 0x11}, /* AltGr */
258- {0xffea, 0x11, 0xe0, 0xff, 0x11}, /* Right alt */
259- {0xffeb, 0x1f, 0xe0, 0xff, 0x1f}, /* Left Windows */
260- {0xffec, 0x27, 0xe0, 0xff, 0x27}, /* Right Windows */
261- {0xffbe, 0x05, 0x00, 0xff, 0x05}, /* F1 */
262- {0xffbf, 0x06, 0x00, 0xff, 0x06}, /* F2 */
263- {0xffc0, 0x04, 0x00, 0xff, 0x04}, /* F3 */
264- {0xffc1, 0x0c, 0x00, 0xff, 0x0c}, /* F4 */
265- {0xffc2, 0x03, 0x00, 0xff, 0x03}, /* F5 */
266- {0xffc3, 0x0b, 0x00, 0xff, 0x0b}, /* F6 */
267- {0xffc4, 0x83, 0x00, 0xff, 0x83}, /* F7 */
268- {0xffc5, 0x0a, 0x00, 0xff, 0x0a}, /* F8 */
269- {0xffc6, 0x01, 0x00, 0xff, 0x01}, /* F9 */
270- {0xffc7, 0x09, 0x00, 0xff, 0x09}, /* F10 */
271- {0xffc8, 0x78, 0x00, 0xff, 0x78}, /* F11 */
272- {0xffc9, 0x07, 0x00, 0xff, 0x07}, /* F12 */
273- {0xffff, 0x71, 0xe0, 0xff, 0x71}, /* Del */
274- {0xff14, 0x7e, 0x00, 0xff, 0x7e}, /* ScrollLock */
250+ {0xff08, 0x66, 0, 0xff, 0x66, "Back space"},
251+ {0xff09, 0x0d, 0, 0xff, 0x0d, "Tab"},
252+ {0xff0d, 0x5a, 0, 0xff, 0x5a, "Return"},
253+ {0xff1b, 0x76, 0, 0xff, 0x76, "Escape"},
254+ {0xff50, 0x6c, 0xe0, 0xff, 0x6c, "Home"},
255+ {0xff51, 0x6b, 0xe0, 0xff, 0x6b, "Left arrow"},
256+ {0xff52, 0x75, 0xe0, 0xff, 0x75, "Up arrow"},
257+ {0xff53, 0x74, 0xe0, 0xff, 0x74, "Right arrow"},
258+ {0xff54, 0x72, 0xe0, 0xff, 0x72, "Down arrow"},
259+ {0xff55, 0x7d, 0xe0, 0xff, 0x7d, "PgUp"},
260+ {0xff56, 0x7a, 0xe0, 0xff, 0x7a, "PgDown"},
261+ {0xff57, 0x69, 0xe0, 0xff, 0x69, "End"},
262+ {0xff63, 0x70, 0xe0, 0xff, 0x70, "Ins"},
263+ {0xff8d, 0x5a, 0xe0, 0xff, 0x5a, "Keypad Enter"},
264+ {0xffe1, 0x12, 0, 0xff, 0x12, "Left shift"},
265+ {0xffe2, 0x59, 0, 0xff, 0x59, "Right shift"},
266+ {0xffe3, 0x14, 0, 0xff, 0x14, "Left control"},
267+ {0xffe4, 0x14, 0xe0, 0xff, 0x14, "Right control"},
268+/* {0xffe7, 0, 0, 0xff, 0, XXX}, Left meta */
269+/* {0xffe8, 0, 0, 0xff, 0, XXX}, Right meta */
270+ {0xffe9, 0x11, 0, 0xff, 0x11, "Left alt"},
271+ {0xfe03, 0x11, 0xe0, 0xff, 0x11, "AltGr"},
272+ {0xffea, 0x11, 0xe0, 0xff, 0x11, "Right alt"},
273+ {0xffeb, 0x1f, 0xe0, 0xff, 0x1f, "Left Windows"},
274+ {0xffec, 0x27, 0xe0, 0xff, 0x27, "Right Windows"},
275+ {0xffbe, 0x05, 0, 0xff, 0x05, "F1"},
276+ {0xffbf, 0x06, 0, 0xff, 0x06, "F2"},
277+ {0xffc0, 0x04, 0, 0xff, 0x04, "F3"},
278+ {0xffc1, 0x0c, 0, 0xff, 0x0c, "F4"},
279+ {0xffc2, 0x03, 0, 0xff, 0x03, "F5"},
280+ {0xffc3, 0x0b, 0, 0xff, 0x0b, "F6"},
281+ {0xffc4, 0x83, 0, 0xff, 0x83, "F7"},
282+ {0xffc5, 0x0a, 0, 0xff, 0x0a, "F8"},
283+ {0xffc6, 0x01, 0, 0xff, 0x01, "F9"},
284+ {0xffc7, 0x09, 0, 0xff, 0x09, "F10"},
285+ {0xffc8, 0x78, 0, 0xff, 0x78, "F11"},
286+ {0xffc9, 0x07, 0, 0xff, 0x07, "F12"},
287+ {0xffff, 0x71, 0xe0, 0xff, 0x71, "Del"},
288+ {0xff14, 0x7e, 0, 0xff, 0x7e, "ScrollLock"},
275289 /* NumLock and Keypads -----------*/
276- {0xff7f, 0x77, 0x00, 0xff, 0x77}, /* NumLock */
277- {0xffaf, 0x4a, 0xe0, 0xff, 0x4a}, /* Keypad slash */
278- {0xffaa, 0x7c, 0x00, 0xff, 0x7c}, /* Keypad asterisk */
279- {0xffad, 0x7b, 0x00, 0xff, 0x7b}, /* Keypad minus */
280- {0xffab, 0x79, 0x00, 0xff, 0x79}, /* Keypad plus */
281- {0xffb7, 0x6c, 0x00, 0xff, 0x6c}, /* Keypad 7 */
282- {0xff95, 0x6c, 0x00, 0xff, 0x6c}, /* Keypad home */
283- {0xffb8, 0x75, 0x00, 0xff, 0x75}, /* Keypad 8 */
284- {0xff97, 0x75, 0x00, 0xff, 0x75}, /* Keypad up arrow */
285- {0xffb9, 0x7d, 0x00, 0xff, 0x7d}, /* Keypad 9 */
286- {0xff9a, 0x7d, 0x00, 0xff, 0x7d}, /* Keypad PgUp */
287- {0xffb4, 0x6b, 0x00, 0xff, 0x6b}, /* Keypad 4 */
288- {0xff96, 0x6b, 0x00, 0xff, 0x6b}, /* Keypad left arrow */
289- {0xffb5, 0x73, 0x00, 0xff, 0x73}, /* Keypad 5 */
290- {0xff9d, 0x73, 0x00, 0xff, 0x73}, /* Keypad empty */
291- {0xffb6, 0x74, 0x00, 0xff, 0x74}, /* Keypad 6 */
292- {0xff98, 0x74, 0x00, 0xff, 0x74}, /* Keypad right arrow */
293- {0xffb1, 0x69, 0x00, 0xff, 0x69}, /* Keypad 1 */
294- {0xff9c, 0x69, 0x00, 0xff, 0x69}, /* Keypad end */
295- {0xffb2, 0x72, 0x00, 0xff, 0x72}, /* Keypad 2 */
296- {0xff99, 0x72, 0x00, 0xff, 0x72}, /* Keypad down arrow */
297- {0xffb3, 0x7a, 0x00, 0xff, 0x7a}, /* Keypad 3 */
298- {0xff9b, 0x7a, 0x00, 0xff, 0x7a}, /* Keypad PgDown */
299- {0xffb0, 0x70, 0x00, 0xff, 0x70}, /* Keypad 0 */
300- {0xff9e, 0x70, 0x00, 0xff, 0x70}, /* Keypad ins */
301- {0xffae, 0x71, 0x00, 0xff, 0x71}, /* Keypad . */
302- {0xff9f, 0x71, 0x00, 0xff, 0x71}, /* Keypad del */
303- { 0, 0, 0, 0xff, 0} /* Terminator */
290+ {0xff7f, 0x77, 0, 0xff, 0x77, "NumLock"},
291+ {0xffaf, 0x4a, 0xe0, 0xff, 0x4a, "Keypad slash"},
292+ {0xffaa, 0x7c, 0, 0xff, 0x7c, "Keypad asterisk"},
293+ {0xffad, 0x7b, 0, 0xff, 0x7b, "Keypad minus"},
294+ {0xffab, 0x79, 0, 0xff, 0x79, "Keypad plus"},
295+ {0xffb7, 0x6c, 0, 0xff, 0x6c, "Keypad 7"},
296+ {0xff95, 0x6c, 0, 0xff, 0x6c, "Keypad home"},
297+ {0xffb8, 0x75, 0, 0xff, 0x75, "Keypad 8"},
298+ {0xff97, 0x75, 0, 0xff, 0x75, "Keypad up arrow"},
299+ {0xffb9, 0x7d, 0, 0xff, 0x7d, "Keypad 9"},
300+ {0xff9a, 0x7d, 0, 0xff, 0x7d, "Keypad PgUp"},
301+ {0xffb4, 0x6b, 0, 0xff, 0x6b, "Keypad 4"},
302+ {0xff96, 0x6b, 0, 0xff, 0x6b, "Keypad left arrow"},
303+ {0xffb5, 0x73, 0, 0xff, 0x73, "Keypad 5"},
304+ {0xff9d, 0x73, 0, 0xff, 0x73, "Keypad empty"},
305+ {0xffb6, 0x74, 0, 0xff, 0x74, "Keypad 6"},
306+ {0xff98, 0x74, 0, 0xff, 0x74, "Keypad right arrow"},
307+ {0xffb1, 0x69, 0, 0xff, 0x69, "Keypad 1"},
308+ {0xff9c, 0x69, 0, 0xff, 0x69, "Keypad end"},
309+ {0xffb2, 0x72, 0, 0xff, 0x72, "Keypad 2"},
310+ {0xff99, 0x72, 0, 0xff, 0x72, "Keypad down arrow"},
311+ {0xffb3, 0x7a, 0, 0xff, 0x7a, "Keypad 3"},
312+ {0xff9b, 0x7a, 0, 0xff, 0x7a, "Keypad PgDown"},
313+ {0xffb0, 0x70, 0, 0xff, 0x70, "Keypad 0"},
314+ {0xff9e, 0x70, 0, 0xff, 0x70, "Keypad ins"},
315+ {0xffae, 0x71, 0, 0xff, 0x71, "Keypad ."},
316+ {0xff9f, 0x71, 0, 0xff, 0x71, "Keypad del"},
317+ { 0, 0, 0, 0xff, 0, "(Terminator)"}
304318 };
305319
306320
@@ -319,8 +333,6 @@ int parseline(int *scancode, char keyname[][8], char *lockstate, char *line)
319333 if (sscanf((line + 2), "%3d", scancode) != 1)
320334 return 3;
321335
322- //printf(" test %3d: ", *scancode);
323-
324336 for(cnt = 0; cnt < 8; cnt++) {
325337 start = line + 8 + (cnt * 7);
326338 start[6] = '\0';
@@ -331,15 +343,11 @@ int parseline(int *scancode, char keyname[][8], char *lockstate, char *line)
331343 keyname[cnt][2] = '\'';
332344 keyname[cnt][3] = '\0';
333345 }
334- else {
346+ else
335347 sscanf(start, "%6s", keyname[cnt]);
336- }
337-
338- //printf( "[%d] %6s ", cnt, keyname[cnt]);
339348 }
340349
341350 *lockstate = line[65];
342- //printf( "%c\n", *lockstate);
343351
344352 return 0;
345353 }
@@ -347,46 +355,67 @@ int parseline(int *scancode, char keyname[][8], char *lockstate, char *line)
347355
348356 uint16_t get_orig_scancode( int scancode )
349357 {
358+ uint16_t prefix = 0;
350359 uint16_t origcode = 0;
351360
352361 if (scancode >= 256)
353362 return origcode;
354363
355- origcode = i8042_detranslation[scancode];
356-
357364 switch (scancode) {
358- case 0x1C: /* right enter key */
359- case 0x1D: /* right ctrl key */
360- case 0x35: /* keypad divide key */
361- case 0x37: /* print scrn key */
362- case 0x38: /* right alt key (alt gr) */
365+ case 0x59: /* right enter key */
366+ scancode = 0x1C; prefix = 0xE000; break;
367+ case 0x5A: /* right ctrl key */
368+ scancode = 0x1D; prefix = 0xE000; break;
369+ case 0x5B: /* keypad divide key */
370+ scancode = 0x35; prefix = 0xE000; break;
371+ case 0x5C: /* print scrn key */
372+ scancode = 0x37; prefix = 0xE000; break;
373+ case 0x5D: /* right alt key (alt gr) */
374+ scancode = 0x38; prefix = 0xE000; break;
363375 //case 0x68: /* ctrl-pause/break on AT 101 */
364- case 0x47: /* grey home key */
365- case 0x48: /* grey up arrow key */
366- case 0x49: /* grey page up key */
367- case 0x4B: /* grey left arrow key */
368- case 0x4D: /* grey right arrow key */
369- case 0x4F: /* grey end key */
370- case 0x50: /* grey down arrow key */
371- case 0x51: /* grey page down key */
372- case 0x52: /* grey insert key */
373- case 0x53: /* grey delete key */
374- case 0x5B: /* left Window key */
375- case 0x5C: /* right Window key */
376- case 0x5D: /* menu key */
377- case 0x5E: /* power key */
378- case 0x5F: /* sleep key */
379- case 0x63: /* wake key */
380- origcode = 0xE000 | origcode; break;
376+ case 0x5E: /* grey home key */
377+ scancode = 0x47; prefix = 0xE000; break;
378+ case 0x5F: /* grey up arrow key */
379+ scancode = 0x48; prefix = 0xE000; break;
380+ case 0x60: /* grey page up key */
381+ scancode = 0x49; prefix = 0xE000; break;
382+ case 0x61: /* grey left arrow key */
383+ scancode = 0x4B; prefix = 0xE000; break;
384+ case 0x62: /* grey right arrow key */
385+ scancode = 0x4D; prefix = 0xE000; break;
386+ case 0x63: /* grey end key */
387+ scancode = 0x4F; prefix = 0xE000; break;
388+ case 0x64: /* grey down arrow key */
389+ scancode = 0x50; prefix = 0xE000; break;
390+ case 0x65: /* grey page down key */
391+ scancode = 0x51; prefix = 0xE000; break;
392+ case 0x66: /* grey insert key */
393+ scancode = 0x52; prefix = 0xE000; break;
394+ case 0x67: /* grey delete key */
395+ scancode = 0x53; prefix = 0xE000; break;
396+ case 0x69: /* left Window key */
397+ scancode = 0x5B; prefix = 0xE000; break;
398+ case 0x6A: /* right Window key */
399+ scancode = 0x5C; prefix = 0xE000; break;
400+ case 0x6B: /* menu key */
401+ scancode = 0x5D; prefix = 0xE000; break;
402+ case 0x6D: /* power key */
403+ scancode = 0x5E; prefix = 0xE000; break;
404+ case 0x6E: /* sleep key */
405+ scancode = 0x5F; prefix = 0xE000; break;
406+ case 0x6F: /* wake key */
407+ scancode = 0x63; prefix = 0xE000; break;
381408 default:
382409 break;
383410 }
384-
411+
412+ origcode = i8042_detranslation[scancode] | prefix;
413+
385414 return origcode;
386415 }
387416
388417
389-int get_keysym(uint16_t keysym[3], char *keyname, char lockstate)
418+int get_keysym(uint16_t keysym[3], char *keyname, char lockstate, uint16_t scancode)
390419 {
391420 struct kbdmap_define *maptbl;
392421
@@ -400,12 +429,23 @@ int get_keysym(uint16_t keysym[3], char *keyname, char lockstate)
400429
401430 if ((keyname[0] == '\'') && (keyname[2] == '\'') && (keyname[3] == '\0')) {
402431 keysym[0] = (uint16_t)keyname[1];
432+
433+ /* Keypad * */
434+ if ((keysym[0] == '*') && (scancode == 0x7c))
435+ keysym[0] = 0xffaa;
436+ /* Keypad / */
437+ else if ((keysym[0] == '/') && (scancode == 0x4a))
438+ keysym[0] = 0xffaf;
439+ /* Keypad . */
440+ else if ((keysym[0] == '.') && (scancode == 0x71))
441+ keysym[0] = 0xffae;
442+
403443 return 1;
404444 }
405445
406446 maptbl = kbdmaps;
407447 do {
408- if ((!strncmp(maptbl->keyname, keyname, 7)) && (maptbl->lockstate == lockstate)) {
448+ if (!strncmp(maptbl->keyname, keyname, 7)) {
409449 keysym[0] = maptbl->keysym[0];
410450 keysym[1] = maptbl->keysym[1];
411451 keysym[2] = maptbl->keysym[2];
@@ -417,7 +457,7 @@ int get_keysym(uint16_t keysym[3], char *keyname, char lockstate)
417457 }
418458
419459
420-int update_keytranslation( uint16_t keysym, uint16_t origcode, uint8_t mode, uint8_t flag)
460+int update_keytranslation( uint16_t keysym, uint16_t origcode, uint8_t mode)
421461 {
422462 uint8_t scancode;
423463 uint8_t prefix;
@@ -436,16 +476,9 @@ int update_keytranslation( uint16_t keysym, uint16_t origcode, uint8_t mode, uin
436476
437477 if (trans->mode <= mode)
438478 continue;
439- /*
440- else if (trans->mode == mode) {
441- if (trans->scancode < scancode)
442- continue;
443- }
444- */
445479
446- //printf(" %02x: %02x %02x %d\n", keysym, scancode, prefix, mode );
447480 trans->scancode =scancode;
448- trans->prefix = prefix & flag;
481+ trans->prefix = prefix;
449482 trans->mode = mode;
450483 break;
451484
@@ -474,8 +507,12 @@ int output_keytranslation(void)
474507 else
475508 printf(";\t");
476509
477- // for Debug
478- printf(" mode=%x us=%x %x\n", trans->mode, trans->uscode, trans->keysym );
510+ if(trans->keysym < 0x80)
511+ printf("%c (0x%02x)\n",
512+ (unsigned char)(trans->keysym & 0x00ff),
513+ (unsigned char)(trans->keysym & 0x00ff));
514+ else
515+ printf("%s\n", trans->comment);
479516 }
480517
481518 } while( (++trans)->keysym != 0);
@@ -486,20 +523,17 @@ int output_keytranslation(void)
486523
487524 int main( int argc, char *argv[] )
488525 {
489- int err;
526+ int err, fd, cnt, scancode;
490527 int ret = 0;
491- int fd;
492528 char *buf, *next, *line;
493- int scancode;
494529 char lockstate;
495530 char keyname[8][8];
496531 struct stat sb;
497532 size_t sz;
498533 uint16_t origcode;
499- int cnt;
500534 uint16_t keysym[3];
501535
502- if( 3 != argc )
536+ if( 2 != argc )
503537 return 1;
504538
505539 err = stat(argv[1], &sb);
@@ -535,27 +569,21 @@ int main( int argc, char *argv[] )
535569 origcode = get_orig_scancode(scancode);
536570
537571 // alt ---
538- cnt = get_keysym(keysym, keyname[4], lockstate);
572+ cnt = get_keysym(keysym, keyname[4], lockstate, origcode);
539573 for( --cnt; cnt >= 0; cnt-- )
540- update_keytranslation( keysym[cnt], origcode, (uint8_t)4, ((cnt==2) ? 0xff: 0x00));
574+ update_keytranslation( keysym[cnt], origcode, (uint8_t)4);
541575
542576 // shift ---
543- cnt = get_keysym(keysym, keyname[1], lockstate);
577+ cnt = get_keysym(keysym, keyname[1], lockstate, origcode);
544578 for( --cnt; cnt >= 0; cnt-- )
545- update_keytranslation( keysym[cnt], origcode, (uint8_t)1, ((cnt==2) ? 0xff: 0x00));
579+ update_keytranslation( keysym[cnt], origcode, (uint8_t)1);
546580
547581 // base ---
548- cnt = get_keysym(keysym, keyname[0], lockstate);
582+ cnt = get_keysym(keysym, keyname[0], lockstate, origcode);
549583 for( --cnt; cnt >= 0; cnt-- )
550- update_keytranslation( keysym[cnt], origcode, (uint8_t)0, ((cnt==2) ? 0xff: 0x00));
551-
552-
553- //printf(" %2d -> %04x %7s[%4x : %4x : %4x] %c\n",
554- //scancode, origcode,
555- //keyname[0], keysym[0], keysym[1], keysym[2], lockstate);
584+ update_keytranslation( keysym[cnt], origcode, (uint8_t)0);
556585 }
557586 }
558-
559587
560588 output_keytranslation();
561589
@@ -565,4 +593,3 @@ post:
565593 return ret;
566594 }
567595
568-