|
Justin M. Forbes |
a81953 |
From 90f6ec84332857752c252b1c3b89d86eb9714b0e Mon Sep 17 00:00:00 2001
|
|
Justin M. Forbes |
a81953 |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
Justin M. Forbes |
a81953 |
Date: Thu, 11 Mar 2010 11:13:28 -0300
|
|
Justin M. Forbes |
a81953 |
Subject: [PATCH 05/39] spice: add keyboard
|
|
Justin M. Forbes |
a81953 |
|
|
Justin M. Forbes |
a81953 |
Open keyboard channel. Now you can type into the spice client and the
|
|
Justin M. Forbes |
a81953 |
keyboard events are sent to your guest. You'll need some other display
|
|
Justin M. Forbes |
a81953 |
like vnc to actually see the guest responding to them though.
|
|
Justin M. Forbes |
a81953 |
---
|
|
Justin M. Forbes |
a81953 |
Makefile.objs | 2 +-
|
|
Justin M. Forbes |
a81953 |
qemu-spice.h | 1 +
|
|
Justin M. Forbes |
a81953 |
spice-input.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
Justin M. Forbes |
a81953 |
spice.c | 2 ++
|
|
Justin M. Forbes |
a81953 |
4 files changed, 61 insertions(+), 1 deletions(-)
|
|
Justin M. Forbes |
a81953 |
create mode 100644 spice-input.c
|
|
Justin M. Forbes |
a81953 |
|
|
Justin M. Forbes |
a81953 |
diff --git a/Makefile.objs b/Makefile.objs
|
|
Justin M. Forbes |
a81953 |
index 569b458..023a0dc 100644
|
|
Justin M. Forbes |
a81953 |
--- a/Makefile.objs
|
|
Justin M. Forbes |
a81953 |
+++ b/Makefile.objs
|
|
Justin M. Forbes |
a81953 |
@@ -89,7 +89,7 @@ common-obj-y += pflib.o
|
|
Justin M. Forbes |
a81953 |
common-obj-$(CONFIG_BRLAPI) += baum.o
|
|
Justin M. Forbes |
a81953 |
common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
|
|
Justin M. Forbes |
a81953 |
|
|
Justin M. Forbes |
a81953 |
-common-obj-$(CONFIG_SPICE) += spice.o
|
|
Justin M. Forbes |
a81953 |
+common-obj-$(CONFIG_SPICE) += spice.o spice-input.o
|
|
Justin M. Forbes |
a81953 |
|
|
Justin M. Forbes |
a81953 |
audio-obj-y = audio.o noaudio.o wavaudio.o mixeng.o
|
|
Justin M. Forbes |
a81953 |
audio-obj-$(CONFIG_SDL) += sdlaudio.o
|
|
Justin M. Forbes |
a81953 |
diff --git a/qemu-spice.h b/qemu-spice.h
|
|
Justin M. Forbes |
a81953 |
index 5597576..ceb3db2 100644
|
|
Justin M. Forbes |
a81953 |
--- a/qemu-spice.h
|
|
Justin M. Forbes |
a81953 |
+++ b/qemu-spice.h
|
|
Justin M. Forbes |
a81953 |
@@ -12,6 +12,7 @@ extern SpiceServer *spice_server;
|
|
Justin M. Forbes |
a81953 |
extern int using_spice;
|
|
Justin M. Forbes |
a81953 |
|
|
Justin M. Forbes |
a81953 |
void qemu_spice_init(void);
|
|
Justin M. Forbes |
a81953 |
+void qemu_spice_input_init(void);
|
|
Justin M. Forbes |
a81953 |
|
|
Justin M. Forbes |
a81953 |
#else /* CONFIG_SPICE */
|
|
Justin M. Forbes |
a81953 |
|
|
Justin M. Forbes |
a81953 |
diff --git a/spice-input.c b/spice-input.c
|
|
Justin M. Forbes |
a81953 |
new file mode 100644
|
|
Justin M. Forbes |
a81953 |
index 0000000..e1014d7
|
|
Justin M. Forbes |
a81953 |
--- /dev/null
|
|
Justin M. Forbes |
a81953 |
+++ b/spice-input.c
|
|
Justin M. Forbes |
a81953 |
@@ -0,0 +1,57 @@
|
|
Justin M. Forbes |
a81953 |
+#include <stdlib.h>
|
|
Justin M. Forbes |
a81953 |
+#include <stdio.h>
|
|
Justin M. Forbes |
a81953 |
+#include <string.h>
|
|
Justin M. Forbes |
a81953 |
+
|
|
Justin M. Forbes |
a81953 |
+#include <spice.h>
|
|
Justin M. Forbes |
a81953 |
+
|
|
Justin M. Forbes |
a81953 |
+#include "qemu-common.h"
|
|
Justin M. Forbes |
a81953 |
+#include "qemu-spice.h"
|
|
Justin M. Forbes |
a81953 |
+#include "console.h"
|
|
Justin M. Forbes |
a81953 |
+
|
|
Justin M. Forbes |
a81953 |
+/* keyboard bits */
|
|
Justin M. Forbes |
a81953 |
+
|
|
Justin M. Forbes |
a81953 |
+typedef struct QemuSpiceKbd {
|
|
Justin M. Forbes |
a81953 |
+ SpiceKbdInstance sin;
|
|
Justin M. Forbes |
a81953 |
+ int ledstate;
|
|
Justin M. Forbes |
a81953 |
+} QemuSpiceKbd;
|
|
Justin M. Forbes |
a81953 |
+
|
|
Justin M. Forbes |
a81953 |
+static void kbd_push_key(SpiceKbdInstance *sin, uint8_t frag);
|
|
Justin M. Forbes |
a81953 |
+static uint8_t kbd_get_leds(SpiceKbdInstance *sin);
|
|
Justin M. Forbes |
a81953 |
+static void kbd_leds(void *opaque, int l);
|
|
Justin M. Forbes |
a81953 |
+
|
|
Justin M. Forbes |
a81953 |
+static const SpiceKbdInterface kbd_interface = {
|
|
Justin M. Forbes |
a81953 |
+ .base.type = SPICE_INTERFACE_KEYBOARD,
|
|
Justin M. Forbes |
a81953 |
+ .base.description = "qemu keyboard",
|
|
Justin M. Forbes |
a81953 |
+ .base.major_version = SPICE_INTERFACE_KEYBOARD_MAJOR,
|
|
Justin M. Forbes |
a81953 |
+ .base.minor_version = SPICE_INTERFACE_KEYBOARD_MINOR,
|
|
Justin M. Forbes |
a81953 |
+ .push_scan_freg = kbd_push_key,
|
|
Justin M. Forbes |
a81953 |
+ .get_leds = kbd_get_leds,
|
|
Justin M. Forbes |
a81953 |
+};
|
|
Justin M. Forbes |
a81953 |
+
|
|
Justin M. Forbes |
a81953 |
+static void kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
|
|
Justin M. Forbes |
a81953 |
+{
|
|
Justin M. Forbes |
a81953 |
+ kbd_put_keycode(frag);
|
|
Justin M. Forbes |
a81953 |
+}
|
|
Justin M. Forbes |
a81953 |
+
|
|
Justin M. Forbes |
a81953 |
+static uint8_t kbd_get_leds(SpiceKbdInstance *sin)
|
|
Justin M. Forbes |
a81953 |
+{
|
|
Justin M. Forbes |
a81953 |
+ QemuSpiceKbd *kbd = container_of(sin, QemuSpiceKbd, sin);
|
|
Justin M. Forbes |
a81953 |
+ return kbd->ledstate;
|
|
Justin M. Forbes |
a81953 |
+}
|
|
Justin M. Forbes |
a81953 |
+
|
|
Justin M. Forbes |
a81953 |
+static void kbd_leds(void *opaque, int ledstate)
|
|
Justin M. Forbes |
a81953 |
+{
|
|
Justin M. Forbes |
a81953 |
+ QemuSpiceKbd *kbd = opaque;
|
|
Justin M. Forbes |
a81953 |
+ kbd->ledstate = ledstate;
|
|
Justin M. Forbes |
a81953 |
+ spice_server_kbd_leds(&kbd->sin, ledstate);
|
|
Justin M. Forbes |
a81953 |
+}
|
|
Justin M. Forbes |
a81953 |
+
|
|
Justin M. Forbes |
a81953 |
+void qemu_spice_input_init(void)
|
|
Justin M. Forbes |
a81953 |
+{
|
|
Justin M. Forbes |
a81953 |
+ QemuSpiceKbd *kbd;
|
|
Justin M. Forbes |
a81953 |
+
|
|
Justin M. Forbes |
a81953 |
+ kbd = qemu_mallocz(sizeof(*kbd));
|
|
Justin M. Forbes |
a81953 |
+ kbd->sin.base.sif = &kbd_interface.base;
|
|
Justin M. Forbes |
a81953 |
+ spice_server_add_interface(spice_server, &kbd->sin.base);
|
|
Justin M. Forbes |
a81953 |
+ qemu_add_led_event_handler(kbd_leds, kbd);
|
|
Justin M. Forbes |
a81953 |
+}
|
|
Justin M. Forbes |
a81953 |
diff --git a/spice.c b/spice.c
|
|
Justin M. Forbes |
a81953 |
index 50fa5ca..c763d52 100644
|
|
Justin M. Forbes |
a81953 |
--- a/spice.c
|
|
Justin M. Forbes |
a81953 |
+++ b/spice.c
|
|
Justin M. Forbes |
a81953 |
@@ -148,4 +148,6 @@ void qemu_spice_init(void)
|
|
Justin M. Forbes |
a81953 |
|
|
Justin M. Forbes |
a81953 |
spice_server_init(spice_server, &core_interface);
|
|
Justin M. Forbes |
a81953 |
using_spice = 1;
|
|
Justin M. Forbes |
a81953 |
+
|
|
Justin M. Forbes |
a81953 |
+ qemu_spice_input_init();
|
|
Justin M. Forbes |
a81953 |
}
|
|
Justin M. Forbes |
a81953 |
--
|
|
Justin M. Forbes |
a81953 |
1.7.2.3
|
|
Justin M. Forbes |
a81953 |
|