Commit aa71cf802eb884dcdaebae6fbbd008248a64a01b
1 parent
d5853c20
QEMU Microsoft serial mouse emulation
Adds "msmouse" character device, which emulates a serial mouse. Use it with -serial msmouse. Signed-Off-By: Lubomir Rintel <lkundrak@v3.sk> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6559 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
5 changed files
with
88 additions
and
0 deletions
Makefile.target
@@ -574,6 +574,9 @@ OBJS += pcnet.o | @@ -574,6 +574,9 @@ OBJS += pcnet.o | ||
574 | OBJS += rtl8139.o | 574 | OBJS += rtl8139.o |
575 | OBJS += e1000.o | 575 | OBJS += e1000.o |
576 | 576 | ||
577 | +# Serial mouse | ||
578 | +OBJS += msmouse.o | ||
579 | + | ||
577 | ifeq ($(TARGET_BASE_ARCH), i386) | 580 | ifeq ($(TARGET_BASE_ARCH), i386) |
578 | # Hardware support | 581 | # Hardware support |
579 | OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o | 582 | OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o |
hw/msmouse.c
0 → 100644
1 | +/* | ||
2 | + * QEMU Microsoft serial mouse emulation | ||
3 | + * | ||
4 | + * Copyright (c) 2008 Lubomir Rintel | ||
5 | + * | ||
6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
7 | + * of this software and associated documentation files (the "Software"), to deal | ||
8 | + * in the Software without restriction, including without limitation the rights | ||
9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
10 | + * copies of the Software, and to permit persons to whom the Software is | ||
11 | + * furnished to do so, subject to the following conditions: | ||
12 | + * | ||
13 | + * The above copyright notice and this permission notice shall be included in | ||
14 | + * all copies or substantial portions of the Software. | ||
15 | + * | ||
16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
19 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
22 | + * THE SOFTWARE. | ||
23 | + */ | ||
24 | +#include <stdlib.h> | ||
25 | +#include "../qemu-common.h" | ||
26 | +#include "../qemu-char.h" | ||
27 | +#include "../console.h" | ||
28 | +#include "msmouse.h" | ||
29 | + | ||
30 | +#define MSMOUSE_LO6(n) ((n) & 0x3f) | ||
31 | +#define MSMOUSE_HI2(n) (((n) & 0xc0) >> 6) | ||
32 | + | ||
33 | +static void msmouse_event(void *opaque, | ||
34 | + int dx, int dy, int dz, int buttons_state) | ||
35 | +{ | ||
36 | + CharDriverState *chr = (CharDriverState *)opaque; | ||
37 | + | ||
38 | + unsigned char bytes[4] = { 0x40, 0x00, 0x00, 0x00 }; | ||
39 | + | ||
40 | + /* Movement deltas */ | ||
41 | + bytes[0] |= (MSMOUSE_HI2(dy) << 2) | MSMOUSE_HI2(dx); | ||
42 | + bytes[1] |= MSMOUSE_LO6(dx); | ||
43 | + bytes[2] |= MSMOUSE_LO6(dy); | ||
44 | + | ||
45 | + /* Buttons */ | ||
46 | + bytes[0] |= (buttons_state & 0x01 ? 0x20 : 0x00); | ||
47 | + bytes[0] |= (buttons_state & 0x02 ? 0x10 : 0x00); | ||
48 | + bytes[3] |= (buttons_state & 0x04 ? 0x20 : 0x00); | ||
49 | + | ||
50 | + /* We always send the packet of, so that we do not have to keep track | ||
51 | + of previous state of the middle button. This can potentially confuse | ||
52 | + some very old drivers for two button mice though. */ | ||
53 | + qemu_chr_read(chr, bytes, 4); | ||
54 | +} | ||
55 | + | ||
56 | +static int msmouse_chr_write (struct CharDriverState *s, const uint8_t *buf, int len) | ||
57 | +{ | ||
58 | + /* Ignore writes to mouse port */ | ||
59 | + return len; | ||
60 | +} | ||
61 | + | ||
62 | +static void msmouse_chr_close (struct CharDriverState *chr) | ||
63 | +{ | ||
64 | + qemu_free (chr); | ||
65 | +} | ||
66 | + | ||
67 | +CharDriverState *qemu_chr_open_msmouse(void) | ||
68 | +{ | ||
69 | + CharDriverState *chr; | ||
70 | + | ||
71 | + chr = qemu_mallocz(sizeof(CharDriverState)); | ||
72 | + chr->chr_write = msmouse_chr_write; | ||
73 | + chr->chr_close = msmouse_chr_close; | ||
74 | + | ||
75 | + qemu_add_mouse_event_handler(msmouse_event, chr, 0, "QEMU Microsoft Mouse"); | ||
76 | + | ||
77 | + return chr; | ||
78 | +} |
hw/msmouse.h
0 → 100644
qemu-char.c
@@ -30,6 +30,7 @@ | @@ -30,6 +30,7 @@ | ||
30 | #include "block.h" | 30 | #include "block.h" |
31 | #include "hw/usb.h" | 31 | #include "hw/usb.h" |
32 | #include "hw/baum.h" | 32 | #include "hw/baum.h" |
33 | +#include "hw/msmouse.h" | ||
33 | 34 | ||
34 | #include <unistd.h> | 35 | #include <unistd.h> |
35 | #include <fcntl.h> | 36 | #include <fcntl.h> |
@@ -2105,6 +2106,8 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*i | @@ -2105,6 +2106,8 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*i | ||
2105 | } else { | 2106 | } else { |
2106 | printf("Unable to open driver: %s\n", p); | 2107 | printf("Unable to open driver: %s\n", p); |
2107 | } | 2108 | } |
2109 | + } else if (!strcmp(filename, "msmouse")) { | ||
2110 | + chr = qemu_chr_open_msmouse(); | ||
2108 | } else | 2111 | } else |
2109 | #ifndef _WIN32 | 2112 | #ifndef _WIN32 |
2110 | if (strstart(filename, "unix:", &p)) { | 2113 | if (strstart(filename, "unix:", &p)) { |
qemu-doc.texi
@@ -961,6 +961,8 @@ This implements UDP Net Console. | @@ -961,6 +961,8 @@ This implements UDP Net Console. | ||
961 | When @var{remote_host} or @var{src_ip} are not specified | 961 | When @var{remote_host} or @var{src_ip} are not specified |
962 | they default to @code{0.0.0.0}. | 962 | they default to @code{0.0.0.0}. |
963 | When not using a specified @var{src_port} a random port is automatically chosen. | 963 | When not using a specified @var{src_port} a random port is automatically chosen. |
964 | +@item msmouse | ||
965 | +Three button serial mouse. Configure the guest to use Microsoft protocol. | ||
964 | 966 | ||
965 | If you just want a simple readonly console you can use @code{netcat} or | 967 | If you just want a simple readonly console you can use @code{netcat} or |
966 | @code{nc}, by starting qemu with: @code{-serial udp::4555} and nc as: | 968 | @code{nc}, by starting qemu with: @code{-serial udp::4555} and nc as: |