wok view busybox/stuff/busybox-1.23-fbvnc.u @ rev 19011
busybox/fbvnc: wheelmouse support (again)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Mar 28 23:15:26 2016 +0200 (2016-03-28) |
parents | 364e68c766fd |
children | 564e1bce3c80 |
line source
1 text data bss dec hex filename
2 3119 0 0 3119 c2f util-linux/fbvnc.o
3 --- /dev/null
4 +++ busybox/util-linux/fbvnc.c
5 @@ -0,0 +1,549 @@
6 +/* vi: set sw=4 ts=4: */
7 +/*
8 + * A small linux framebuffer VNC viewer
9 + *
10 + * pascal.bellard@ads-lu.com
11 + *
12 + * Based on Ali Gholami Rudi's fbvnc.c
13 + * http://repo.or.cz/w/fbvnc.git
14 + *
15 + * Licensed under GPLv2 or later, see file LICENSE in this source tree.
16 + */
17 +
18 +//applet:IF_FBVNC(APPLET(fbvnc, BB_DIR_BIN, BB_SUID_DROP))
19 +
20 +//kbuild:lib-$(CONFIG_FBVNC) += fbvnc.o
21 +
22 +//config:config FBVNC
23 +//config: bool "fbvnc"
24 +//config: default n
25 +//config: depends on PLATFORM_LINUX
26 +//config: help
27 +//config: A linux framebuffer VNC viewer.
28 +
29 +//usage:#define fbvnc_trivial_usage
30 +//usage: "[VNC_SERVER] [PORT]"
31 +//usage:#define fbvnc_full_usage "\n\n"
32 +//usage: "A linux framebuffer VNC viewer."
33 +//usage: "\nTo exit, press any mouse button and press ESC."
34 +
35 +#include "libbb.h"
36 +#include "vnc.h"
37 +
38 +/* Stuff stolen from the kernel's fb.h */
39 +#define FB_ACTIVATE_ALL 64
40 +enum {
41 + FBIOGET_VSCREENINFO = 0x4600,
42 + FBIOPUT_VSCREENINFO = 0x4601,
43 + FBIOGET_FSCREENINFO = 0x4602,
44 + FBIOGETCMAP = 0x4604,
45 + FBIOPUTCMAP = 0x4605
46 +};
47 +
48 +struct fb_bitfield {
49 + uint32_t offset; /* beginning of bitfield */
50 + uint32_t length; /* length of bitfield */
51 + uint32_t msb_right; /* !=0: Most significant bit is right */
52 +};
53 +struct fb_var_screeninfo {
54 + uint32_t xres; /* visible resolution */
55 + uint32_t yres;
56 + uint32_t xres_virtual; /* virtual resolution */
57 + uint32_t yres_virtual;
58 + uint32_t xoffset; /* offset from virtual to visible */
59 + uint32_t yoffset; /* resolution */
60 +
61 + uint32_t bits_per_pixel;
62 + uint32_t grayscale; /* !=0 Graylevels instead of colors */
63 +
64 + struct fb_bitfield red; /* bitfield in fb mem if true color, */
65 + struct fb_bitfield green; /* else only length is significant */
66 + struct fb_bitfield blue;
67 + struct fb_bitfield transp; /* transparency */
68 +
69 + uint32_t nonstd; /* !=0 Non standard pixel format */
70 +
71 + uint32_t activate; /* see FB_ACTIVATE_x */
72 +
73 + uint32_t height; /* height of picture in mm */
74 + uint32_t width; /* width of picture in mm */
75 +
76 + uint32_t accel_flags; /* acceleration flags (hints) */
77 +
78 + /* Timing: All values in pixclocks, except pixclock (of course) */
79 + uint32_t pixclock; /* pixel clock in ps (pico seconds) */
80 + uint32_t left_margin; /* time from sync to picture */
81 + uint32_t right_margin; /* time from picture to sync */
82 + uint32_t upper_margin; /* time from sync to picture */
83 + uint32_t lower_margin;
84 + uint32_t hsync_len; /* length of horizontal sync */
85 + uint32_t vsync_len; /* length of vertical sync */
86 + uint32_t sync; /* see FB_SYNC_x */
87 + uint32_t vmode; /* see FB_VMODE_x */
88 + uint32_t reserved[6]; /* Reserved for future compatibility */
89 +};
90 +
91 +#define DEFAULTFBDEV FB_0
92 +
93 +struct fb_fix_screeninfo {
94 + char id[16]; /* identification string eg "TT Builtin" */
95 + unsigned long smem_start; /* Start of frame buffer mem */
96 + /* (physical address) */
97 + uint32_t smem_len; /* Length of frame buffer mem */
98 + uint32_t type; /* see FB_TYPE_* */
99 + uint32_t type_aux; /* Interleave for interleaved Planes */
100 + uint32_t visual; /* see FB_VISUAL_* */
101 + uint16_t xpanstep; /* zero if no hardware panning */
102 + uint16_t ypanstep; /* zero if no hardware panning */
103 + uint16_t ywrapstep; /* zero if no hardware ywrap */
104 + uint32_t line_length; /* length of a line in bytes */
105 + unsigned long mmio_start; /* Start of Memory Mapped I/O */
106 + /* (physical address) */
107 + uint32_t mmio_len; /* Length of Memory Mapped I/O */
108 + uint32_t accel; /* Indicate to driver which */
109 + /* specific chip/card we have */
110 + uint16_t reserved[3]; /* Reserved for future compatibility */
111 +};
112 +
113 +struct fb_cmap {
114 + uint32_t start; /* First entry */
115 + uint32_t len; /* Number of entries */
116 + uint16_t *red; /* Red values */
117 + uint16_t *green;
118 + uint16_t *blue;
119 + uint16_t *transp; /* transparency, can be NULL */
120 +};
121 +
122 +#define FB_VISUAL_TRUECOLOR 2 /* True color */
123 +
124 +#define COLORLEVELS (1 << 8)
125 +
126 +struct scroll_data {
127 + int size;
128 + int srv_size;
129 + int offset;
130 + int pos;
131 +};
132 +
133 +struct globals {
134 + struct termios term_orig;
135 + struct pollfd ufds[3];
136 +#define kbd_fd ufds[0].fd
137 +#define vnc_fd ufds[1].fd
138 +#define rat_fd ufds[2].fd
139 + struct scroll_data scroll[2];
140 +#define cols scroll[0].size
141 +#define srv_cols scroll[0].srv_size
142 +#define oc scroll[0].offset
143 +#define mc scroll[0].pos
144 +#define rows scroll[1].size
145 +#define srv_rows scroll[1].srv_size
146 +#define or scroll[1].offset
147 +#define mr scroll[1].pos
148 + char rat_buttons;
149 + int fb_fd;
150 + void *fb_ptr;
151 + int bpp;
152 + int nr, ng, nb;
153 + struct fb_var_screeninfo vinfo;
154 + struct fb_fix_screeninfo finfo;
155 + unsigned short red[COLORLEVELS], green[COLORLEVELS], blue[COLORLEVELS];
156 +};
157 +
158 +#define G (*ptr_to_globals)
159 +#define INIT_G() do { \
160 + SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
161 +} while (0)
162 +
163 +static int fb_len(void)
164 +{
165 + return G.finfo.line_length * G.vinfo.yres_virtual;
166 +}
167 +
168 +static void fb_ioctl_cmap(int fct, struct fb_cmap *cmap)
169 +{
170 + if (G.finfo.visual == FB_VISUAL_TRUECOLOR)
171 + return;
172 + cmap->start = 0;
173 + cmap->len = MAX(G.nr, MAX(G.ng, G.nb));
174 + cmap->transp = NULL;
175 + xioctl(G.fb_fd, fct, cmap);
176 +}
177 +
178 +static void fb_cmap_save(int save)
179 +{
180 + struct fb_cmap cmap;
181 +
182 + cmap.red = G.red;
183 + cmap.green = G.green;
184 + cmap.blue = G.blue;
185 + fb_ioctl_cmap(save ? FBIOGETCMAP : FBIOPUTCMAP, &cmap);
186 +}
187 +
188 +static void fb_build_cmap(unsigned short *color, int n)
189 +{
190 + int i, inc = 65535 / (n - 1);
191 +
192 + for (i = 0; n--; i += inc)
193 + *color++ = i;
194 +}
195 +
196 +static void fb_cmap(void)
197 +{
198 + unsigned short red[COLORLEVELS], green[COLORLEVELS], blue[COLORLEVELS];
199 + struct fb_cmap cmap;
200 +
201 + fb_build_cmap(cmap.red = red, G.nr);
202 + fb_build_cmap(cmap.green = green, G.ng);
203 + fb_build_cmap(cmap.blue = blue, G.nb);
204 + fb_ioctl_cmap(FBIOPUTCMAP, &cmap);
205 +}
206 +
207 +static void fb_init(void)
208 +{
209 + G.fb_fd = xopen(DEFAULTFBDEV, O_RDWR);
210 + xioctl(G.fb_fd, FBIOGET_VSCREENINFO, &G.vinfo);
211 + xioctl(G.fb_fd, FBIOGET_FSCREENINFO, &G.finfo);
212 + close_on_exec_on(G.fb_fd);
213 + G.fb_ptr = mmap(NULL, fb_len(), PROT_READ | PROT_WRITE, MAP_SHARED, G.fb_fd, 0);
214 + if (G.fb_ptr == MAP_FAILED)
215 + bb_perror_msg_and_die("mmap");
216 + G.bpp = (G.vinfo.bits_per_pixel + 7) >> 3;
217 + G.nr = 1 << G.vinfo.red.length;
218 + G.nb = 1 << G.vinfo.blue.length;
219 + G.ng = 1 << G.vinfo.green.length;
220 + fb_cmap_save(1);
221 + fb_cmap();
222 +}
223 +
224 +static void fb_free(void)
225 +{
226 + fb_cmap_save(0);
227 + munmap(G.fb_ptr, fb_len());
228 + close(G.fb_fd);
229 +}
230 +
231 +#define fb_rows vinfo.yres
232 +#define fb_cols vinfo.xres
233 +
234 +static void fb_set(int r, int c, void *mem, int len)
235 +{
236 + memcpy(G.fb_ptr + (r + G.vinfo.yoffset) * G.finfo.line_length +
237 + (c + G.vinfo.xoffset) * G.bpp, mem, len * G.bpp);
238 +}
239 +
240 +#define line_buffer bb_common_bufsiz1
241 +#define MAXPIX (sizeof(line_buffer)/sizeof(uint32_t))
242 +
243 +static void skip(int len)
244 +{
245 + int n;
246 + while (len > 0 && (n = read(G.vnc_fd, line_buffer,
247 + MIN(len, sizeof(line_buffer)))) > 0)
248 + len -= n;
249 +}
250 +
251 +static void vnc_init(void)
252 +{
253 + struct vnc_client_init clientinit;
254 + struct vnc_server_init serverinit;
255 + struct vnc_client_pixelfmt pixfmt_cmd;
256 + int connstat = VNC_CONN_FAILED;
257 +
258 + write(G.vnc_fd, "RFB 003.003\n", 12);
259 + skip(12);
260 +
261 + xread(G.vnc_fd, &connstat, sizeof(connstat));
262 +
263 + if (ntohl(connstat) != VNC_CONN_NOAUTH)
264 + bb_perror_msg_and_die("vnc auth");
265 +
266 + clientinit.shared = 1;
267 + write(G.vnc_fd, &clientinit, sizeof(clientinit));
268 + read(G.vnc_fd, &serverinit, sizeof(serverinit));
269 +
270 + fb_init();
271 + G.srv_cols = ntohs(serverinit.w);
272 + G.srv_rows = ntohs(serverinit.h);
273 + G.cols = MIN(G.srv_cols, G.fb_cols);
274 + G.rows = MIN(G.srv_rows, G.fb_rows);
275 + G.mr = G.rows / 2;
276 + G.mc = G.cols / 2;
277 +
278 + skip(ntohl(serverinit.len));
279 + pixfmt_cmd.type = VNC_CLIENT_PIXFMT;
280 + pixfmt_cmd.format.bigendian = 0;
281 + pixfmt_cmd.format.truecolor = 1;
282 + pixfmt_cmd.format.bpp =
283 + pixfmt_cmd.format.depth = G.bpp << 3;
284 + pixfmt_cmd.format.rmax = htons(G.nr - 1);
285 + pixfmt_cmd.format.gmax = htons(G.ng - 1);
286 + pixfmt_cmd.format.bmax = htons(G.nb - 1);
287 + pixfmt_cmd.format.rshl = G.vinfo.red.offset;
288 + pixfmt_cmd.format.gshl = G.vinfo.green.offset;
289 + pixfmt_cmd.format.bshl = G.vinfo.blue.offset;
290 + write(G.vnc_fd, &pixfmt_cmd, sizeof(pixfmt_cmd));
291 +}
292 +
293 +static void vnc_refresh(int inc)
294 +{
295 + struct vnc_client_fbup fbup_req;
296 + fbup_req.type = VNC_CLIENT_FBUP;
297 + fbup_req.inc = inc;
298 + fbup_req.x = htons(G.oc);
299 + fbup_req.y = htons(G.or);
300 + fbup_req.w = htons(G.oc + G.cols);
301 + fbup_req.h = htons(G.or + G.rows);
302 + write(G.vnc_fd, &fbup_req, sizeof(fbup_req));
303 +}
304 +
305 +static void cleanup(void)
306 +{
307 +#define RESETSTR "\x1b[?25h\x1b[2J\x1b[H"
308 + fb_free();
309 + tcsetattr_stdin_TCSANOW(&G.term_orig);
310 + write(STDOUT_FILENO, RESETSTR, sizeof(RESETSTR));
311 + if (ENABLE_FEATURE_CLEAN_UP) {
312 + close(G.vnc_fd);
313 + close(G.rat_fd);
314 + }
315 +}
316 +
317 +static void killed(int code) NORETURN;
318 +static void killed(int code)
319 +{
320 + cleanup();
321 + if (code > EXIT_FAILURE)
322 + kill_myself_with_sig(code);
323 + exit(code);
324 +}
325 +
326 +static void vnc_event(void)
327 +{
328 + struct vnc_rect uprect;
329 + union {
330 + struct vnc_server_fbup fbup;
331 + struct vnc_server_cuttext cuttext;
332 + struct vnc_server_colormap colormap;
333 + } msg;
334 + int n;
335 +
336 + switch (xread_char(G.vnc_fd)) {
337 + case VNC_SERVER_FBUP:
338 + xread(G.vnc_fd, &msg.fbup.pad, sizeof(msg.fbup) - 1);
339 + n = ntohs(msg.fbup.n);
340 + while (n--) {
341 + int x, y, w, h, l, i;
342 + xread(G.vnc_fd, &uprect, sizeof(uprect));
343 + if (uprect.enc != 0)
344 + killed(1);
345 + i = 0;
346 + x = ntohs(uprect.x) - G.oc;
347 + y = ntohs(uprect.y) - G.or;
348 + w = ntohs(uprect.w);
349 + h = ntohs(uprect.h);
350 + l = MIN(w, G.cols - x);
351 + if (x < 0) {
352 + l = MIN(w + x, G.cols);
353 + i = -x;
354 + x = 0;
355 + }
356 + for (; h--; y++) {
357 + int a, b, c = i;
358 + for (a = b = 0; w > b; b += a, c = 0) {
359 + int len;
360 + a = MIN(w - b, MAXPIX);
361 + len = MIN(a, l - b) - c;
362 + xread(G.vnc_fd, line_buffer, a * G.bpp);
363 + if (y >= 0 && y < G.rows && len > 0)
364 + fb_set(y, x + b,
365 + line_buffer + (c * G.bpp),
366 + len);
367 + }
368 + }
369 + }
370 + break;
371 + case VNC_SERVER_BELL:
372 + break;
373 + case VNC_SERVER_CUTTEXT:
374 + xread(G.vnc_fd, &msg.cuttext.pad1, sizeof(msg.cuttext) - 1);
375 + skip(ntohl(msg.cuttext.len));
376 + break;
377 + case VNC_SERVER_COLORMAP:
378 + xread(G.vnc_fd, &msg.colormap.pad, sizeof(msg.colormap) - 1);
379 + skip(ntohs(msg.colormap.n) * 3 * 2);
380 + break;
381 + default:
382 + killed(1);
383 + }
384 +}
385 +
386 +static int update_scroll(struct scroll_data *s)
387 +{
388 + int shift = s->size / 5;
389 + int max = s->srv_size - s->size;
390 + int status = 0;
391 + if (s->pos < s->offset) {
392 + if ((s->offset -= shift) < 0)
393 + s->offset = 0;
394 + }
395 + else if (s->pos >= s->offset + s->size && s->offset < max) {
396 + if ((s->offset += shift) > max)
397 + s->offset = max;
398 + }
399 + else status++;
400 + s->pos = MAX(s->offset, MIN(s->offset + s->size - 1, s->pos));
401 + return status;
402 +}
403 +
404 +static void rat_event(void)
405 +{
406 + static u8 btn2vnc[8] = {
407 + 0, VNC_BUTTON1_MASK, VNC_BUTTON3_MASK,
408 + VNC_BUTTON1_MASK + VNC_BUTTON3_MASK, VNC_BUTTON2_MASK,
409 + VNC_BUTTON1_MASK + VNC_BUTTON2_MASK,
410 + VNC_BUTTON2_MASK + VNC_BUTTON3_MASK,
411 + VNC_BUTTON1_MASK + VNC_BUTTON2_MASK + VNC_BUTTON3_MASK
412 + };
413 + signed char ie[4];
414 + struct vnc_client_ratevent me = {VNC_CLIENT_RATEVENT};
415 + int refresh;
416 +
417 + xread(G.rat_fd, &ie, sizeof(ie));
418 + G.mc += ie[1];
419 + G.mr -= ie[2];
420 + refresh = 2 - update_scroll(&G.scroll[0]) - update_scroll(&G.scroll[1]);
421 + me.mask = btn2vnc[G.rat_buttons = ie[0] & 7];
422 + if (ie[3] > 0) /* wheel up */
423 + me.mask |= VNC_BUTTON4_MASK;
424 + if (ie[3] < 0) /* wheel down */
425 + me.mask |= VNC_BUTTON5_MASK;
426 + me.y = htons(G.mr);
427 + me.x = htons(G.mc);
428 + write(G.vnc_fd, &me, sizeof(me));
429 + if (refresh)
430 + vnc_refresh(0);
431 +}
432 +
433 +static int press(int key, int down)
434 +{
435 + struct vnc_client_keyevent ke = {VNC_CLIENT_KEYEVENT};
436 + ke.key = htonl(key);
437 + ke.down = down;
438 + return write(G.vnc_fd, &ke, sizeof(ke));
439 +}
440 +
441 +static void kbd_event(void)
442 +{
443 + char key[1024];
444 + int i, nr;
445 +
446 + if ((nr = read(0, key, sizeof(key))) <= 0 )
447 + killed(1);
448 + for (i = 0; i < nr; i++) {
449 + int j, k;
450 + int mod[4];
451 + int nmod;
452 +
453 + k = nmod = 0;
454 + switch (key[i]) {
455 + case 0x08:
456 + case 0x7f:
457 + k = 0xff08;
458 + break;
459 + case 0x1b:
460 + if (G.rat_buttons)
461 + killed(0);
462 + if (i + 2 < nr && key[i + 1] == '[') {
463 + static const char arr2vnc[] = "HDACB";
464 + char *p = strchr(arr2vnc, key[i + 2]);
465 +
466 + if (p) {
467 + k = p - arr2vnc + 0xff50;
468 + i += 2;
469 + break;
470 + }
471 + }
472 + if (i + 1 < nr) {
473 + mod[nmod++] = 0xffe9;
474 + i++;
475 + }
476 + case 0x09:
477 + case 0x0d:
478 + k = 0xff00;
479 + goto getkey;
480 + case 0x0c: /* Mouse button + ^L: redraw */
481 + if (G.rat_buttons)
482 + vnc_refresh(0);
483 + default:
484 + getkey:
485 + k += (unsigned char) key[i];
486 + }
487 + if ((k >= 'A' && k <= 'Z') || strchr(":\"<>?{}|+_()*&^%$#@!~", k))
488 + mod[nmod++] = 0xffe1;
489 + if (k >= 1 && k <= 26) {
490 + k += 'a' - 1;
491 + mod[nmod++] = 0xffe3;
492 + }
493 + mod[nmod] = k;
494 + for (j = 0; j <= nmod; j++)
495 + press(mod[j], 1);
496 + press(k, 0);
497 + for (j = 0; j < nmod; j++)
498 + press(mod[j], 0);
499 + }
500 +}
501 +
502 +static void term_setup(void)
503 +{
504 + struct termios termios;
505 +#define INITSTR "\x1b[?25l\x1b[2J\x1b[H** fbvnc **"
506 +
507 + write(STDOUT_FILENO, INITSTR, sizeof(INITSTR));
508 + tcgetattr (STDIN_FILENO, &termios);
509 + G.term_orig = termios;
510 + cfmakeraw(&termios);
511 + tcsetattr_stdin_TCSANOW(&termios);
512 +}
513 +
514 +int fbvnc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
515 +int fbvnc_main(int argc, char **argv)
516 +{
517 + char *host = (char *) "127.0.0.1";
518 + int port, pending = 0;
519 +
520 + INIT_G();
521 + if (argc >= 2)
522 + host = argv[1];
523 + port = bb_lookup_port((argc >= 3) ? argv[2] : "vnc", "tcp", 5900);
524 + G.vnc_fd = create_and_connect_stream_or_die(host, port);
525 + vnc_init();
526 + G.rat_fd = open("/dev/input/mice", O_RDWR);
527 + write(G.rat_fd, "\xf3\xc8\xf3\x64\xf3\x50", 6); /* for using mouse wheel */
528 + read(G.rat_fd, line_buffer, 1);
529 + term_setup();
530 + atexit(cleanup);
531 + bb_signals(BB_FATAL_SIGS, killed);
532 +
533 + G.ufds[0].events =
534 + G.ufds[1].events =
535 + G.ufds[2].events = POLLIN;
536 + vnc_refresh(0);
537 + while (1) {
538 + int status = poll(G.ufds, 3, 500);
539 + if (status == -1 && errno != EINTR)
540 + killed(1);
541 + if (!status)
542 + continue;
543 + if (G.ufds[0].revents & POLLIN)
544 + kbd_event();
545 + if (G.ufds[1].revents & POLLIN) {
546 + vnc_event();
547 + pending = 0;
548 + }
549 + if (G.ufds[2].revents & POLLIN)
550 + rat_event();
551 + if (!pending++)
552 + vnc_refresh(1);
553 + }
554 +}
555 --- /dev/null
556 +++ busybox/util-linux/vnc.h
557 @@ -0,0 +1,124 @@
558 +#define VNC_CONN_FAILED 0
559 +#define VNC_CONN_NOAUTH 1
560 +#define VNC_CONN_AUTH 2
561 +
562 +#define VNC_AUTH_OK 0
563 +#define VNC_AUTH_FAILED 1
564 +#define VNC_AUTH_TOOMANY 2
565 +
566 +#define VNC_SERVER_FBUP 0
567 +#define VNC_SERVER_COLORMAP 1
568 +#define VNC_SERVER_BELL 2
569 +#define VNC_SERVER_CUTTEXT 3
570 +
571 +#define VNC_CLIENT_PIXFMT 0
572 +#define VNC_CLIENT_COLORMAP 1
573 +#define VNC_CLIENT_SETENC 2
574 +#define VNC_CLIENT_FBUP 3
575 +#define VNC_CLIENT_KEYEVENT 4
576 +#define VNC_CLIENT_RATEVENT 5
577 +#define VNC_CLIENT_CUTTEXT 6
578 +
579 +#define VNC_ENC_RAW 0
580 +#define VNC_ENC_COPYRECT 1
581 +#define VNC_ENC_RRE 2
582 +#define VNC_ENC_CORRE 4
583 +#define VNC_ENC_HEXTILE 5
584 +
585 +#define VNC_BUTTON1_MASK 0x01
586 +#define VNC_BUTTON2_MASK 0x02
587 +#define VNC_BUTTON3_MASK 0x04
588 +#define VNC_BUTTON4_MASK 0x10
589 +#define VNC_BUTTON5_MASK 0x08
590 +
591 +typedef unsigned char u8;
592 +typedef unsigned short u16;
593 +typedef unsigned int u32;
594 +
595 +struct vnc_pixelfmt {
596 + u8 bpp;
597 + u8 depth;
598 + u8 bigendian;
599 + u8 truecolor;
600 + u16 rmax;
601 + u16 gmax;
602 + u16 bmax;
603 + u8 rshl;
604 + u8 gshl;
605 + u8 bshl;
606 +
607 + u8 pad1;
608 + u16 pad2;
609 +};
610 +
611 +struct vnc_client_init {
612 + u8 shared;
613 +};
614 +
615 +struct vnc_server_init {
616 + u16 w;
617 + u16 h;
618 + struct vnc_pixelfmt fmt;
619 + u32 len;
620 + /* char name[len]; */
621 +};
622 +
623 +struct vnc_rect {
624 + u16 x, y;
625 + u16 w, h;
626 + u32 enc;
627 + /* rect bytes */
628 +};
629 +
630 +struct vnc_server_fbup {
631 + u8 type;
632 + u8 pad;
633 + u16 n;
634 + /* struct vnc_rect rects[n]; */
635 +};
636 +
637 +struct vnc_server_cuttext {
638 + u8 type;
639 + u8 pad1;
640 + u16 pad2;
641 + u32 len;
642 + /* char text[length] */
643 +};
644 +
645 +struct vnc_server_colormap {
646 + u8 type;
647 + u8 pad;
648 + u16 first;
649 + u16 n;
650 + /* u8 colors[n * 3 * 2]; */
651 +};
652 +
653 +struct vnc_client_pixelfmt {
654 + u8 type;
655 + u8 pad1;
656 + u16 pad2;
657 + struct vnc_pixelfmt format;
658 +};
659 +
660 +struct vnc_client_fbup {
661 + u8 type;
662 + u8 inc;
663 + u16 x;
664 + u16 y;
665 + u16 w;
666 + u16 h;
667 +};
668 +
669 +struct vnc_client_keyevent {
670 + u8 type;
671 + u8 down;
672 + u16 pad;
673 + u32 key;
674 +};
675 +
676 +struct vnc_client_ratevent {
677 + u8 type;
678 + u8 mask;
679 + u16 x;
680 + u16 y;
681 +};