All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Mastracci <matt@aclaro.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] QEMU RFB (vnc) driver
Date: Thu, 29 Apr 2004 20:22:01 -0600	[thread overview]
Message-ID: <1083291721.28997.11.camel@matt> (raw)

[-- Attachment #1: Type: text/plain, Size: 985 bytes --]

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 <matt@aclaro.com>

[-- Attachment #2: vnc.c --]
[-- Type: text/x-c, Size: 3496 bytes --]

/*
 * 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 <rfb/rfb.h>

#ifndef _WIN32
#include <signal.h>
#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;
}

             reply	other threads:[~2004-04-30  2:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-30  2:22 Matthew Mastracci [this message]
2004-05-05  9:23 ` [Qemu-devel] QEMU RFB (vnc) driver Brad Campbell
2004-05-05 15:12   ` [Qemu-devel] " Matthew Mastracci
2004-05-05 18:34   ` [Qemu-devel] " Fabrice Bellard
2004-05-05 20:49     ` Johannes Schindelin
2004-05-06  7:35       ` Brad Campbell
2004-05-06 15:21       ` [Qemu-devel] " Matthew Mastracci
2004-05-08 10:27       ` [Qemu-devel] " Fabrice Bellard
2004-05-08 15:00         ` Johannes Schindelin
2004-05-05 20:53     ` Johannes Schindelin
2004-05-05 22:05     ` [Qemu-devel] " Matthew Mastracci
2004-05-06  7:47       ` Filip Navara
2004-05-06 15:22         ` Matthew Mastracci

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1083291721.28997.11.camel@matt \
    --to=matt@aclaro.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.