From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BJNfj-0004lQ-U5 for qemu-devel@nongnu.org; Thu, 29 Apr 2004 22:22:40 -0400 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BJNfA-0004J1-HQ for qemu-devel@nongnu.org; Thu, 29 Apr 2004 22:22:35 -0400 Received: from [64.59.128.220] (helo=bpd2mo2no.prod.shawcable.com) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BJNfA-0004Ip-1I for qemu-devel@nongnu.org; Thu, 29 Apr 2004 22:22:04 -0400 Received: from bpd2mi4no.prod.shawcable.com (bpd2mi4no-qfe3.prod.shawcable.com [10.0.184.123]) by bpd2mo2no.prod.shawcable.com (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0HWY00CBRP8RUG50@bpd2mo2no.prod.shawcable.com> for qemu-devel@nongnu.org; Thu, 29 Apr 2004 20:22:03 -0600 (MDT) Received: from [192.168.145.99] (S01060050bae85601.cg.shawcable.net [68.145.131.109]) by bpd2mi4no.prod.shawcable.com (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0HWY00C0PP8GJQ00@bpd2mi4no.prod.shawcable.com> for qemu-devel@nongnu.org; Thu, 29 Apr 2004 20:21:52 -0600 (MDT) Date: Thu, 29 Apr 2004 20:22:01 -0600 From: Matthew Mastracci Message-id: <1083291721.28997.11.camel@matt> MIME-version: 1.0 Content-type: multipart/mixed; boundary="=-8uXw8LhyWrn++76+V1cn" Subject: [Qemu-devel] QEMU RFB (vnc) driver Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --=-8uXw8LhyWrn++76+V1cn Content-Type: text/plain Content-Transfer-Encoding: 7bit I'm working on adding RFB support for QEMU. I've attached my work-in-progress here. You'll need to compile and link against libvncserver to make it work- I'm not an autoconf wizard, so I just hacked my local version for now. The whole thing works surprisingly well. I managed to talk to QEMU on my Linux box from my LAN-connected Windows box with amazing performance. It's a bit of a pain using the mouse over VNC since everything is done using relative position packets. It might be possible to emulate a Synaptics PS/2 touchpad (which supports absolute positioning and is supported under Windows and X) to make this a bit easier, but I'm not certain how difficult that would be. It might be easier to whip up a special VNC client that supports mouse capturing. :) I've also left the keymapping as a "work in progress" until I find an easy way to map from the vnc codes (which seem to be X codes) to the PC-101 scancodes. Any ideas? -- Matthew Mastracci --=-8uXw8LhyWrn++76+V1cn Content-Disposition: attachment; filename=vnc.c Content-Type: text/x-c; name=vnc.c; charset=UTF-8 Content-Transfer-Encoding: 7bit /* * QEMU VNC display driver * * Copyright (c) 2003 Fabrice Bellard * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "vl.h" #include #ifndef _WIN32 #include #endif rfbScreenInfoPtr rfbScreen; int last_x_position; int last_y_position; static void vnc_update(DisplayState *ds, int x, int y, int w, int h) { // printf("updating x=%d y=%d w=%d h=%d\n", x, y, w, h); rfbMarkRectAsModified(rfbScreen, x, y, x+w, y+h); } static void vnc_resize(DisplayState *ds, int w, int h) { printf("resize! w=%i h=%i\n", w, h); ds->data = rfbScreen->frameBuffer + ( 1024 - w ) + ( 768 - h ) * 1024; ds->linesize = 1024*2; ds->depth = 16; rfbFillRect(rfbScreen, 0, 0, 1023, 767, 0); } static void vnc_refresh(DisplayState *ds) { vga_update_display(); // rfbProcessEvents(rfbScreen,1000000); } static void vnc_pointer(int buttonMask, int x, int y, rfbClientPtr cl) { int dx, dy, buttons; dx = x - last_x_position; last_x_position = x; dy = y - last_y_position; last_y_position = y; buttons = 0; if ( buttonMask & 1 ) buttons |= MOUSE_EVENT_LBUTTON; if ( buttonMask & 2 ) buttons |= MOUSE_EVENT_MBUTTON; if ( buttonMask & 4 ) buttons |= MOUSE_EVENT_RBUTTON; kbd_mouse_event(dx, dy, 0, buttons); } static void vnc_keyboard(rfbBool down, rfbKeySym key, rfbClientPtr cl) { if (key == 'A') if (down) kbd_put_keycode(0x38); else kbd_put_keycode(0x38 | 0x80); } void vnc_display_init(DisplayState *ds) { int flags; last_x_position = 0; last_y_position = 0; rfbScreen = rfbGetScreen(0, NULL, 1024, 768, 5, 3, 2); rfbScreen->frameBuffer = (char*)malloc(1074*768*2); rfbScreen->rfbServerFormat.bitsPerPixel = 16; rfbScreen->rfbServerFormat.depth = 16; rfbScreen->rfbServerFormat.bigEndian = 0; rfbScreen->rfbServerFormat.trueColour = 1; rfbScreen->rfbServerFormat.redMax = (1 << 5) - 1; rfbScreen->rfbServerFormat.greenMax = (1 << 6) - 1; rfbScreen->rfbServerFormat.blueMax = (1 << 5) - 1; rfbScreen->rfbServerFormat.redShift = 11; rfbScreen->rfbServerFormat.greenShift = 5; rfbScreen->rfbServerFormat.blueShift = 0; rfbScreen->ptrAddEvent = vnc_pointer; rfbScreen->kbdAddEvent = vnc_keyboard; rfbInitServer(rfbScreen); rfbRunEventLoop(rfbScreen, 1000000, TRUE); vnc_resize(ds, 640, 480); ds->dpy_update = vnc_update; ds->dpy_resize = vnc_resize; ds->dpy_refresh = vnc_refresh; } --=-8uXw8LhyWrn++76+V1cn--