From: Anthony Liguori <anthony@codemonkey.ws>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 6/9] spice: add keyboard
Date: Thu, 19 Aug 2010 09:24:18 -0500 [thread overview]
Message-ID: <4C6D3E92.8060604@codemonkey.ws> (raw)
In-Reply-To: <1282221625-29501-7-git-send-email-kraxel@redhat.com>
On 08/19/2010 07:40 AM, Gerd Hoffmann wrote:
> Open keyboard channel. Now you can type into the spice client and the
> keyboard events are sent to your guest. You'll need some other display
> like vnc to actually see the guest responding to them though.
>
> Signed-off-by: Gerd Hoffmann<kraxel@redhat.com>
> ---
> Makefile.objs | 2 +-
> qemu-spice.h | 1 +
> spice-input.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> spice.c | 2 ++
> 4 files changed, 61 insertions(+), 1 deletions(-)
> create mode 100644 spice-input.c
>
> diff --git a/Makefile.objs b/Makefile.objs
> index 021067b..6ddb373 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -88,7 +88,7 @@ common-obj-y += pflib.o
> common-obj-$(CONFIG_BRLAPI) += baum.o
> common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
>
> -common-obj-$(CONFIG_SPICE) += spice.o
> +common-obj-$(CONFIG_SPICE) += spice.o spice-input.o
>
> audio-obj-y = audio.o noaudio.o wavaudio.o mixeng.o
> audio-obj-$(CONFIG_SDL) += sdlaudio.o
> diff --git a/qemu-spice.h b/qemu-spice.h
> index 5597576..ceb3db2 100644
> --- a/qemu-spice.h
> +++ b/qemu-spice.h
> @@ -12,6 +12,7 @@ extern SpiceServer *spice_server;
> extern int using_spice;
>
> void qemu_spice_init(void);
> +void qemu_spice_input_init(void);
>
> #else /* CONFIG_SPICE */
>
> diff --git a/spice-input.c b/spice-input.c
> new file mode 100644
> index 0000000..e1014d7
> --- /dev/null
> +++ b/spice-input.c
> @@ -0,0 +1,57 @@
> +#include<stdlib.h>
> +#include<stdio.h>
> +#include<string.h>
>
copyright and extra headers.
> +
> +#include<spice.h>
> +
> +#include "qemu-common.h"
> +#include "qemu-spice.h"
> +#include "console.h"
> +
> +/* keyboard bits */
> +
> +typedef struct QemuSpiceKbd {
> + SpiceKbdInstance sin;
> + int ledstate;
> +} QemuSpiceKbd;
> +
> +static void kbd_push_key(SpiceKbdInstance *sin, uint8_t frag);
> +static uint8_t kbd_get_leds(SpiceKbdInstance *sin);
> +static void kbd_leds(void *opaque, int l);
> +
> +static const SpiceKbdInterface kbd_interface = {
> + .base.type = SPICE_INTERFACE_KEYBOARD,
> + .base.description = "qemu keyboard",
> + .base.major_version = SPICE_INTERFACE_KEYBOARD_MAJOR,
> + .base.minor_version = SPICE_INTERFACE_KEYBOARD_MINOR,
> + .push_scan_freg = kbd_push_key,
> + .get_leds = kbd_get_leds,
> +};
> +
> +static void kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
> +{
> + kbd_put_keycode(frag);
> +}
>
Instead of using this interface which includes multi-byte sequences, it
would probably make sense to use the same compressed encoding that VNC
uses and introduce a new function that takes this encoding type. The
advantage is that one call == one keycode so it's far less prone to
goofiness.
> +
> +static uint8_t kbd_get_leds(SpiceKbdInstance *sin)
> +{
> + QemuSpiceKbd *kbd = container_of(sin, QemuSpiceKbd, sin);
> + return kbd->ledstate;
> +}
> +
> +static void kbd_leds(void *opaque, int ledstate)
> +{
> + QemuSpiceKbd *kbd = opaque;
> + kbd->ledstate = ledstate;
> + spice_server_kbd_leds(&kbd->sin, ledstate);
> +}
>
It's probably more robust in the long term to explicitly convert the
ledstate to from the QEMU format to the libspice format even if they
both happen to be the same.
Regards,
Anthony Liguori
> +void qemu_spice_input_init(void)
> +{
> + QemuSpiceKbd *kbd;
> +
> + kbd = qemu_mallocz(sizeof(*kbd));
> + kbd->sin.base.sif =&kbd_interface.base;
> + spice_server_add_interface(spice_server,&kbd->sin.base);
> + qemu_add_led_event_handler(kbd_leds, kbd);
> +}
> diff --git a/spice.c b/spice.c
> index 50fa5ca..c763d52 100644
> --- a/spice.c
> +++ b/spice.c
> @@ -148,4 +148,6 @@ void qemu_spice_init(void)
>
> spice_server_init(spice_server,&core_interface);
> using_spice = 1;
> +
> + qemu_spice_input_init();
> }
>
next prev parent reply other threads:[~2010-08-19 14:40 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-19 12:40 [Qemu-devel] [PATCH 0/9] initial spice support Gerd Hoffmann
2010-08-19 12:40 ` [Qemu-devel] [PATCH 1/9] add pflib: PixelFormat conversion library Gerd Hoffmann
2010-08-19 14:04 ` Anthony Liguori
2010-08-19 15:34 ` Gerd Hoffmann
2010-08-19 19:09 ` Anthony Liguori
2010-08-20 10:38 ` Gerd Hoffmann
2010-08-19 12:40 ` [Qemu-devel] [PATCH 2/9] configure: add logging Gerd Hoffmann
2010-08-19 14:05 ` Anthony Liguori
2010-08-19 15:44 ` Gerd Hoffmann
2010-08-19 12:40 ` [Qemu-devel] [PATCH 3/9] add spice into the configure file Gerd Hoffmann
2010-08-19 14:06 ` Anthony Liguori
2010-08-19 12:40 ` [Qemu-devel] [PATCH 4/9] configure: require spice 0.5.3 Gerd Hoffmann
2010-08-19 12:40 ` [Qemu-devel] [PATCH 5/9] spice: core bits Gerd Hoffmann
2010-08-19 14:19 ` Anthony Liguori
2010-08-20 11:54 ` Gerd Hoffmann
2010-08-25 12:37 ` Gerd Hoffmann
2010-08-19 12:40 ` [Qemu-devel] [PATCH 6/9] spice: add keyboard Gerd Hoffmann
2010-08-19 14:24 ` Anthony Liguori [this message]
2010-08-20 12:34 ` Gerd Hoffmann
2010-08-20 13:18 ` Anthony Liguori
2010-08-20 13:56 ` Gerd Hoffmann
2010-08-20 14:15 ` Daniel P. Berrange
2010-08-20 14:49 ` Gerd Hoffmann
2010-08-20 15:01 ` Daniel P. Berrange
2010-08-19 12:40 ` [Qemu-devel] [PATCH 7/9] spice: add mouse Gerd Hoffmann
2010-08-19 14:25 ` Anthony Liguori
2010-08-20 12:42 ` Gerd Hoffmann
2010-08-20 13:19 ` Anthony Liguori
2010-08-20 14:03 ` Gerd Hoffmann
2010-08-20 14:37 ` Anthony Liguori
2010-08-19 12:40 ` [Qemu-devel] [PATCH 8/9] spice: simple display Gerd Hoffmann
2010-08-19 14:39 ` Anthony Liguori
2010-08-19 15:23 ` malc
2010-08-19 15:34 ` Anthony Liguori
2010-08-19 15:36 ` malc
2010-08-19 19:03 ` Anthony Liguori
2010-08-19 19:10 ` malc
2010-08-19 15:40 ` Alexander Graf
2010-08-25 11:09 ` Gerd Hoffmann
2010-08-19 16:05 ` Gerd Hoffmann
2010-08-19 19:00 ` Anthony Liguori
2010-08-19 12:40 ` [Qemu-devel] [PATCH 9/9] spice: add tablet support Gerd Hoffmann
2010-08-19 14:40 ` Anthony Liguori
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=4C6D3E92.8060604@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=kraxel@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).