Fri Dec 30 20:08:00 2011 UTC ()
report rfb pointer events


(jmcneill)
diff -r1.52 -r1.53 src/sys/arch/usermode/include/thunk.h
diff -r1.66 -r1.67 src/sys/arch/usermode/usermode/thunk.c

cvs diff -r1.52 -r1.53 src/sys/arch/usermode/include/thunk.h (expand / switch to unified diff)

--- src/sys/arch/usermode/include/thunk.h 2011/12/30 14:20:34 1.52
+++ src/sys/arch/usermode/include/thunk.h 2011/12/30 20:08:00 1.53
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: thunk.h,v 1.52 2011/12/30 14:20:34 jmcneill Exp $ */ 1/* $NetBSD: thunk.h,v 1.53 2011/12/30 20:08:00 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -177,26 +177,31 @@ typedef enum { @@ -177,26 +177,31 @@ typedef enum {
177 THUNK_RFB_FRAMEBUFFER_UPDATE_REQUEST = 3, 177 THUNK_RFB_FRAMEBUFFER_UPDATE_REQUEST = 3,
178 THUNK_RFB_KEY_EVENT = 4, 178 THUNK_RFB_KEY_EVENT = 4,
179 THUNK_RFB_POINTER_EVENT = 5, 179 THUNK_RFB_POINTER_EVENT = 5,
180 THUNK_RFB_CLIENT_CUT_TEXT = 6, 180 THUNK_RFB_CLIENT_CUT_TEXT = 6,
181} thunk_rfb_message_t; 181} thunk_rfb_message_t;
182 182
183typedef struct { 183typedef struct {
184 thunk_rfb_message_t message_type; 184 thunk_rfb_message_t message_type;
185 union { 185 union {
186 struct { 186 struct {
187 uint8_t down_flag; 187 uint8_t down_flag;
188 uint32_t keysym; 188 uint32_t keysym;
189 } key_event; 189 } key_event;
 190 struct {
 191 uint8_t button_mask;
 192 uint16_t absx;
 193 uint16_t absy;
 194 } pointer_event;
190 } data; 195 } data;
191} thunk_rfb_event_t; 196} thunk_rfb_event_t;
192 197
193 198
194typedef struct { 199typedef struct {
195 uint8_t enc; 200 uint8_t enc;
196 uint16_t x, y, w, h; 201 uint16_t x, y, w, h;
197 uint16_t srcx, srcy; 202 uint16_t srcx, srcy;
198 uint8_t pixel[4]; 203 uint8_t pixel[4];
199} thunk_rfb_update_t; 204} thunk_rfb_update_t;
200#define THUNK_RFB_TYPE_RAW 0 205#define THUNK_RFB_TYPE_RAW 0
201#define THUNK_RFB_TYPE_COPYRECT 1 206#define THUNK_RFB_TYPE_COPYRECT 1
202#define THUNK_RFB_TYPE_RRE 2 /* rectangle fill */ 207#define THUNK_RFB_TYPE_RRE 2 /* rectangle fill */

cvs diff -r1.66 -r1.67 src/sys/arch/usermode/usermode/thunk.c (expand / switch to unified diff)

