| @@ -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 | |