FreeBSD bhyve keyboard layout patch
リビジョン | a52e6fbbd4512a54c78da64df4c065913c6f7f7d (tree) |
---|---|
日時 | 2021-01-02 13:42:09 |
作者 | ![]() |
コミッター | Koine Yuusuke(koinec) |
kbdlayout: add patch for FreeBSD 12.2-RELEASE
kbdlayout: rebase for FreeBSE 13.0-current(20201224)
qemuextkey: add patch for FreeBSD 12.2-RELEASE
qemuextkey: rebase for FreeBSE 13.0-current(20201224)
@@ -0,0 +1,248 @@ | ||
1 | +diff -uprN bhyve_orig/Makefile bhyve/Makefile | |
2 | +--- bhyve_orig/Makefile 2020-10-23 09:02:29.000000000 +0900 | |
3 | ++++ bhyve/Makefile 2020-12-30 15:37:58.795173000 +0900 | |
4 | +@@ -95,4 +95,6 @@ CFLAGS+=-DGDB_LOG | |
5 | + | |
6 | + WARNS?= 2 | |
7 | + | |
8 | ++SUBDIR= kbdlayout | |
9 | ++ | |
10 | + .include <bsd.prog.mk> | |
11 | +diff -uprN bhyve_orig/bhyve.8 bhyve/bhyve.8 | |
12 | +--- bhyve_orig/bhyve.8 2020-10-23 09:02:29.000000000 +0900 | |
13 | ++++ bhyve/bhyve.8 2020-12-30 15:37:58.795903000 +0900 | |
14 | +@@ -47,6 +47,7 @@ | |
15 | + .Sm on | |
16 | + .Op Fl G Ar port | |
17 | + .Op Fl g Ar gdbport | |
18 | ++.Op Fl k Ar layout | |
19 | + .Oo Fl l | |
20 | + .Sm off | |
21 | + .Cm help | Ar lpcdev Op Cm \&, Ar conf | |
22 | +@@ -163,6 +164,13 @@ Print help message and exit. | |
23 | + .It Fl H | |
24 | + Yield the virtual CPU thread when a HLT instruction is detected. | |
25 | + If this option is not specified, virtual CPUs will use 100% of a host CPU. | |
26 | ++.It Fl k Ar layout | |
27 | ++Specify the keyboard layout. | |
28 | ++The value that can be specified sets the file name in | |
29 | ++.Ar /usr/share/bhyve/kbdlayout . | |
30 | ++This specification only works when loaded with UEFI mode.(Not working via console or SSH) | |
31 | ++If you are using a VNC client that supports QEMU Extended Key Event Message (e.g. TigerVNC), don't need to specify this option. | |
32 | ++If you are using a VNC client that doesn't support it(e.g. tightVNC), and you don't specify this option, the US keyboard layout(default) is specified. | |
33 | + .It Fl l Op Ar help|lpcdev Ns Op , Ns Ar conf | |
34 | + Allow devices behind the LPC PCI-ISA bridge to be configured. | |
35 | + The only supported devices are the TTY-class devices | |
36 | +diff -uprN bhyve_orig/bhyverun.c bhyve/bhyverun.c | |
37 | +--- bhyve_orig/bhyverun.c 2020-10-23 09:02:29.000000000 +0900 | |
38 | ++++ bhyve/bhyverun.c 2020-12-30 15:37:58.796864000 +0900 | |
39 | +@@ -165,6 +165,8 @@ char *vmname; | |
40 | + int guest_ncpus; | |
41 | + uint16_t cores, maxcpus, sockets, threads; | |
42 | + | |
43 | ++char *kbdlayout_name; | |
44 | ++ | |
45 | + char *guest_uuid_str; | |
46 | + | |
47 | + int raw_stdio = 0; | |
48 | +@@ -215,7 +217,7 @@ usage(int code) | |
49 | + fprintf(stderr, | |
50 | + "Usage: %s [-abehuwxACDHPSWY]\n" | |
51 | + " %*s [-c [[cpus=]numcpus][,sockets=n][,cores=n][,threads=n]]\n" | |
52 | +- " %*s [-g <gdb port>] [-l <lpc>]\n" | |
53 | ++ " %*s [-g <gdb port>] [-k layout] [-l <lpc>]\n" | |
54 | + " %*s [-m mem] [-p vcpu:hostcpu] [-s <pci>] [-U uuid] <vm>\n" | |
55 | + " -a: local apic is in xAPIC mode (deprecated)\n" | |
56 | + " -A: create ACPI tables\n" | |
57 | +@@ -226,6 +228,7 @@ usage(int code) | |
58 | + " -g: gdb port\n" | |
59 | + " -h: help\n" | |
60 | + " -H: vmexit from the guest on hlt\n" | |
61 | ++ " -k: PS2 keyboard layout\n" | |
62 | + " -l: LPC device configuration\n" | |
63 | + " -m: memory size in MB\n" | |
64 | + " -p: pin 'vcpu' to 'hostcpu'\n" | |
65 | +@@ -1024,8 +1027,9 @@ main(int argc, char *argv[]) | |
66 | + mptgen = 1; | |
67 | + rtc_localtime = 1; | |
68 | + memflags = 0; | |
69 | ++ kbdlayout_name = NULL; | |
70 | + | |
71 | +- optstr = "abehuwxACDHIPSWYp:g:G:c:s:m:l:U:"; | |
72 | ++ optstr = "abehuwxACDHIPSWYp:g:G:c:s:m:l:k:U:"; | |
73 | + while ((c = getopt(argc, argv, optstr)) != -1) { | |
74 | + switch (c) { | |
75 | + case 'a': | |
76 | +@@ -1064,6 +1068,9 @@ main(int argc, char *argv[]) | |
77 | + optarg++; | |
78 | + } | |
79 | + gdb_port = atoi(optarg); | |
80 | ++ break; | |
81 | ++ case 'k': | |
82 | ++ kbdlayout_name = optarg; | |
83 | + break; | |
84 | + case 'l': | |
85 | + if (strncmp(optarg, "help", strlen(optarg)) == 0) { | |
86 | +diff -uprN bhyve_orig/bhyverun.h bhyve/bhyverun.h | |
87 | +--- bhyve_orig/bhyverun.h 2020-10-23 09:02:29.000000000 +0900 | |
88 | ++++ bhyve/bhyverun.h 2020-12-30 15:37:58.797234000 +0900 | |
89 | +@@ -39,6 +39,7 @@ extern int guest_ncpus; | |
90 | + extern uint16_t cores, sockets, threads; | |
91 | + extern char *guest_uuid_str; | |
92 | + extern char *vmname; | |
93 | ++extern char *kbdlayout_name; | |
94 | + | |
95 | + void *paddr_guest2host(struct vmctx *ctx, uintptr_t addr, size_t len); | |
96 | + | |
97 | +diff -uprN bhyve_orig/ps2kbd.c bhyve/ps2kbd.c | |
98 | +--- bhyve_orig/ps2kbd.c 2020-10-23 09:02:29.000000000 +0900 | |
99 | ++++ bhyve/ps2kbd.c 2020-12-30 15:37:58.797949000 +0900 | |
100 | +@@ -31,15 +31,20 @@ | |
101 | + __FBSDID("$FreeBSD: releng/12.2/usr.sbin/bhyve/ps2kbd.c 358184 2020-02-20 21:48:36Z vmaffione $"); | |
102 | + | |
103 | + #include <sys/types.h> | |
104 | ++#include <sys/stat.h> | |
105 | + | |
106 | + #include <assert.h> | |
107 | + #include <stdbool.h> | |
108 | + #include <stdio.h> | |
109 | + #include <stdlib.h> | |
110 | ++#include <string.h> | |
111 | + #include <strings.h> | |
112 | + #include <pthread.h> | |
113 | + #include <pthread_np.h> | |
114 | ++#include <unistd.h> | |
115 | ++#include <fcntl.h> | |
116 | + | |
117 | ++#include "bhyverun.h" | |
118 | + #include "atkbdc.h" | |
119 | + #include "debug.h" | |
120 | + #include "console.h" | |
121 | +@@ -59,6 +64,8 @@ __FBSDID("$FreeBSD: releng/12.2/usr.sbin/bhyve/ps2kbd. | |
122 | + | |
123 | + #define PS2KBD_FIFOSZ 16 | |
124 | + | |
125 | ++#define PS2KBD_LAYOUT_BASEDIR "/usr/share/bhyve/kbdlayout/" | |
126 | ++ | |
127 | + struct fifo { | |
128 | + uint8_t buf[PS2KBD_FIFOSZ]; | |
129 | + int rindex; /* index to read from */ | |
130 | +@@ -87,7 +94,7 @@ struct extended_translation { | |
131 | + /* | |
132 | + * FIXME: Pause/break and Print Screen/SysRq require special handling. | |
133 | + */ | |
134 | +-static const struct extended_translation extended_translations[] = { | |
135 | ++static struct extended_translation extended_translations[128] = { | |
136 | + {0xff08, 0x66}, /* Back space */ | |
137 | + {0xff09, 0x0d}, /* Tab */ | |
138 | + {0xff0d, 0x5a}, /* Return */ | |
139 | +@@ -159,7 +166,7 @@ static const struct extended_translation extended_tran | |
140 | + }; | |
141 | + | |
142 | + /* ASCII to type 2 scancode lookup table */ | |
143 | +-static const uint8_t ascii_translations[128] = { | |
144 | ++static uint8_t ascii_translations[128] = { | |
145 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
146 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
147 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
148 | +@@ -317,7 +324,7 @@ ps2kbd_keysym_queue(struct ps2kbd_softc *sc, | |
149 | + assert(pthread_mutex_isowned_np(&sc->mtx)); | |
150 | + int e0_prefix, found; | |
151 | + uint8_t code; | |
152 | +- const struct extended_translation *trans; | |
153 | ++ struct extended_translation *trans; | |
154 | + | |
155 | + found = 0; | |
156 | + if (keysym < 0x80) { | |
157 | +@@ -367,10 +374,91 @@ ps2kbd_event(int down, uint32_t keysym, void *arg) | |
158 | + atkbdc_event(sc->atkbdc_sc, 1); | |
159 | + } | |
160 | + | |
161 | ++static void | |
162 | ++ps2kbd_update_extended_translation(uint32_t keycode, uint32_t scancode, uint32_t prefix) | |
163 | ++{ | |
164 | ++ int i = 0; | |
165 | ++ | |
166 | ++ do { | |
167 | ++ if (extended_translations[i].keysym == keycode) | |
168 | ++ break; | |
169 | ++ } while(extended_translations[++i].keysym); | |
170 | ++ | |
171 | ++ if (i == (sizeof(extended_translations) / sizeof(struct extended_translation) - 1)) | |
172 | ++ return; | |
173 | ++ | |
174 | ++ if (!extended_translations[i].keysym) { | |
175 | ++ extended_translations[i].keysym = keycode; | |
176 | ++ | |
177 | ++ extended_translations[i+1].keysym = 0; | |
178 | ++ extended_translations[i+1].scancode = 0; | |
179 | ++ extended_translations[i+1].flags = 0; | |
180 | ++ } | |
181 | ++ | |
182 | ++ extended_translations[i].scancode = (uint8_t)(scancode & 0xff); | |
183 | ++ extended_translations[i].flags = (prefix ? SCANCODE_E0_PREFIX : 0); | |
184 | ++} | |
185 | ++ | |
186 | ++static void | |
187 | ++ps2kbd_setkbdlayout(void) | |
188 | ++{ | |
189 | ++ int err; | |
190 | ++ int fd; | |
191 | ++ char path[256]; | |
192 | ++ char *buf, *next, *line; | |
193 | ++ struct stat sb; | |
194 | ++ size_t sz; | |
195 | ++ uint8_t ascii; | |
196 | ++ uint32_t keycode, scancode, prefix; | |
197 | ++ | |
198 | ++ strcpy(path, PS2KBD_LAYOUT_BASEDIR); | |
199 | ++ strncat(path, kbdlayout_name, (sizeof(path) - strlen(PS2KBD_LAYOUT_BASEDIR) - 1)); | |
200 | ++ | |
201 | ++ err = stat(path, &sb); | |
202 | ++ if (err) | |
203 | ++ return; | |
204 | ++ | |
205 | ++ buf = (char *)malloc(sizeof(char) * sb.st_size); | |
206 | ++ if (buf == NULL) | |
207 | ++ return; | |
208 | ++ | |
209 | ++ fd = open(path, O_RDONLY); | |
210 | ++ if (fd == -1) | |
211 | ++ goto out; | |
212 | ++ | |
213 | ++ sz = read(fd, buf, sb.st_size ); | |
214 | ++ | |
215 | ++ close(fd); | |
216 | ++ | |
217 | ++ if (sz != sb.st_size ) | |
218 | ++ goto out; | |
219 | ++ | |
220 | ++ next = buf; | |
221 | ++ while ((line = strsep(&next, "\n")) != NULL) { | |
222 | ++ if (sscanf(line, "'%c',%x;", &ascii, &scancode) == 2) { | |
223 | ++ if (ascii < 0x80) | |
224 | ++ ascii_translations[ascii] = (uint8_t)(scancode & 0xff); | |
225 | ++ } else if (sscanf(line, "%x,%x,%x;", &keycode, &scancode, &prefix) == 3 ) { | |
226 | ++ ps2kbd_update_extended_translation(keycode, scancode, prefix); | |
227 | ++ } else if (sscanf(line, "%x,%x;", &keycode, &scancode) == 2) { | |
228 | ++ if (keycode < 0x80) | |
229 | ++ ascii_translations[(uint8_t)(keycode & 0xff)] = (uint8_t)(scancode & 0xff); | |
230 | ++ else | |
231 | ++ ps2kbd_update_extended_translation(keycode, scancode, 0); | |
232 | ++ } | |
233 | ++ } | |
234 | ++ | |
235 | ++out: | |
236 | ++ free(buf); | |
237 | ++} | |
238 | ++ | |
239 | + struct ps2kbd_softc * | |
240 | + ps2kbd_init(struct atkbdc_softc *atkbdc_sc) | |
241 | + { | |
242 | + struct ps2kbd_softc *sc; | |
243 | ++ | |
244 | ++ if (kbdlayout_name != NULL) | |
245 | ++ ps2kbd_setkbdlayout(); | |
246 | + | |
247 | + sc = calloc(1, sizeof (struct ps2kbd_softc)); | |
248 | + pthread_mutex_init(&sc->mtx, NULL); |
@@ -1,16 +1,16 @@ | ||
1 | -diff -upN bhyve_base/Makefile bhyve/Makefile | |
2 | ---- bhyve_base/Makefile 2020-06-14 16:06:21.223455000 +0900 | |
3 | -+++ bhyve/Makefile 2020-06-14 16:12:32.408499000 +0900 | |
4 | -@@ -121,4 +121,6 @@ CFLAGS+=-DGDB_LOG | |
1 | +diff -uprN bhyve_orig/Makefile bhyve/Makefile | |
2 | +--- bhyve_orig/Makefile 2020-12-24 09:12:34.000000000 +0900 | |
3 | ++++ bhyve/Makefile 2020-12-30 21:29:03.796383000 +0900 | |
4 | +@@ -124,4 +124,6 @@ CFLAGS+=-DGDB_LOG | |
5 | 5 | |
6 | 6 | WARNS?= 2 |
7 | 7 | |
8 | 8 | +SUBDIR= kbdlayout |
9 | 9 | + |
10 | 10 | .include <bsd.prog.mk> |
11 | -diff -upN bhyve_base/bhyve.8 bhyve/bhyve.8 | |
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 | |
11 | +diff -uprN bhyve_orig/bhyve.8 bhyve/bhyve.8 | |
12 | +--- bhyve_orig/bhyve.8 2020-12-24 09:12:34.000000000 +0900 | |
13 | ++++ bhyve/bhyve.8 2020-12-30 21:24:17.882128000 +0900 | |
14 | 14 | @@ -47,6 +47,7 @@ |
15 | 15 | .Sm on |
16 | 16 | .Op Fl G Ar port |
@@ -19,7 +19,7 @@ diff -upN bhyve_base/bhyve.8 bhyve/bhyve.8 | ||
19 | 19 | .Oo Fl l |
20 | 20 | .Sm off |
21 | 21 | .Cm help | Ar lpcdev Op Cm \&, Ar conf |
22 | -@@ -162,6 +163,13 @@ Print help message and exit. | |
22 | +@@ -166,6 +167,13 @@ Print help message and exit. | |
23 | 23 | .It Fl H |
24 | 24 | Yield the virtual CPU thread when a HLT instruction is detected. |
25 | 25 | If this option is not specified, virtual CPUs will use 100% of a host CPU. |
@@ -33,10 +33,10 @@ diff -upN bhyve_base/bhyve.8 bhyve/bhyve.8 | ||
33 | 33 | .It Fl l Op Ar help|lpcdev Ns Op , Ns Ar conf |
34 | 34 | Allow devices behind the LPC PCI-ISA bridge to be configured. |
35 | 35 | The only supported devices are the TTY-class devices |
36 | -diff -upN bhyve_base/bhyverun.c bhyve/bhyverun.c | |
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 | |
39 | -@@ -188,6 +188,8 @@ const char *vmname; | |
36 | +diff -uprN bhyve_orig/bhyverun.c bhyve/bhyverun.c | |
37 | +--- bhyve_orig/bhyverun.c 2020-12-24 09:12:34.000000000 +0900 | |
38 | ++++ bhyve/bhyverun.c 2020-12-30 21:26:48.192087000 +0900 | |
39 | +@@ -189,6 +189,8 @@ const char *vmname; | |
40 | 40 | int guest_ncpus; |
41 | 41 | uint16_t cores, maxcpus, sockets, threads; |
42 | 42 |
@@ -45,16 +45,16 @@ diff -upN bhyve_base/bhyverun.c bhyve/bhyverun.c | ||
45 | 45 | char *guest_uuid_str; |
46 | 46 | |
47 | 47 | int raw_stdio = 0; |
48 | -@@ -237,7 +239,7 @@ usage(int code) | |
48 | +@@ -239,7 +241,7 @@ usage(int code) | |
49 | 49 | fprintf(stderr, |
50 | - "Usage: %s [-abehuwxACHPSWY]\n" | |
50 | + "Usage: %s [-abehuwxACDHPSWY]\n" | |
51 | 51 | " %*s [-c [[cpus=]numcpus][,sockets=n][,cores=n][,threads=n]]\n" |
52 | 52 | - " %*s [-g <gdb port>] [-l <lpc>]\n" |
53 | 53 | + " %*s [-g <gdb port>] [-k layout] [-l <lpc>]\n" |
54 | 54 | " %*s [-m mem] [-p vcpu:hostcpu] [-s <pci>] [-U uuid] <vm>\n" |
55 | 55 | " -a: local apic is in xAPIC mode (deprecated)\n" |
56 | 56 | " -A: create ACPI tables\n" |
57 | -@@ -247,6 +249,7 @@ usage(int code) | |
57 | +@@ -250,6 +252,7 @@ usage(int code) | |
58 | 58 | " -g: gdb port\n" |
59 | 59 | " -h: help\n" |
60 | 60 | " -H: vmexit from the guest on hlt\n" |
@@ -62,22 +62,22 @@ diff -upN bhyve_base/bhyverun.c bhyve/bhyverun.c | ||
62 | 62 | " -l: LPC device configuration\n" |
63 | 63 | " -m: memory size in MB\n" |
64 | 64 | #ifdef BHYVE_SNAPSHOT |
65 | -@@ -1084,11 +1087,12 @@ main(int argc, char *argv[]) | |
65 | +@@ -1109,11 +1112,12 @@ main(int argc, char *argv[]) | |
66 | 66 | mptgen = 1; |
67 | 67 | rtc_localtime = 1; |
68 | 68 | memflags = 0; |
69 | 69 | + kbdlayout_name = NULL; |
70 | 70 | |
71 | 71 | #ifdef BHYVE_SNAPSHOT |
72 | -- optstr = "abehuwxACHIPSWYp:g:G:c:s:m:l:U:r:"; | |
73 | -+ optstr = "abehuwxACHIPSWYp:g:G:c:s:m:l:k:U:r:"; | |
72 | +- optstr = "abehuwxACDHIPSWYp:g:G:c:s:m:l:U:r:"; | |
73 | ++ optstr = "abehuwxACDHIPSWYp:g:G:c:s:m:l:k:U:r:"; | |
74 | 74 | #else |
75 | -- optstr = "abehuwxACHIPSWYp:g:G:c:s:m:l:U:"; | |
76 | -+ optstr = "abehuwxACHIPSWYp:g:G:c:s:m:l:k:U:"; | |
75 | +- optstr = "abehuwxACDHIPSWYp:g:G:c:s:m:l:U:"; | |
76 | ++ optstr = "abehuwxACDHIPSWYp:g:G:c:s:m:l:k:U:"; | |
77 | 77 | #endif |
78 | 78 | while ((c = getopt(argc, argv, optstr)) != -1) { |
79 | 79 | switch (c) { |
80 | -@@ -1125,6 +1129,9 @@ main(int argc, char *argv[]) | |
80 | +@@ -1155,6 +1159,9 @@ main(int argc, char *argv[]) | |
81 | 81 | optarg++; |
82 | 82 | } |
83 | 83 | gdb_port = atoi(optarg); |
@@ -87,9 +87,9 @@ diff -upN bhyve_base/bhyverun.c bhyve/bhyverun.c | ||
87 | 87 | break; |
88 | 88 | case 'l': |
89 | 89 | if (strncmp(optarg, "help", strlen(optarg)) == 0) { |
90 | -diff -upN bhyve_base/bhyverun.h bhyve/bhyverun.h | |
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 | |
90 | +diff -uprN bhyve_orig/bhyverun.h bhyve/bhyverun.h | |
91 | +--- bhyve_orig/bhyverun.h 2020-12-24 09:12:34.000000000 +0900 | |
92 | ++++ bhyve/bhyverun.h 2020-12-30 21:24:17.885813000 +0900 | |
93 | 93 | @@ -39,6 +39,7 @@ extern int guest_ncpus; |
94 | 94 | extern uint16_t cores, sockets, threads; |
95 | 95 | extern char *guest_uuid_str; |
@@ -98,19 +98,18 @@ diff -upN bhyve_base/bhyverun.h bhyve/bhyverun.h | ||
98 | 98 | |
99 | 99 | void *paddr_guest2host(struct vmctx *ctx, uintptr_t addr, size_t len); |
100 | 100 | #ifdef BHYVE_SNAPSHOT |
101 | -Common subdirectories: bhyve_base/kbdlayout and bhyve/kbdlayout | |
102 | -diff -upN bhyve_base/ps2kbd.c bhyve/ps2kbd.c | |
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 | |
101 | +diff -uprN bhyve_orig/ps2kbd.c bhyve/ps2kbd.c | |
102 | +--- bhyve_orig/ps2kbd.c 2020-12-24 09:12:34.000000000 +0900 | |
103 | ++++ bhyve/ps2kbd.c 2020-12-30 21:24:17.887408000 +0900 | |
105 | 104 | @@ -31,6 +31,7 @@ |
106 | - __FBSDID("$FreeBSD: head/usr.sbin/bhyve/ps2kbd.c 360648 2020-05-05 00:02:04Z jhb $"); | |
105 | + __FBSDID("$FreeBSD$"); | |
107 | 106 | |
108 | 107 | #include <sys/types.h> |
109 | 108 | +#include <sys/stat.h> |
110 | 109 | |
111 | 110 | #include <machine/vmm_snapshot.h> |
112 | 111 | |
113 | -@@ -42,7 +43,10 @@ __FBSDID("$FreeBSD: head/usr.sbin/bhyve/ps2kbd.c 36064 | |
112 | +@@ -42,7 +43,10 @@ __FBSDID("$FreeBSD$"); | |
114 | 113 | #include <strings.h> |
115 | 114 | #include <pthread.h> |
116 | 115 | #include <pthread_np.h> |
@@ -121,7 +120,7 @@ diff -upN bhyve_base/ps2kbd.c bhyve/ps2kbd.c | ||
121 | 120 | #include "atkbdc.h" |
122 | 121 | #include "debug.h" |
123 | 122 | #include "console.h" |
124 | -@@ -62,6 +66,8 @@ __FBSDID("$FreeBSD: head/usr.sbin/bhyve/ps2kbd.c 36064 | |
123 | +@@ -62,6 +66,8 @@ __FBSDID("$FreeBSD$"); | |
125 | 124 | |
126 | 125 | #define PS2KBD_FIFOSZ 16 |
127 | 126 |
@@ -148,16 +147,16 @@ diff -upN bhyve_base/ps2kbd.c bhyve/ps2kbd.c | ||
148 | 147 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
149 | 148 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
150 | 149 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
151 | -@@ -340,7 +346,7 @@ ps2kbd_keysym_queue(struct ps2kbd_softc *sc, | |
150 | +@@ -320,7 +326,7 @@ ps2kbd_keysym_queue(struct ps2kbd_softc *sc, | |
152 | 151 | assert(pthread_mutex_isowned_np(&sc->mtx)); |
153 | 152 | int e0_prefix, found; |
154 | 153 | uint8_t code; |
155 | 154 | - const struct extended_translation *trans; |
156 | 155 | + struct extended_translation *trans; |
157 | 156 | |
158 | - if (keycode) { | |
159 | - code = keyset1to2_translations[(uint8_t)(keycode & 0x7f)]; | |
160 | -@@ -396,10 +402,91 @@ ps2kbd_event(int down, uint32_t keysym, uint32_t keyco | |
157 | + found = 0; | |
158 | + if (keysym < 0x80) { | |
159 | +@@ -370,10 +376,91 @@ ps2kbd_event(int down, uint32_t keysym, void *arg) | |
161 | 160 | atkbdc_event(sc->atkbdc_sc, 1); |
162 | 161 | } |
163 | 162 |
@@ -0,0 +1,41 @@ | ||
1 | +diff -uprN examples/bhyve_orig/vmrun.sh examples/bhyve/vmrun.sh | |
2 | +--- examples/bhyve_orig/vmrun.sh 2020-10-23 09:02:33.000000000 +0900 | |
3 | ++++ examples/bhyve/vmrun.sh 2020-12-30 16:07:31.585188000 +0900 | |
4 | +@@ -59,8 +59,8 @@ usage() { | |
5 | + echo " [-e <name=value>] [-f <path of firmware>]" \ | |
6 | + "[-F <size>]" | |
7 | + echo " [-g <gdbport> ] [-H <directory>]" | |
8 | +- echo " [-I <location of installation iso>] [-l <loader>]" | |
9 | +- echo " [-L <VNC IP for UEFI framebuffer>]" | |
10 | ++ echo " [-I <location of installation iso>] [-k <layout>]" | |
11 | ++ echo " [-l <loader>] [-L <VNC IP for UEFI framebuffer>]" | |
12 | + echo " [-m <memsize>]" \ | |
13 | + "[-n <network adapter emulation type>]" | |
14 | + echo " [-P <port>] [-t <tapdev>] <vmname>" | |
15 | +@@ -81,6 +81,7 @@ usage() { | |
16 | + echo " -i: force boot of the Installation CDROM image" | |
17 | + echo " -I: Installation CDROM image location" \ | |
18 | + "(default: ${DEFAULT_ISOFILE})" | |
19 | ++ echo " -k: Specify the keyboard layout" | |
20 | + echo " -l: the OS loader to use (default: /boot/userboot.so)" | |
21 | + echo " -L: IP address for UEFI GOP VNC server" \ | |
22 | + "(default: ${DEFAULT_VNCHOST}" | |
23 | +@@ -134,7 +135,7 @@ vncport=${DEFAULT_VNCPORT} | |
24 | + vncsize=${DEFAULT_VNCSIZE} | |
25 | + tablet="" | |
26 | + | |
27 | +-while getopts aAc:C:d:e:Ef:F:g:hH:iI:l:L:m:n:p:P:t:Tuvw c ; do | |
28 | ++while getopts aAc:C:d:e:Ef:F:g:hH:iI:k:l:L:m:n:p:P:t:Tuvw c ; do | |
29 | + case $c in | |
30 | + a) | |
31 | + bhyverun_opt="${bhyverun_opt} -a" | |
32 | +@@ -178,6 +179,9 @@ while getopts aAc:C:d:e:Ef:F:g:hH:iI:l:L:m:n:p:P:t:Tuv | |
33 | + ;; | |
34 | + I) | |
35 | + isofile=${OPTARG} | |
36 | ++ ;; | |
37 | ++ k) | |
38 | ++ bhyverun_opt="${bhyverun_opt} -k ${OPTARG}" | |
39 | + ;; | |
40 | + l) | |
41 | + loader_opt="${loader_opt} -l ${OPTARG}" |
@@ -1,6 +1,6 @@ | ||
1 | -diff -upN examples/bhyve_orig/vmrun.sh examples/bhyve/vmrun.sh | |
2 | ---- examples/bhyve_orig/vmrun.sh 2020-05-28 09:02:55.000000000 +0900 | |
3 | -+++ examples/bhyve/vmrun.sh 2020-06-03 19:37:56.271282000 +0900 | |
1 | +diff -uprN examples/bhyve_orig/vmrun.sh examples/bhyve/vmrun.sh | |
2 | +--- examples/bhyve_orig/vmrun.sh 2020-12-24 09:12:29.000000000 +0900 | |
3 | ++++ examples/bhyve/vmrun.sh 2020-12-30 21:48:02.559191000 +0900 | |
4 | 4 | @@ -59,8 +59,8 @@ usage() { |
5 | 5 | echo " [-e <name=value>] [-f <path of firmware>]" \ |
6 | 6 | "[-F <size>]" |
@@ -0,0 +1,271 @@ | ||
1 | +diff -uprN bhyve_orig/console.c bhyve/console.c | |
2 | +--- bhyve_orig/console.c 2020-10-23 09:02:29.000000000 +0900 | |
3 | ++++ bhyve/console.c 2020-12-30 18:21:24.579446000 +0900 | |
4 | +@@ -106,10 +106,10 @@ console_ptr_register(ptr_event_func_t event_cb, void * | |
5 | + } | |
6 | + | |
7 | + void | |
8 | +-console_key_event(int down, uint32_t keysym) | |
9 | ++console_key_event(int down, uint32_t keysym, uint32_t keycode) | |
10 | + { | |
11 | + if (console.kbd_event_cb) | |
12 | +- (*console.kbd_event_cb)(down, keysym, console.kbd_arg); | |
13 | ++ (*console.kbd_event_cb)(down, keysym, keycode, console.kbd_arg); | |
14 | + } | |
15 | + | |
16 | + void | |
17 | +diff -uprN bhyve_orig/console.h bhyve/console.h | |
18 | +--- bhyve_orig/console.h 2020-10-23 09:02:29.000000000 +0900 | |
19 | ++++ bhyve/console.h 2020-12-30 18:21:24.579887000 +0900 | |
20 | +@@ -34,7 +34,7 @@ | |
21 | + struct bhyvegc; | |
22 | + | |
23 | + typedef void (*fb_render_func_t)(struct bhyvegc *gc, void *arg); | |
24 | +-typedef void (*kbd_event_func_t)(int down, uint32_t keysym, void *arg); | |
25 | ++typedef void (*kbd_event_func_t)(int down, uint32_t keysym, uint32_t keycode, void *arg); | |
26 | + typedef void (*ptr_event_func_t)(uint8_t mask, int x, int y, void *arg); | |
27 | + | |
28 | + void console_init(int w, int h, void *fbaddr); | |
29 | +@@ -47,7 +47,7 @@ void console_fb_register(fb_render_func_t render_cb, v | |
30 | + void console_refresh(void); | |
31 | + | |
32 | + void console_kbd_register(kbd_event_func_t event_cb, void *arg, int pri); | |
33 | +-void console_key_event(int down, uint32_t keysym); | |
34 | ++void console_key_event(int down, uint32_t keysym, uint32_t keycode); | |
35 | + | |
36 | + void console_ptr_register(ptr_event_func_t event_cb, void *arg, int pri); | |
37 | + void console_ptr_event(uint8_t button, int x, int y); | |
38 | +diff -uprN bhyve_orig/ps2kbd.c bhyve/ps2kbd.c | |
39 | +--- bhyve_orig/ps2kbd.c 2020-10-23 09:02:29.000000000 +0900 | |
40 | ++++ bhyve/ps2kbd.c 2020-12-30 18:21:24.580562000 +0900 | |
41 | +@@ -178,6 +178,26 @@ static const uint8_t ascii_translations[128] = { | |
42 | + 0x22, 0x35, 0x1a, 0x54, 0x5d, 0x5b, 0x0e, 0x00, | |
43 | + }; | |
44 | + | |
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 | ++ | |
65 | + static void | |
66 | + fifo_init(struct ps2kbd_softc *sc) | |
67 | + { | |
68 | +@@ -312,26 +332,32 @@ ps2kbd_write(struct ps2kbd_softc *sc, uint8_t val) | |
69 | + */ | |
70 | + static void | |
71 | + ps2kbd_keysym_queue(struct ps2kbd_softc *sc, | |
72 | +- int down, uint32_t keysym) | |
73 | ++ int down, uint32_t keysym, uint32_t keycode) | |
74 | + { | |
75 | + assert(pthread_mutex_isowned_np(&sc->mtx)); | |
76 | + int e0_prefix, found; | |
77 | + uint8_t code; | |
78 | + const struct extended_translation *trans; | |
79 | + | |
80 | +- found = 0; | |
81 | +- if (keysym < 0x80) { | |
82 | +- code = ascii_translations[keysym]; | |
83 | +- e0_prefix = 0; | |
84 | ++ if (keycode) { | |
85 | ++ code = keyset1to2_translations[(uint8_t)(keycode & 0x7f)]; | |
86 | ++ e0_prefix = ((keycode & 0x80) ? SCANCODE_E0_PREFIX : 0); | |
87 | + found = 1; | |
88 | + } else { | |
89 | +- for (trans = &(extended_translations[0]); trans->keysym != 0; | |
90 | +- trans++) { | |
91 | +- if (keysym == trans->keysym) { | |
92 | +- code = trans->scancode; | |
93 | +- e0_prefix = trans->flags & SCANCODE_E0_PREFIX; | |
94 | +- found = 1; | |
95 | +- break; | |
96 | ++ found = 0; | |
97 | ++ if (keysym < 0x80) { | |
98 | ++ code = ascii_translations[keysym]; | |
99 | ++ e0_prefix = 0; | |
100 | ++ found = 1; | |
101 | ++ } else { | |
102 | ++ for (trans = &(extended_translations[0]); trans->keysym != 0; | |
103 | ++ trans++) { | |
104 | ++ if (keysym == trans->keysym) { | |
105 | ++ code = trans->scancode; | |
106 | ++ e0_prefix = trans->flags & SCANCODE_E0_PREFIX; | |
107 | ++ found = 1; | |
108 | ++ break; | |
109 | ++ } | |
110 | + } | |
111 | + } | |
112 | + } | |
113 | +@@ -349,7 +375,7 @@ ps2kbd_keysym_queue(struct ps2kbd_softc *sc, | |
114 | + } | |
115 | + | |
116 | + static void | |
117 | +-ps2kbd_event(int down, uint32_t keysym, void *arg) | |
118 | ++ps2kbd_event(int down, uint32_t keysym, uint32_t keycode, void *arg) | |
119 | + { | |
120 | + struct ps2kbd_softc *sc = arg; | |
121 | + int fifo_full; | |
122 | +@@ -360,7 +386,7 @@ ps2kbd_event(int down, uint32_t keysym, void *arg) | |
123 | + return; | |
124 | + } | |
125 | + fifo_full = sc->fifo.num == PS2KBD_FIFOSZ; | |
126 | +- ps2kbd_keysym_queue(sc, down, keysym); | |
127 | ++ ps2kbd_keysym_queue(sc, down, keysym, keycode); | |
128 | + pthread_mutex_unlock(&sc->mtx); | |
129 | + | |
130 | + if (!fifo_full) | |
131 | +diff -uprN bhyve_orig/rfb.c bhyve/rfb.c | |
132 | +--- bhyve_orig/rfb.c 2020-10-23 09:02:29.000000000 +0900 | |
133 | ++++ bhyve/rfb.c 2020-12-30 18:21:24.581683000 +0900 | |
134 | +@@ -99,7 +99,10 @@ struct rfb_softc { | |
135 | + bool enc_raw_ok; | |
136 | + bool enc_zlib_ok; | |
137 | + bool enc_resize_ok; | |
138 | ++ bool enc_extkeyevent_ok; | |
139 | + | |
140 | ++ bool enc_extkeyevent_send; | |
141 | ++ | |
142 | + z_stream zstream; | |
143 | + uint8_t *zbuf; | |
144 | + int zbuflen; | |
145 | +@@ -145,7 +148,10 @@ struct rfb_pixfmt_msg { | |
146 | + #define RFB_ENCODING_RAW 0 | |
147 | + #define RFB_ENCODING_ZLIB 6 | |
148 | + #define RFB_ENCODING_RESIZE -223 | |
149 | ++#define RFB_ENCODING_EXT_KEYEVENT -258 | |
150 | + | |
151 | ++#define RFB_CLIENTMSG_EXT_KEYEVENT 0 | |
152 | ++ | |
153 | + #define RFB_MAX_WIDTH 2000 | |
154 | + #define RFB_MAX_HEIGHT 1200 | |
155 | + #define RFB_ZLIB_BUFSZ RFB_MAX_WIDTH*RFB_MAX_HEIGHT*4 | |
156 | +@@ -172,6 +178,19 @@ struct rfb_key_msg { | |
157 | + uint8_t type; | |
158 | + uint8_t down; | |
159 | + uint16_t pad; | |
160 | ++ uint32_t sym; | |
161 | ++}; | |
162 | ++ | |
163 | ++struct rfb_client_msg { | |
164 | ++ uint8_t type; | |
165 | ++ uint8_t subtype; | |
166 | ++}; | |
167 | ++ | |
168 | ++struct rfb_extended_key_msg { | |
169 | ++ uint8_t type; | |
170 | ++ uint8_t subtype; | |
171 | ++ uint16_t down; | |
172 | ++ uint32_t sym; | |
173 | + uint32_t code; | |
174 | + }; | |
175 | + | |
176 | +@@ -250,6 +269,27 @@ rfb_send_resize_update_msg(struct rfb_softc *rc, int c | |
177 | + } | |
178 | + | |
179 | + static void | |
180 | ++rfb_send_extended_keyevent_update_msg(struct rfb_softc *rc, int cfd) | |
181 | ++{ | |
182 | ++ struct rfb_srvr_updt_msg supdt_msg; | |
183 | ++ struct rfb_srvr_rect_hdr srect_hdr; | |
184 | ++ | |
185 | ++ /* Number of rectangles: 1 */ | |
186 | ++ supdt_msg.type = 0; | |
187 | ++ supdt_msg.pad = 0; | |
188 | ++ supdt_msg.numrects = htons(1); | |
189 | ++ stream_write(cfd, &supdt_msg, sizeof(struct rfb_srvr_updt_msg)); | |
190 | ++ | |
191 | ++ /* Rectangle header */ | |
192 | ++ srect_hdr.x = htons(0); | |
193 | ++ srect_hdr.y = htons(0); | |
194 | ++ srect_hdr.width = htons(rc->width); | |
195 | ++ srect_hdr.height = htons(rc->height); | |
196 | ++ srect_hdr.encoding = htonl(RFB_ENCODING_EXT_KEYEVENT); | |
197 | ++ stream_write(cfd, &srect_hdr, sizeof(struct rfb_srvr_rect_hdr)); | |
198 | ++} | |
199 | ++ | |
200 | ++static void | |
201 | + rfb_recv_set_pixfmt_msg(struct rfb_softc *rc, int cfd) | |
202 | + { | |
203 | + struct rfb_pixfmt_msg pixfmt_msg; | |
204 | +@@ -283,6 +323,9 @@ rfb_recv_set_encodings_msg(struct rfb_softc *rc, int c | |
205 | + case RFB_ENCODING_RESIZE: | |
206 | + rc->enc_resize_ok = true; | |
207 | + break; | |
208 | ++ case RFB_ENCODING_EXT_KEYEVENT: | |
209 | ++ rc->enc_extkeyevent_ok = true; | |
210 | ++ break; | |
211 | + } | |
212 | + } | |
213 | + } | |
214 | +@@ -648,6 +691,11 @@ rfb_recv_update_msg(struct rfb_softc *rc, int cfd, int | |
215 | + rfb_send_resize_update_msg(rc, cfd); | |
216 | + } | |
217 | + | |
218 | ++ if (rc->enc_extkeyevent_ok && (!rc->enc_extkeyevent_send)) { | |
219 | ++ rfb_send_extended_keyevent_update_msg(rc, cfd); | |
220 | ++ rc->enc_extkeyevent_send = true; | |
221 | ++ } | |
222 | ++ | |
223 | + if (discardonly) | |
224 | + return; | |
225 | + | |
226 | +@@ -661,10 +709,24 @@ rfb_recv_key_msg(struct rfb_softc *rc, int cfd) | |
227 | + | |
228 | + (void)stream_read(cfd, ((void *)&key_msg) + 1, sizeof(key_msg) - 1); | |
229 | + | |
230 | +- console_key_event(key_msg.down, htonl(key_msg.code)); | |
231 | ++ console_key_event(key_msg.down, htonl(key_msg.sym), htonl(0)); | |
232 | + } | |
233 | + | |
234 | + static void | |
235 | ++rfb_recv_client_msg(struct rfb_softc *rc, int cfd) | |
236 | ++{ | |
237 | ++ struct rfb_client_msg client_msg; | |
238 | ++ struct rfb_extended_key_msg extkey_msg; | |
239 | ++ | |
240 | ++ (void)stream_read(cfd, ((void *)&client_msg) + 1, sizeof(client_msg) - 1); | |
241 | ++ | |
242 | ++ if (client_msg.subtype == RFB_CLIENTMSG_EXT_KEYEVENT ) { | |
243 | ++ (void)stream_read(cfd, ((void *)&extkey_msg) + 2, sizeof(extkey_msg) - 2); | |
244 | ++ console_key_event((int)extkey_msg.down, htonl(extkey_msg.sym), htonl(extkey_msg.code)); | |
245 | ++ } | |
246 | ++} | |
247 | ++ | |
248 | ++static void | |
249 | + rfb_recv_ptr_msg(struct rfb_softc *rc, int cfd) | |
250 | + { | |
251 | + struct rfb_ptr_msg ptr_msg; | |
252 | +@@ -903,6 +965,9 @@ rfb_handle(struct rfb_softc *rc, int cfd) | |
253 | + case 6: | |
254 | + rfb_recv_cuttext_msg(rc, cfd); | |
255 | + break; | |
256 | ++ case 255: | |
257 | ++ rfb_recv_client_msg(rc, cfd); | |
258 | ++ break; | |
259 | + default: | |
260 | + WPRINTF(("rfb unknown cli-code %d!", buf[0] & 0xff)); | |
261 | + goto done; | |
262 | +@@ -937,6 +1002,9 @@ rfb_thr(void *arg) | |
263 | + rc->enc_raw_ok = false; | |
264 | + rc->enc_zlib_ok = false; | |
265 | + rc->enc_resize_ok = false; | |
266 | ++ rc->enc_extkeyevent_ok = false; | |
267 | ++ | |
268 | ++ rc->enc_extkeyevent_send = false; | |
269 | + | |
270 | + cfd = accept(rc->sfd, NULL, NULL); | |
271 | + if (rc->conn_wait) { |
@@ -1,6 +1,6 @@ | ||
1 | -diff -upN bhyve_orig/console.c bhyve/console.c | |
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 | |
1 | +diff -uprN bhyve_orig/console.c bhyve/console.c | |
2 | +--- bhyve_orig/console.c 2020-12-24 09:12:34.000000000 +0900 | |
3 | ++++ bhyve/console.c 2020-12-30 21:50:53.384428000 +0900 | |
4 | 4 | @@ -106,10 +106,10 @@ console_ptr_register(ptr_event_func_t event_cb, void * |
5 | 5 | } |
6 | 6 |
@@ -14,9 +14,9 @@ diff -upN bhyve_orig/console.c bhyve/console.c | ||
14 | 14 | } |
15 | 15 | |
16 | 16 | void |
17 | -diff -upN bhyve_orig/console.h bhyve/console.h | |
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 | |
17 | +diff -uprN bhyve_orig/console.h bhyve/console.h | |
18 | +--- bhyve_orig/console.h 2020-12-24 09:12:34.000000000 +0900 | |
19 | ++++ bhyve/console.h 2020-12-30 21:50:53.385443000 +0900 | |
20 | 20 | @@ -34,7 +34,7 @@ |
21 | 21 | struct bhyvegc; |
22 | 22 |
@@ -35,9 +35,9 @@ diff -upN bhyve_orig/console.h bhyve/console.h | ||
35 | 35 | |
36 | 36 | void console_ptr_register(ptr_event_func_t event_cb, void *arg, int pri); |
37 | 37 | void console_ptr_event(uint8_t button, int x, int y); |
38 | -diff -upN bhyve_orig/ps2kbd.c bhyve/ps2kbd.c | |
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 | |
38 | +diff -uprN bhyve_orig/ps2kbd.c bhyve/ps2kbd.c | |
39 | +--- bhyve_orig/ps2kbd.c 2020-12-24 09:12:34.000000000 +0900 | |
40 | ++++ bhyve/ps2kbd.c 2020-12-30 21:50:53.386722000 +0900 | |
41 | 41 | @@ -181,6 +181,26 @@ static const uint8_t ascii_translations[128] = { |
42 | 42 | 0x22, 0x35, 0x1a, 0x54, 0x5d, 0x5b, 0x0e, 0x00, |
43 | 43 | }; |
@@ -128,21 +128,21 @@ diff -upN bhyve_orig/ps2kbd.c bhyve/ps2kbd.c | ||
128 | 128 | pthread_mutex_unlock(&sc->mtx); |
129 | 129 | |
130 | 130 | if (!fifo_full) |
131 | -diff -upN bhyve_orig/rfb.c bhyve/rfb.c | |
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 | |
134 | -@@ -99,7 +99,10 @@ struct rfb_softc { | |
135 | - bool enc_raw_ok; | |
136 | - bool enc_zlib_ok; | |
137 | - bool enc_resize_ok; | |
138 | -+ bool enc_extkeyevent_ok; | |
131 | +diff -uprN bhyve_orig/rfb.c bhyve/rfb.c | |
132 | +--- bhyve_orig/rfb.c 2020-12-24 09:12:34.000000000 +0900 | |
133 | ++++ bhyve/rfb.c 2020-12-31 10:39:54.009578000 +0900 | |
134 | +@@ -118,7 +118,10 @@ struct rfb_softc { | |
135 | + bool enc_raw_ok; | |
136 | + bool enc_zlib_ok; | |
137 | + bool enc_resize_ok; | |
138 | ++ bool enc_extkeyevent_ok; | |
139 | 139 | |
140 | -+ bool enc_extkeyevent_send; | |
140 | ++ bool enc_extkeyevent_send; | |
141 | 141 | + |
142 | 142 | z_stream zstream; |
143 | 143 | uint8_t *zbuf; |
144 | 144 | int zbuflen; |
145 | -@@ -145,7 +148,10 @@ struct rfb_pixfmt_msg { | |
145 | +@@ -170,7 +173,10 @@ struct rfb_pixfmt_msg { | |
146 | 146 | #define RFB_ENCODING_RAW 0 |
147 | 147 | #define RFB_ENCODING_ZLIB 6 |
148 | 148 | #define RFB_ENCODING_RESIZE -223 |
@@ -153,7 +153,7 @@ diff -upN bhyve_orig/rfb.c bhyve/rfb.c | ||
153 | 153 | #define RFB_MAX_WIDTH 2000 |
154 | 154 | #define RFB_MAX_HEIGHT 1200 |
155 | 155 | #define RFB_ZLIB_BUFSZ RFB_MAX_WIDTH*RFB_MAX_HEIGHT*4 |
156 | -@@ -172,6 +178,19 @@ struct rfb_key_msg { | |
156 | +@@ -197,6 +203,19 @@ struct rfb_key_msg { | |
157 | 157 | uint8_t type; |
158 | 158 | uint8_t down; |
159 | 159 | uint16_t pad; |
@@ -173,7 +173,7 @@ diff -upN bhyve_orig/rfb.c bhyve/rfb.c | ||
173 | 173 | uint32_t code; |
174 | 174 | }; |
175 | 175 | |
176 | -@@ -250,6 +269,27 @@ rfb_send_resize_update_msg(struct rfb_softc *rc, int c | |
176 | +@@ -277,6 +296,27 @@ rfb_send_resize_update_msg(struct rfb_softc *rc, int c | |
177 | 177 | } |
178 | 178 | |
179 | 179 | static void |
@@ -201,7 +201,7 @@ diff -upN bhyve_orig/rfb.c bhyve/rfb.c | ||
201 | 201 | rfb_recv_set_pixfmt_msg(struct rfb_softc *rc, int cfd) |
202 | 202 | { |
203 | 203 | struct rfb_pixfmt_msg pixfmt_msg; |
204 | -@@ -283,6 +323,9 @@ rfb_recv_set_encodings_msg(struct rfb_softc *rc, int c | |
204 | +@@ -309,6 +349,9 @@ rfb_recv_set_encodings_msg(struct rfb_softc *rc, int c | |
205 | 205 | case RFB_ENCODING_RESIZE: |
206 | 206 | rc->enc_resize_ok = true; |
207 | 207 | break; |
@@ -211,24 +211,25 @@ diff -upN bhyve_orig/rfb.c bhyve/rfb.c | ||
211 | 211 | } |
212 | 212 | } |
213 | 213 | } |
214 | -@@ -648,6 +691,11 @@ rfb_recv_update_msg(struct rfb_softc *rc, int cfd, int | |
215 | - rfb_send_resize_update_msg(rc, cfd); | |
216 | - } | |
214 | +@@ -686,6 +729,11 @@ rfb_recv_update_msg(struct rfb_softc *rc, int cfd) | |
215 | + | |
216 | + (void)stream_read(cfd, ((void *)&updt_msg) + 1 , sizeof(updt_msg) - 1); | |
217 | 217 | |
218 | 218 | + if (rc->enc_extkeyevent_ok && (!rc->enc_extkeyevent_send)) { |
219 | 219 | + rfb_send_extended_keyevent_update_msg(rc, cfd); |
220 | 220 | + rc->enc_extkeyevent_send = true; |
221 | 221 | + } |
222 | 222 | + |
223 | - if (discardonly) | |
224 | - return; | |
225 | - | |
226 | -@@ -661,10 +709,24 @@ rfb_recv_key_msg(struct rfb_softc *rc, int cfd) | |
223 | + rc->pending = true; | |
224 | + if (!updt_msg.incremental) | |
225 | + rc->update_all = true; | |
226 | +@@ -698,11 +746,26 @@ rfb_recv_key_msg(struct rfb_softc *rc, int cfd) | |
227 | 227 | |
228 | 228 | (void)stream_read(cfd, ((void *)&key_msg) + 1, sizeof(key_msg) - 1); |
229 | 229 | |
230 | 230 | - console_key_event(key_msg.down, htonl(key_msg.code)); |
231 | 231 | + console_key_event(key_msg.down, htonl(key_msg.sym), htonl(0)); |
232 | + rc->input_detected = true; | |
232 | 233 | } |
233 | 234 | |
234 | 235 | static void |
@@ -242,6 +243,7 @@ diff -upN bhyve_orig/rfb.c bhyve/rfb.c | ||
242 | 243 | + if (client_msg.subtype == RFB_CLIENTMSG_EXT_KEYEVENT ) { |
243 | 244 | + (void)stream_read(cfd, ((void *)&extkey_msg) + 2, sizeof(extkey_msg) - 2); |
244 | 245 | + console_key_event((int)extkey_msg.down, htonl(extkey_msg.sym), htonl(extkey_msg.code)); |
246 | ++ rc->input_detected = true; | |
245 | 247 | + } |
246 | 248 | +} |
247 | 249 | + |
@@ -249,8 +251,8 @@ diff -upN bhyve_orig/rfb.c bhyve/rfb.c | ||
249 | 251 | rfb_recv_ptr_msg(struct rfb_softc *rc, int cfd) |
250 | 252 | { |
251 | 253 | struct rfb_ptr_msg ptr_msg; |
252 | -@@ -903,6 +965,9 @@ rfb_handle(struct rfb_softc *rc, int cfd) | |
253 | - case 6: | |
254 | +@@ -997,6 +1060,9 @@ report_and_done: | |
255 | + case CS_CUT_TEXT: | |
254 | 256 | rfb_recv_cuttext_msg(rc, cfd); |
255 | 257 | break; |
256 | 258 | + case 255: |
@@ -259,7 +261,7 @@ diff -upN bhyve_orig/rfb.c bhyve/rfb.c | ||
259 | 261 | default: |
260 | 262 | WPRINTF(("rfb unknown cli-code %d!", buf[0] & 0xff)); |
261 | 263 | goto done; |
262 | -@@ -937,6 +1002,9 @@ rfb_thr(void *arg) | |
264 | +@@ -1031,6 +1097,9 @@ rfb_thr(void *arg) | |
263 | 265 | rc->enc_raw_ok = false; |
264 | 266 | rc->enc_zlib_ok = false; |
265 | 267 | rc->enc_resize_ok = false; |