--- src/sys/arch/usermode/usermode/thunk.c 2011/12/30 14:20:34 1.66
+++ src/sys/arch/usermode/usermode/thunk.c 2011/12/30 20:08:00 1.67
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: thunk.c,v 1.66 2011/12/30 14:20:34 jmcneill Exp $ */ 1/* $NetBSD: thunk.c,v 1.67 2011/12/30 20:08:00 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -18,27 +18,27 @@ @@ -18,27 +18,27 @@
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30#ifdef __NetBSD__ 30#ifdef __NetBSD__
31__RCSID("$NetBSD: thunk.c,v 1.66 2011/12/30 14:20:34 jmcneill Exp $"); 31__RCSID("$NetBSD: thunk.c,v 1.67 2011/12/30 20:08:00 jmcneill Exp $");
32#endif 32#endif
33 33
34#include <sys/types.h> 34#include <sys/types.h>
35#include <sys/mman.h> 35#include <sys/mman.h>
36#include <sys/reboot.h> 36#include <sys/reboot.h>
37#include <sys/poll.h> 37#include <sys/poll.h>
38#include <sys/sysctl.h> 38#include <sys/sysctl.h>
39#include <sys/socket.h> 39#include <sys/socket.h>
40#include <sys/audioio.h> 40#include <sys/audioio.h>
41#include <sys/shm.h> 41#include <sys/shm.h>
42#include <machine/vmparam.h> 42#include <machine/vmparam.h>
43 43
44#include <net/if.h> 44#include <net/if.h>
@@ -1206,27 +1206,40 @@ thunk_rfb_poll(thunk_rfb_t *rfb, thunk_r @@ -1206,27 +1206,40 @@ thunk_rfb_poll(thunk_rfb_t *rfb, thunk_r
1206 case THUNK_RFB_KEY_EVENT: 1206 case THUNK_RFB_KEY_EVENT:
1207 recv(rfb->clientfd, key_event, sizeof(key_event), MSG_NOSIGNAL); 1207 recv(rfb->clientfd, key_event, sizeof(key_event), MSG_NOSIGNAL);
1208 event->data.key_event.down_flag = key_event[0]; 1208 event->data.key_event.down_flag = key_event[0];
1209 event->data.key_event.keysym = 1209 event->data.key_event.keysym =
1210 ntohl(*(uint32_t *)&key_event[3]); 1210 ntohl(*(uint32_t *)&key_event[3]);
1211#ifdef RFB_DEBUG 1211#ifdef RFB_DEBUG
1212 fprintf(stdout, "rfb: key %04x %s\n", 1212 fprintf(stdout, "rfb: key %04x %s\n",
1213 event->data.key_event.keysym, 1213 event->data.key_event.keysym,
1214 event->data.key_event.down_flag ? "pressed" : "released"); 1214 event->data.key_event.down_flag ? "pressed" : "released");
1215#endif 1215#endif
1216 msg_len = 0; 1216 msg_len = 0;
1217 break; 1217 break;
1218 case THUNK_RFB_POINTER_EVENT: 1218 case THUNK_RFB_POINTER_EVENT:
1219 msg_len = sizeof(pointer_event); 1219 recv(rfb->clientfd, pointer_event, sizeof(pointer_event),
 1220 MSG_NOSIGNAL);
 1221 event->data.pointer_event.button_mask = pointer_event[0];
 1222 event->data.pointer_event.absx =
 1223 ntohs(*(uint16_t *)&pointer_event[1]);
 1224 event->data.pointer_event.absy =
 1225 ntohs(*(uint16_t *)&pointer_event[3]);
 1226#ifdef RFB_DEBUG
 1227 fprintf(stdout, "rfb: pointer mask %02x abs %dx%d\n",
 1228 event->data.pointer_event.button_mask,
 1229 event->data.pointer_event.absx,
 1230 event->data.pointer_event.absy);
 1231#endif
 1232 msg_len = 0;
1220 break; 1233 break;
1221 case THUNK_RFB_CLIENT_CUT_TEXT: 1234 case THUNK_RFB_CLIENT_CUT_TEXT:
1222 recv(rfb->clientfd, client_cut_text, sizeof(client_cut_text), 1235 recv(rfb->clientfd, client_cut_text, sizeof(client_cut_text),
1223 MSG_NOSIGNAL); 1236 MSG_NOSIGNAL);
1224 msg_len = ntohl(*(uint32_t *)&client_cut_text[3]); 1237 msg_len = ntohl(*(uint32_t *)&client_cut_text[3]);
1225 break; 1238 break;
1226 default: 1239 default:
1227 fprintf(stdout, "rfb: unknown message type %d\n", ch); 1240 fprintf(stdout, "rfb: unknown message type %d\n", ch);
1228 close(rfb->clientfd); 1241 close(rfb->clientfd);
1229 rfb->clientfd = -1; 1242 rfb->clientfd = -1;
1230 return -1; 1243 return -1;
1231 } 1244 }
1232 1245