• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

FreeBSD bhyve keyboard layout patch


Commit MetaInfo

Révision3f7a1d1af8b789619505d97d4757b34083bc3a1b (tree)
l'heure2021-01-02 13:34:00
AuteurKoine Yuusuke(koinec) <koinec@user...>
CommiterKoine Yuusuke(koinec)

Message de Log

kbdlayout: regist old version(2020/06/14-v5:rebase src tree)
qemuextkey: regist old versin(2020/06/14-v5:fix scancode tbl)

Change Summary

Modification

--- a/kbdlayout_option/bhyve_kbdlayout_option_fbsd121r.patch
+++ b/kbdlayout_option/bhyve_kbdlayout_option_fbsd121r.patch
@@ -1,6 +1,6 @@
11 diff -upN bhyve_base/Makefile bhyve/Makefile
2---- bhyve_base/Makefile 2020-06-02 20:16:51.532368000 +0900
3-+++ bhyve/Makefile 2020-06-02 20:35:48.179160000 +0900
2+--- bhyve_base/Makefile 2020-06-13 15:59:44.503811000 +0900
3++++ bhyve/Makefile 2020-06-13 15:58:02.502118000 +0900
44 @@ -95,4 +95,6 @@ CFLAGS+=-DGDB_LOG
55
66 WARNS?= 2
@@ -9,8 +9,8 @@ diff -upN bhyve_base/Makefile bhyve/Makefile
99 +
1010 .include <bsd.prog.mk>
1111 diff -upN bhyve_base/bhyve.8 bhyve/bhyve.8
12---- bhyve_base/bhyve.8 2020-06-02 20:16:51.487013000 +0900
13-+++ bhyve/bhyve.8 2020-06-02 20:35:48.180745000 +0900
12+--- bhyve_base/bhyve.8 2020-06-13 15:59:44.500093000 +0900
13++++ bhyve/bhyve.8 2020-06-13 15:58:02.502950000 +0900
1414 @@ -44,6 +44,7 @@
1515 .Op Ar ,threads=n
1616 .Oc
@@ -34,8 +34,8 @@ diff -upN bhyve_base/bhyve.8 bhyve/bhyve.8
3434 Allow devices behind the LPC PCI-ISA bridge to be configured.
3535 The only supported devices are the TTY-class devices
3636 diff -upN bhyve_base/bhyverun.c bhyve/bhyverun.c
37---- bhyve_base/bhyverun.c 2020-06-02 20:16:51.456344000 +0900
38-+++ bhyve/bhyverun.c 2020-06-02 20:35:48.181837000 +0900
37+--- bhyve_base/bhyverun.c 2020-06-13 15:59:44.497748000 +0900
38++++ bhyve/bhyverun.c 2020-06-13 15:58:02.504048000 +0900
3939 @@ -165,6 +165,8 @@ char *vmname;
4040 int guest_ncpus;
4141 uint16_t cores, maxcpus, sockets, threads;
@@ -84,8 +84,8 @@ diff -upN bhyve_base/bhyverun.c bhyve/bhyverun.c
8484 case 'l':
8585 if (strncmp(optarg, "help", strlen(optarg)) == 0) {
8686 diff -upN bhyve_base/bhyverun.h bhyve/bhyverun.h
87---- bhyve_base/bhyverun.h 2020-06-02 20:16:51.511202000 +0900
88-+++ bhyve/bhyverun.h 2020-06-02 20:35:48.182282000 +0900
87+--- bhyve_base/bhyverun.h 2020-06-13 15:59:44.501972000 +0900
88++++ bhyve/bhyverun.h 2020-06-13 15:58:02.504455000 +0900
8989 @@ -39,6 +39,7 @@ extern int guest_ncpus;
9090 extern uint16_t cores, sockets, threads;
9191 extern char *guest_uuid_str;
@@ -94,9 +94,10 @@ diff -upN bhyve_base/bhyverun.h bhyve/bhyverun.h
9494
9595 void *paddr_guest2host(struct vmctx *ctx, uintptr_t addr, size_t len);
9696
97+Common subdirectories: bhyve_base/kbdlayout and bhyve/kbdlayout
9798 diff -upN bhyve_base/ps2kbd.c bhyve/ps2kbd.c
98---- bhyve_base/ps2kbd.c 2020-06-02 20:29:26.881702000 +0900
99-+++ bhyve/ps2kbd.c 2020-06-02 20:35:48.184181000 +0900
99+--- bhyve_base/ps2kbd.c 2020-06-13 15:59:52.769007000 +0900
100++++ bhyve/ps2kbd.c 2020-06-13 15:58:02.505301000 +0900
100101 @@ -31,15 +31,20 @@
101102 __FBSDID("$FreeBSD: releng/12.1/usr.sbin/bhyve/ps2kbd.c 341757 2018-12-09 06:41:57Z araujo $");
102103
@@ -126,8 +127,8 @@ diff -upN bhyve_base/ps2kbd.c bhyve/ps2kbd.c
126127 +
127128 struct fifo {
128129 uint8_t buf[PS2KBD_FIFOSZ];
129- uint8_t trans[PS2KBD_FIFOSZ];
130-@@ -87,7 +94,7 @@ struct extended_translation {
130+ int rindex; /* index to read from */
131+@@ -86,7 +93,7 @@ struct extended_translation {
131132 /*
132133 * FIXME: Pause/break and Print Screen/SysRq require special handling.
133134 */
@@ -136,7 +137,7 @@ diff -upN bhyve_base/ps2kbd.c bhyve/ps2kbd.c
136137 {0xff08, 0x66}, /* Back space */
137138 {0xff09, 0x0d}, /* Tab */
138139 {0xff0d, 0x5a}, /* Return */
139-@@ -159,7 +166,7 @@ static const struct extended_translation extended_tran
140+@@ -158,7 +165,7 @@ static const struct extended_translation extended_tran
140141 };
141142
142143 /* ASCII to type 2 scancode lookup table */
@@ -145,7 +146,7 @@ diff -upN bhyve_base/ps2kbd.c bhyve/ps2kbd.c
145146 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
146147 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
147148 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
148-@@ -319,7 +326,7 @@ ps2kbd_keysym_queue(struct ps2kbd_softc *sc,
149+@@ -336,7 +343,7 @@ ps2kbd_keysym_queue(struct ps2kbd_softc *sc,
149150 assert(pthread_mutex_isowned_np(&sc->mtx));
150151 int e0_prefix, found;
151152 uint8_t code;
@@ -153,8 +154,8 @@ diff -upN bhyve_base/ps2kbd.c bhyve/ps2kbd.c
153154 + struct extended_translation *trans;
154155
155156 if (keycode) {
156- code = (uint8_t)(keycode & 0x7f);
157-@@ -375,10 +382,91 @@ ps2kbd_event(int down, uint32_t keysym, uint32_t keyco
157+ code = keyset1to2_translations[(uint8_t)(keycode & 0x7f)];
158+@@ -392,10 +399,91 @@ ps2kbd_event(int down, uint32_t keysym, uint32_t keyco
158159 atkbdc_event(sc->atkbdc_sc, 1);
159160 }
160161
--- a/kbdlayout_option/bhyve_kbdlayout_option_fbsd13c.patch
+++ b/kbdlayout_option/bhyve_kbdlayout_option_fbsd13c.patch
@@ -1,6 +1,6 @@
11 diff -upN bhyve_base/Makefile bhyve/Makefile
2---- bhyve_base/Makefile 2020-06-03 10:29:29.352291000 +0900
3-+++ bhyve/Makefile 2020-06-03 18:14:34.462454000 +0900
2+--- bhyve_base/Makefile 2020-06-14 16:06:21.223455000 +0900
3++++ bhyve/Makefile 2020-06-14 16:12:32.408499000 +0900
44 @@ -121,4 +121,6 @@ CFLAGS+=-DGDB_LOG
55
66 WARNS?= 2
@@ -9,8 +9,8 @@ diff -upN bhyve_base/Makefile bhyve/Makefile
99 +
1010 .include <bsd.prog.mk>
1111 diff -upN bhyve_base/bhyve.8 bhyve/bhyve.8
12---- bhyve_base/bhyve.8 2020-06-03 10:29:29.331537000 +0900
13-+++ bhyve/bhyve.8 2020-06-03 18:14:34.464867000 +0900
12+--- bhyve_base/bhyve.8 2020-06-14 16:06:21.236090000 +0900
13++++ bhyve/bhyve.8 2020-06-14 16:12:32.409488000 +0900
1414 @@ -47,6 +47,7 @@
1515 .Sm on
1616 .Op Fl G Ar port
@@ -34,8 +34,8 @@ diff -upN bhyve_base/bhyve.8 bhyve/bhyve.8
3434 Allow devices behind the LPC PCI-ISA bridge to be configured.
3535 The only supported devices are the TTY-class devices
3636 diff -upN bhyve_base/bhyverun.c bhyve/bhyverun.c
37---- bhyve_base/bhyverun.c 2020-06-03 10:29:29.370019000 +0900
38-+++ bhyve/bhyverun.c 2020-06-03 18:19:50.608647000 +0900
37+--- bhyve_base/bhyverun.c 2020-06-14 16:06:21.267122000 +0900
38++++ bhyve/bhyverun.c 2020-06-14 16:12:32.410678000 +0900
3939 @@ -188,6 +188,8 @@ const char *vmname;
4040 int guest_ncpus;
4141 uint16_t cores, maxcpus, sockets, threads;
@@ -88,8 +88,8 @@ diff -upN bhyve_base/bhyverun.c bhyve/bhyverun.c
8888 case 'l':
8989 if (strncmp(optarg, "help", strlen(optarg)) == 0) {
9090 diff -upN bhyve_base/bhyverun.h bhyve/bhyverun.h
91---- bhyve_base/bhyverun.h 2020-06-03 10:29:29.289487000 +0900
92-+++ bhyve/bhyverun.h 2020-06-03 18:18:13.198204000 +0900
91+--- bhyve_base/bhyverun.h 2020-06-14 16:06:21.236876000 +0900
92++++ bhyve/bhyverun.h 2020-06-14 16:12:32.410831000 +0900
9393 @@ -39,6 +39,7 @@ extern int guest_ncpus;
9494 extern uint16_t cores, sockets, threads;
9595 extern char *guest_uuid_str;
@@ -100,8 +100,8 @@ diff -upN bhyve_base/bhyverun.h bhyve/bhyverun.h
100100 #ifdef BHYVE_SNAPSHOT
101101 Common subdirectories: bhyve_base/kbdlayout and bhyve/kbdlayout
102102 diff -upN bhyve_base/ps2kbd.c bhyve/ps2kbd.c
103---- bhyve_base/ps2kbd.c 2020-06-03 10:31:37.339319000 +0900
104-+++ bhyve/ps2kbd.c 2020-06-03 18:17:01.983386000 +0900
103+--- bhyve_base/ps2kbd.c 2020-06-14 16:06:49.476779000 +0900
104++++ bhyve/ps2kbd.c 2020-06-14 16:12:32.411172000 +0900
105105 @@ -31,6 +31,7 @@
106106 __FBSDID("$FreeBSD: head/usr.sbin/bhyve/ps2kbd.c 360648 2020-05-05 00:02:04Z jhb $");
107107
@@ -129,8 +129,8 @@ diff -upN bhyve_base/ps2kbd.c bhyve/ps2kbd.c
129129 +
130130 struct fifo {
131131 uint8_t buf[PS2KBD_FIFOSZ];
132- uint8_t trans[PS2KBD_FIFOSZ];
133-@@ -91,7 +97,7 @@ struct extended_translation {
132+ int rindex; /* index to read from */
133+@@ -90,7 +96,7 @@ struct extended_translation {
134134 /*
135135 * FIXME: Pause/break and Print Screen/SysRq require special handling.
136136 */
@@ -139,7 +139,7 @@ diff -upN bhyve_base/ps2kbd.c bhyve/ps2kbd.c
139139 {0xff08, 0x66}, /* Back space */
140140 {0xff09, 0x0d}, /* Tab */
141141 {0xff0d, 0x5a}, /* Return */
142-@@ -163,7 +169,7 @@ static const struct extended_translation extended_tran
142+@@ -162,7 +168,7 @@ static const struct extended_translation extended_tran
143143 };
144144
145145 /* ASCII to type 2 scancode lookup table */
@@ -148,7 +148,7 @@ diff -upN bhyve_base/ps2kbd.c bhyve/ps2kbd.c
148148 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
149149 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
150150 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
151-@@ -323,7 +329,7 @@ ps2kbd_keysym_queue(struct ps2kbd_softc *sc,
151+@@ -340,7 +346,7 @@ ps2kbd_keysym_queue(struct ps2kbd_softc *sc,
152152 assert(pthread_mutex_isowned_np(&sc->mtx));
153153 int e0_prefix, found;
154154 uint8_t code;
@@ -156,8 +156,8 @@ diff -upN bhyve_base/ps2kbd.c bhyve/ps2kbd.c
156156 + struct extended_translation *trans;
157157
158158 if (keycode) {
159- code = (uint8_t)(keycode & 0x7f);
160-@@ -379,10 +385,91 @@ ps2kbd_event(int down, uint32_t keysym, uint32_t keyco
159+ code = keyset1to2_translations[(uint8_t)(keycode & 0x7f)];
160+@@ -396,10 +402,91 @@ ps2kbd_event(int down, uint32_t keysym, uint32_t keyco
161161 atkbdc_event(sc->atkbdc_sc, 1);
162162 }
163163
--- a/qemu_ext_keyevent_msg/bhyve_qemu_ext_key_event_msg_fbsd121r.patch
+++ b/qemu_ext_keyevent_msg/bhyve_qemu_ext_key_event_msg_fbsd121r.patch
@@ -1,38 +1,6 @@
1-diff -upN bhyve_orig/atkbdc.c bhyve/atkbdc.c
2---- bhyve_orig/atkbdc.c 2020-05-01 11:25:57.441270000 +0900
3-+++ bhyve/atkbdc.c 2020-06-02 20:27:26.516809000 +0900
4-@@ -211,24 +211,25 @@ atkbdc_kbd_read(struct atkbdc_softc *sc)
5- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
6- };
7- uint8_t val;
8-+ uint8_t trans;
9- uint8_t release = 0;
10-
11- assert(pthread_mutex_isowned_np(&sc->mtx));
12-
13- if (sc->ram[0] & KBD_TRANSLATION) {
14-- while (ps2kbd_read(sc->ps2kbd_sc, &val) != -1) {
15-+ while (ps2kbd_read(sc->ps2kbd_sc, &val, &trans) != -1) {
16- if (val == 0xf0) {
17- release = 0x80;
18- continue;
19- } else {
20-- val = translation[val] | release;
21-+ val = ((trans) ? translation[val] : val) | release;
22- }
23- atkbdc_kbd_queue_data(sc, val);
24- break;
25- }
26- } else {
27- while (sc->kbd.bcnt < FIFOSZ) {
28-- if (ps2kbd_read(sc->ps2kbd_sc, &val) != -1)
29-+ if (ps2kbd_read(sc->ps2kbd_sc, &val, &trans) != -1)
30- atkbdc_kbd_queue_data(sc, val);
31- else
32- break;
331 diff -upN bhyve_orig/console.c bhyve/console.c
342 --- bhyve_orig/console.c 2020-05-01 11:25:57.441001000 +0900
35-+++ bhyve/console.c 2020-06-02 20:27:26.517334000 +0900
3++++ bhyve/console.c 2020-06-13 14:02:26.514285000 +0900
364 @@ -106,10 +106,10 @@ console_ptr_register(ptr_event_func_t event_cb, void *
375 }
386
@@ -48,7 +16,7 @@ diff -upN bhyve_orig/console.c bhyve/console.c
4816 void
4917 diff -upN bhyve_orig/console.h bhyve/console.h
5018 --- bhyve_orig/console.h 2020-05-01 11:25:57.446732000 +0900
51-+++ bhyve/console.h 2020-06-02 20:27:26.517796000 +0900
19++++ bhyve/console.h 2020-06-13 14:02:26.514771000 +0900
5220 @@ -34,7 +34,7 @@
5321 struct bhyvegc;
5422
@@ -69,133 +37,35 @@ diff -upN bhyve_orig/console.h bhyve/console.h
6937 void console_ptr_event(uint8_t button, int x, int y);
7038 diff -upN bhyve_orig/ps2kbd.c bhyve/ps2kbd.c
7139 --- bhyve_orig/ps2kbd.c 2020-05-01 11:25:57.446548000 +0900
72-+++ bhyve/ps2kbd.c 2020-06-02 20:29:26.881702000 +0900
73-@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD: releng/12.1/usr.sbin/bhyve/ps2kbd.
74-
75- struct fifo {
76- uint8_t buf[PS2KBD_FIFOSZ];
77-+ uint8_t trans[PS2KBD_FIFOSZ];
78- int rindex; /* index to read from */
79- int windex; /* index to write to */
80- int num; /* number of bytes in the fifo */
81-@@ -197,26 +198,28 @@ fifo_reset(struct ps2kbd_softc *sc)
82- }
40++++ bhyve/ps2kbd.c 2020-06-13 14:17:21.587358000 +0900
41+@@ -177,6 +177,26 @@ static const uint8_t ascii_translations[128] = {
42+ 0x22, 0x35, 0x1a, 0x54, 0x5d, 0x5b, 0x0e, 0x00,
43+ };
8344
45++/* ScanCode set1 to set2 lookup table */
46++const uint8_t keyset1to2_translations[128] = {
47++ 0, 0x76, 0x16, 0x1E, 0x26, 0x25, 0x2e, 0x36,
48++ 0x3d, 0x3e, 0x46, 0x45, 0x4e, 0x55, 0x66, 0x0d,
49++ 0x15, 0x1d, 0x24, 0x2d, 0x2c, 0x35, 0x3c, 0x43,
50++ 0x44, 0x4d, 0x54, 0x5b, 0x5a, 0x14, 0x1c, 0x1b,
51++ 0x23, 0x2b, 0x34, 0x33, 0x3b, 0x42, 0x4b, 0x4c,
52++ 0x52, 0x0e, 0x12, 0x5d, 0x1a, 0x22, 0x21, 0x2a,
53++ 0x32, 0x31, 0x3a, 0x41, 0x49, 0x4a, 0x59, 0x7c,
54++ 0x11, 0x29, 0x58, 0x05, 0x06, 0x04, 0x0c, 0x03,
55++ 0x0b, 0x83, 0x0a, 0x01, 0x09, 0x77, 0x7e, 0x6c,
56++ 0x75, 0x7d, 0x7b, 0x6b, 0x73, 0x74, 0x79, 0x69,
57++ 0x72, 0x7a, 0x70, 0x71, 0x84, 0x60, 0x61, 0x78,
58++ 0x07, 0x0f, 0x17, 0x1f, 0x27, 0x2f, 0x37, 0x3f,
59++ 0x47, 0x4f, 0x56, 0x5e, 0x08, 0x10, 0x18, 0x20,
60++ 0x28, 0x30, 0x38, 0x40, 0x48, 0x50, 0x57, 0x6f,
61++ 0x13, 0x19, 0x39, 0x51, 0x53, 0x5c, 0x5f, 0x62,
62++ 0x63, 0x64, 0x65, 0x67, 0x68, 0x6a, 0x6d, 0x6e,
63++};
64++
8465 static void
85--fifo_put(struct ps2kbd_softc *sc, uint8_t val)
86-+fifo_put(struct ps2kbd_softc *sc, uint8_t val, uint8_t trans)
87- {
88- struct fifo *fifo;
89-
90- fifo = &sc->fifo;
91- if (fifo->num < fifo->size) {
92- fifo->buf[fifo->windex] = val;
93-+ fifo->trans[fifo->windex] = trans;
94- fifo->windex = (fifo->windex + 1) % fifo->size;
95- fifo->num++;
96- }
97- }
98-
99- static int
100--fifo_get(struct ps2kbd_softc *sc, uint8_t *val)
101-+fifo_get(struct ps2kbd_softc *sc, uint8_t *val, uint8_t *trans)
66+ fifo_init(struct ps2kbd_softc *sc)
10267 {
103- struct fifo *fifo;
104-
105- fifo = &sc->fifo;
106- if (fifo->num > 0) {
107- *val = fifo->buf[fifo->rindex];
108-+ *trans = fifo->trans[fifo->rindex];
109- fifo->rindex = (fifo->rindex + 1) % fifo->size;
110- fifo->num--;
111- return (0);
112-@@ -226,12 +229,12 @@ fifo_get(struct ps2kbd_softc *sc, uint8_t *val)
113- }
114-
115- int
116--ps2kbd_read(struct ps2kbd_softc *sc, uint8_t *val)
117-+ps2kbd_read(struct ps2kbd_softc *sc, uint8_t *val, uint8_t *trans)
118- {
119- int retval;
120-
121- pthread_mutex_lock(&sc->mtx);
122-- retval = fifo_get(sc, val);
123-+ retval = fifo_get(sc, val, trans);
124- pthread_mutex_unlock(&sc->mtx);
125-
126- return (retval);
127-@@ -244,13 +247,13 @@ ps2kbd_write(struct ps2kbd_softc *sc, uint8_t val)
128- if (sc->curcmd) {
129- switch (sc->curcmd) {
130- case PS2KC_SET_TYPEMATIC:
131-- fifo_put(sc, PS2KC_ACK);
132-+ fifo_put(sc, PS2KC_ACK, 0);
133- break;
134- case PS2KC_SET_SCANCODE_SET:
135-- fifo_put(sc, PS2KC_ACK);
136-+ fifo_put(sc, PS2KC_ACK, 0);
137- break;
138- case PS2KC_SET_LEDS:
139-- fifo_put(sc, PS2KC_ACK);
140-+ fifo_put(sc, PS2KC_ACK, 0);
141- break;
142- default:
143- fprintf(stderr, "Unhandled ps2 keyboard current "
144-@@ -261,41 +264,41 @@ ps2kbd_write(struct ps2kbd_softc *sc, uint8_t val)
145- } else {
146- switch (val) {
147- case 0x00:
148-- fifo_put(sc, PS2KC_ACK);
149-+ fifo_put(sc, PS2KC_ACK, 0);
150- break;
151- case PS2KC_RESET_DEV:
152- fifo_reset(sc);
153-- fifo_put(sc, PS2KC_ACK);
154-- fifo_put(sc, PS2KC_BAT_SUCCESS);
155-+ fifo_put(sc, PS2KC_ACK, 0);
156-+ fifo_put(sc, PS2KC_BAT_SUCCESS, 0);
157- break;
158- case PS2KC_DISABLE:
159- sc->enabled = false;
160-- fifo_put(sc, PS2KC_ACK);
161-+ fifo_put(sc, PS2KC_ACK, 0);
162- break;
163- case PS2KC_ENABLE:
164- sc->enabled = true;
165- fifo_reset(sc);
166-- fifo_put(sc, PS2KC_ACK);
167-+ fifo_put(sc, PS2KC_ACK, 0);
168- break;
169- case PS2KC_SET_TYPEMATIC:
170- sc->curcmd = val;
171-- fifo_put(sc, PS2KC_ACK);
172-+ fifo_put(sc, PS2KC_ACK, 0);
173- break;
174- case PS2KC_SEND_DEV_ID:
175-- fifo_put(sc, PS2KC_ACK);
176-- fifo_put(sc, 0xab);
177-- fifo_put(sc, 0x83);
178-+ fifo_put(sc, PS2KC_ACK, 0);
179-+ fifo_put(sc, 0xab, 0);
180-+ fifo_put(sc, 0x83, 0);
181- break;
182- case PS2KC_SET_SCANCODE_SET:
183- sc->curcmd = val;
184-- fifo_put(sc, PS2KC_ACK);
185-+ fifo_put(sc, PS2KC_ACK, 0);
186- break;
187- case PS2KC_ECHO:
188-- fifo_put(sc, PS2KC_ECHO);
189-+ fifo_put(sc, PS2KC_ECHO, 0);
190- break;
191- case PS2KC_SET_LEDS:
192- sc->curcmd = val;
193-- fifo_put(sc, PS2KC_ACK);
194-+ fifo_put(sc, PS2KC_ACK, 0);
195- break;
196- default:
197- fprintf(stderr, "Unhandled ps2 keyboard command "
198-@@ -311,26 +314,32 @@ ps2kbd_write(struct ps2kbd_softc *sc, uint8_t val)
68+@@ -311,26 +331,32 @@ ps2kbd_write(struct ps2kbd_softc *sc, uint8_t val)
19969 */
20070 static void
20171 ps2kbd_keysym_queue(struct ps2kbd_softc *sc,
@@ -212,7 +82,7 @@ diff -upN bhyve_orig/ps2kbd.c bhyve/ps2kbd.c
21282 - code = ascii_translations[keysym];
21383 - e0_prefix = 0;
21484 + if (keycode) {
215-+ code = (uint8_t)(keycode & 0x7f);
85++ code = keyset1to2_translations[(uint8_t)(keycode & 0x7f)];
21686 + e0_prefix = ((keycode & 0x80) ? SCANCODE_E0_PREFIX : 0);
21787 found = 1;
21888 } else {
@@ -240,17 +110,7 @@ diff -upN bhyve_orig/ps2kbd.c bhyve/ps2kbd.c
240110 }
241111 }
242112 }
243-@@ -341,14 +350,14 @@ ps2kbd_keysym_queue(struct ps2kbd_softc *sc,
244- }
245-
246- if (e0_prefix)
247-- fifo_put(sc, 0xe0);
248-+ fifo_put(sc, 0xe0, 0);
249- if (!down)
250-- fifo_put(sc, 0xf0);
251-- fifo_put(sc, code);
252-+ fifo_put(sc, 0xf0, 0);
253-+ fifo_put(sc, code, (keycode ? 0 : 1));
113+@@ -348,7 +374,7 @@ ps2kbd_keysym_queue(struct ps2kbd_softc *sc,
254114 }
255115
256116 static void
@@ -259,7 +119,7 @@ diff -upN bhyve_orig/ps2kbd.c bhyve/ps2kbd.c
259119 {
260120 struct ps2kbd_softc *sc = arg;
261121 int fifo_full;
262-@@ -359,7 +368,7 @@ ps2kbd_event(int down, uint32_t keysym, void *arg)
122+@@ -359,7 +385,7 @@ ps2kbd_event(int down, uint32_t keysym, void *arg)
263123 return;
264124 }
265125 fifo_full = sc->fifo.num == PS2KBD_FIFOSZ;
@@ -268,21 +128,9 @@ diff -upN bhyve_orig/ps2kbd.c bhyve/ps2kbd.c
268128 pthread_mutex_unlock(&sc->mtx);
269129
270130 if (!fifo_full)
271-diff -upN bhyve_orig/ps2kbd.h bhyve/ps2kbd.h
272---- bhyve_orig/ps2kbd.h 2020-05-01 11:25:57.441775000 +0900
273-+++ bhyve/ps2kbd.h 2020-06-02 20:27:26.519082000 +0900
274-@@ -35,7 +35,7 @@ struct atkbdc_softc;
275-
276- struct ps2kbd_softc *ps2kbd_init(struct atkbdc_softc *sc);
277-
278--int ps2kbd_read(struct ps2kbd_softc *sc, uint8_t *val);
279-+int ps2kbd_read(struct ps2kbd_softc *sc, uint8_t *val, uint8_t *trans);
280- void ps2kbd_write(struct ps2kbd_softc *sc, uint8_t val);
281-
282- #endif /* _PS2KBD_H_ */
283131 diff -upN bhyve_orig/rfb.c bhyve/rfb.c
284132 --- bhyve_orig/rfb.c 2020-05-01 11:25:57.446856000 +0900
285-+++ bhyve/rfb.c 2020-06-02 20:27:26.520216000 +0900
133++++ bhyve/rfb.c 2020-06-13 14:02:26.516609000 +0900
286134 @@ -97,7 +97,10 @@ struct rfb_softc {
287135 bool enc_raw_ok;
288136 bool enc_zlib_ok;
--- a/qemu_ext_keyevent_msg/bhyve_qemu_ext_key_event_msg_fbsd13c.patch
+++ b/qemu_ext_keyevent_msg/bhyve_qemu_ext_key_event_msg_fbsd13c.patch
@@ -1,38 +1,6 @@
1-diff -upN bhyve_orig/atkbdc.c bhyve/atkbdc.c
2---- bhyve_orig/atkbdc.c 2020-05-28 09:02:50.000000000 +0900
3-+++ bhyve/atkbdc.c 2020-06-03 10:31:37.337347000 +0900
4-@@ -216,24 +216,25 @@ atkbdc_kbd_read(struct atkbdc_softc *sc)
5- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
6- };
7- uint8_t val;
8-+ uint8_t trans;
9- uint8_t release = 0;
10-
11- assert(pthread_mutex_isowned_np(&sc->mtx));
12-
13- if (sc->ram[0] & KBD_TRANSLATION) {
14-- while (ps2kbd_read(sc->ps2kbd_sc, &val) != -1) {
15-+ while (ps2kbd_read(sc->ps2kbd_sc, &val, &trans) != -1) {
16- if (val == 0xf0) {
17- release = 0x80;
18- continue;
19- } else {
20-- val = translation[val] | release;
21-+ val = ((trans) ? translation[val] : val) | release;
22- }
23- atkbdc_kbd_queue_data(sc, val);
24- break;
25- }
26- } else {
27- while (sc->kbd.bcnt < FIFOSZ) {
28-- if (ps2kbd_read(sc->ps2kbd_sc, &val) != -1)
29-+ if (ps2kbd_read(sc->ps2kbd_sc, &val, &trans) != -1)
30- atkbdc_kbd_queue_data(sc, val);
31- else
32- break;
331 diff -upN bhyve_orig/console.c bhyve/console.c
34---- bhyve_orig/console.c 2020-05-28 09:02:50.000000000 +0900
35-+++ bhyve/console.c 2020-06-03 10:31:37.338047000 +0900
2+--- bhyve_orig/console.c 2020-06-14 10:25:23.470371000 +0900
3++++ bhyve/console.c 2020-06-14 16:06:49.475147000 +0900
364 @@ -106,10 +106,10 @@ console_ptr_register(ptr_event_func_t event_cb, void *
375 }
386
@@ -47,8 +15,8 @@ diff -upN bhyve_orig/console.c bhyve/console.c
4715
4816 void
4917 diff -upN bhyve_orig/console.h bhyve/console.h
50---- bhyve_orig/console.h 2020-05-28 09:02:50.000000000 +0900
51-+++ bhyve/console.h 2020-06-03 10:31:37.338668000 +0900
18+--- bhyve_orig/console.h 2020-06-14 10:25:23.454420000 +0900
19++++ bhyve/console.h 2020-06-14 16:06:49.475771000 +0900
5220 @@ -34,7 +34,7 @@
5321 struct bhyvegc;
5422
@@ -68,134 +36,36 @@ diff -upN bhyve_orig/console.h bhyve/console.h
6836 void console_ptr_register(ptr_event_func_t event_cb, void *arg, int pri);
6937 void console_ptr_event(uint8_t button, int x, int y);
7038 diff -upN bhyve_orig/ps2kbd.c bhyve/ps2kbd.c
71---- bhyve_orig/ps2kbd.c 2020-05-28 09:02:50.000000000 +0900
72-+++ bhyve/ps2kbd.c 2020-06-03 10:31:37.339319000 +0900
73-@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD: head/usr.sbin/bhyve/ps2kbd.c 36064
74-
75- struct fifo {
76- uint8_t buf[PS2KBD_FIFOSZ];
77-+ uint8_t trans[PS2KBD_FIFOSZ];
78- int rindex; /* index to read from */
79- int windex; /* index to write to */
80- int num; /* number of bytes in the fifo */
81-@@ -201,26 +202,28 @@ fifo_reset(struct ps2kbd_softc *sc)
82- }
39+--- bhyve_orig/ps2kbd.c 2020-06-14 10:25:24.140690000 +0900
40++++ bhyve/ps2kbd.c 2020-06-14 16:06:49.476779000 +0900
41+@@ -181,6 +181,26 @@ static const uint8_t ascii_translations[128] = {
42+ 0x22, 0x35, 0x1a, 0x54, 0x5d, 0x5b, 0x0e, 0x00,
43+ };
8344
45++/* ScanCode set1 to set2 lookup table */
46++const uint8_t keyset1to2_translations[128] = {
47++ 0, 0x76, 0x16, 0x1E, 0x26, 0x25, 0x2e, 0x36,
48++ 0x3d, 0x3e, 0x46, 0x45, 0x4e, 0x55, 0x66, 0x0d,
49++ 0x15, 0x1d, 0x24, 0x2d, 0x2c, 0x35, 0x3c, 0x43,
50++ 0x44, 0x4d, 0x54, 0x5b, 0x5a, 0x14, 0x1c, 0x1b,
51++ 0x23, 0x2b, 0x34, 0x33, 0x3b, 0x42, 0x4b, 0x4c,
52++ 0x52, 0x0e, 0x12, 0x5d, 0x1a, 0x22, 0x21, 0x2a,
53++ 0x32, 0x31, 0x3a, 0x41, 0x49, 0x4a, 0x59, 0x7c,
54++ 0x11, 0x29, 0x58, 0x05, 0x06, 0x04, 0x0c, 0x03,
55++ 0x0b, 0x83, 0x0a, 0x01, 0x09, 0x77, 0x7e, 0x6c,
56++ 0x75, 0x7d, 0x7b, 0x6b, 0x73, 0x74, 0x79, 0x69,
57++ 0x72, 0x7a, 0x70, 0x71, 0x84, 0x60, 0x61, 0x78,
58++ 0x07, 0x0f, 0x17, 0x1f, 0x27, 0x2f, 0x37, 0x3f,
59++ 0x47, 0x4f, 0x56, 0x5e, 0x08, 0x10, 0x18, 0x20,
60++ 0x28, 0x30, 0x38, 0x40, 0x48, 0x50, 0x57, 0x6f,
61++ 0x13, 0x19, 0x39, 0x51, 0x53, 0x5c, 0x5f, 0x62,
62++ 0x63, 0x64, 0x65, 0x67, 0x68, 0x6a, 0x6d, 0x6e,
63++};
64++
8465 static void
85--fifo_put(struct ps2kbd_softc *sc, uint8_t val)
86-+fifo_put(struct ps2kbd_softc *sc, uint8_t val, uint8_t trans)
87- {
88- struct fifo *fifo;
89-
90- fifo = &sc->fifo;
91- if (fifo->num < fifo->size) {
92- fifo->buf[fifo->windex] = val;
93-+ fifo->trans[fifo->windex] = trans;
94- fifo->windex = (fifo->windex + 1) % fifo->size;
95- fifo->num++;
96- }
97- }
98-
99- static int
100--fifo_get(struct ps2kbd_softc *sc, uint8_t *val)
101-+fifo_get(struct ps2kbd_softc *sc, uint8_t *val, uint8_t *trans)
66+ fifo_init(struct ps2kbd_softc *sc)
10267 {
103- struct fifo *fifo;
104-
105- fifo = &sc->fifo;
106- if (fifo->num > 0) {
107- *val = fifo->buf[fifo->rindex];
108-+ *trans = fifo->trans[fifo->rindex];
109- fifo->rindex = (fifo->rindex + 1) % fifo->size;
110- fifo->num--;
111- return (0);
112-@@ -230,12 +233,12 @@ fifo_get(struct ps2kbd_softc *sc, uint8_t *val)
113- }
114-
115- int
116--ps2kbd_read(struct ps2kbd_softc *sc, uint8_t *val)
117-+ps2kbd_read(struct ps2kbd_softc *sc, uint8_t *val, uint8_t *trans)
118- {
119- int retval;
120-
121- pthread_mutex_lock(&sc->mtx);
122-- retval = fifo_get(sc, val);
123-+ retval = fifo_get(sc, val, trans);
124- pthread_mutex_unlock(&sc->mtx);
125-
126- return (retval);
127-@@ -248,13 +251,13 @@ ps2kbd_write(struct ps2kbd_softc *sc, uint8_t val)
128- if (sc->curcmd) {
129- switch (sc->curcmd) {
130- case PS2KC_SET_TYPEMATIC:
131-- fifo_put(sc, PS2KC_ACK);
132-+ fifo_put(sc, PS2KC_ACK, 0);
133- break;
134- case PS2KC_SET_SCANCODE_SET:
135-- fifo_put(sc, PS2KC_ACK);
136-+ fifo_put(sc, PS2KC_ACK, 0);
137- break;
138- case PS2KC_SET_LEDS:
139-- fifo_put(sc, PS2KC_ACK);
140-+ fifo_put(sc, PS2KC_ACK, 0);
141- break;
142- default:
143- EPRINTLN("Unhandled ps2 keyboard current "
144-@@ -265,41 +268,41 @@ ps2kbd_write(struct ps2kbd_softc *sc, uint8_t val)
145- } else {
146- switch (val) {
147- case 0x00:
148-- fifo_put(sc, PS2KC_ACK);
149-+ fifo_put(sc, PS2KC_ACK, 0);
150- break;
151- case PS2KC_RESET_DEV:
152- fifo_reset(sc);
153-- fifo_put(sc, PS2KC_ACK);
154-- fifo_put(sc, PS2KC_BAT_SUCCESS);
155-+ fifo_put(sc, PS2KC_ACK, 0);
156-+ fifo_put(sc, PS2KC_BAT_SUCCESS, 0);
157- break;
158- case PS2KC_DISABLE:
159- sc->enabled = false;
160-- fifo_put(sc, PS2KC_ACK);
161-+ fifo_put(sc, PS2KC_ACK, 0);
162- break;
163- case PS2KC_ENABLE:
164- sc->enabled = true;
165- fifo_reset(sc);
166-- fifo_put(sc, PS2KC_ACK);
167-+ fifo_put(sc, PS2KC_ACK, 0);
168- break;
169- case PS2KC_SET_TYPEMATIC:
170- sc->curcmd = val;
171-- fifo_put(sc, PS2KC_ACK);
172-+ fifo_put(sc, PS2KC_ACK, 0);
173- break;
174- case PS2KC_SEND_DEV_ID:
175-- fifo_put(sc, PS2KC_ACK);
176-- fifo_put(sc, 0xab);
177-- fifo_put(sc, 0x83);
178-+ fifo_put(sc, PS2KC_ACK, 0);
179-+ fifo_put(sc, 0xab, 0);
180-+ fifo_put(sc, 0x83, 0);
181- break;
182- case PS2KC_SET_SCANCODE_SET:
183- sc->curcmd = val;
184-- fifo_put(sc, PS2KC_ACK);
185-+ fifo_put(sc, PS2KC_ACK, 0);
186- break;
187- case PS2KC_ECHO:
188-- fifo_put(sc, PS2KC_ECHO);
189-+ fifo_put(sc, PS2KC_ECHO, 0);
190- break;
191- case PS2KC_SET_LEDS:
192- sc->curcmd = val;
193-- fifo_put(sc, PS2KC_ACK);
194-+ fifo_put(sc, PS2KC_ACK, 0);
195- break;
196- default:
197- EPRINTLN("Unhandled ps2 keyboard command "
198-@@ -315,26 +318,32 @@ ps2kbd_write(struct ps2kbd_softc *sc, uint8_t val)
68+@@ -315,26 +335,32 @@ ps2kbd_write(struct ps2kbd_softc *sc, uint8_t val)
19969 */
20070 static void
20171 ps2kbd_keysym_queue(struct ps2kbd_softc *sc,
@@ -212,7 +82,7 @@ diff -upN bhyve_orig/ps2kbd.c bhyve/ps2kbd.c
21282 - code = ascii_translations[keysym];
21383 - e0_prefix = 0;
21484 + if (keycode) {
215-+ code = (uint8_t)(keycode & 0x7f);
85++ code = keyset1to2_translations[(uint8_t)(keycode & 0x7f)];
21686 + e0_prefix = ((keycode & 0x80) ? SCANCODE_E0_PREFIX : 0);
21787 found = 1;
21888 } else {
@@ -240,17 +110,7 @@ diff -upN bhyve_orig/ps2kbd.c bhyve/ps2kbd.c
240110 }
241111 }
242112 }
243-@@ -345,14 +354,14 @@ ps2kbd_keysym_queue(struct ps2kbd_softc *sc,
244- }
245-
246- if (e0_prefix)
247-- fifo_put(sc, 0xe0);
248-+ fifo_put(sc, 0xe0, 0);
249- if (!down)
250-- fifo_put(sc, 0xf0);
251-- fifo_put(sc, code);
252-+ fifo_put(sc, 0xf0, 0);
253-+ fifo_put(sc, code, (keycode ? 0 : 1));
113+@@ -352,7 +378,7 @@ ps2kbd_keysym_queue(struct ps2kbd_softc *sc,
254114 }
255115
256116 static void
@@ -259,7 +119,7 @@ diff -upN bhyve_orig/ps2kbd.c bhyve/ps2kbd.c
259119 {
260120 struct ps2kbd_softc *sc = arg;
261121 int fifo_full;
262-@@ -363,7 +372,7 @@ ps2kbd_event(int down, uint32_t keysym, void *arg)
122+@@ -363,7 +389,7 @@ ps2kbd_event(int down, uint32_t keysym, void *arg)
263123 return;
264124 }
265125 fifo_full = sc->fifo.num == PS2KBD_FIFOSZ;
@@ -268,21 +128,9 @@ diff -upN bhyve_orig/ps2kbd.c bhyve/ps2kbd.c
268128 pthread_mutex_unlock(&sc->mtx);
269129
270130 if (!fifo_full)
271-diff -upN bhyve_orig/ps2kbd.h bhyve/ps2kbd.h
272---- bhyve_orig/ps2kbd.h 2020-05-28 09:02:50.000000000 +0900
273-+++ bhyve/ps2kbd.h 2020-06-03 10:31:37.339486000 +0900
274-@@ -36,7 +36,7 @@ struct vm_snapshot_meta;
275-
276- struct ps2kbd_softc *ps2kbd_init(struct atkbdc_softc *sc);
277-
278--int ps2kbd_read(struct ps2kbd_softc *sc, uint8_t *val);
279-+int ps2kbd_read(struct ps2kbd_softc *sc, uint8_t *val, uint8_t *trans);
280- void ps2kbd_write(struct ps2kbd_softc *sc, uint8_t val);
281-
282- #ifdef BHYVE_SNAPSHOT
283131 diff -upN bhyve_orig/rfb.c bhyve/rfb.c
284---- bhyve_orig/rfb.c 2020-05-28 09:02:50.000000000 +0900
285-+++ bhyve/rfb.c 2020-06-03 10:31:37.339898000 +0900
132+--- bhyve_orig/rfb.c 2020-06-14 10:25:24.141562000 +0900
133++++ bhyve/rfb.c 2020-06-14 16:06:49.477815000 +0900
286134 @@ -99,7 +99,10 @@ struct rfb_softc {
287135 bool enc_raw_ok;
288136 bool enc_zlib_ok;