From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH v2 05/10] input: switch ps/2 kbd to new input api
Date: Wed, 7 May 2014 13:06:44 +0200 [thread overview]
Message-ID: <1399460809-15975-6-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1399460809-15975-1-git-send-email-kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/input/ps2.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 9a016eb..9347a85 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -24,6 +24,7 @@
#include "hw/hw.h"
#include "hw/input/ps2.h"
#include "ui/console.h"
+#include "ui/input.h"
#include "sysemu/sysemu.h"
/* debug PC keyboard */
@@ -172,6 +173,21 @@ static void ps2_put_keycode(void *opaque, int keycode)
ps2_queue(&s->common, keycode);
}
+static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src,
+ InputEvent *evt)
+{
+ PS2KbdState *s = (PS2KbdState *)dev;
+ int scancodes[3], i, count;
+
+ qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
+ count = qemu_input_key_value_to_scancode(evt->key->key,
+ evt->key->down,
+ scancodes);
+ for (i = 0; i < count; i++) {
+ ps2_put_keycode(s, scancodes[i]);
+ }
+}
+
uint32_t ps2_read_data(void *opaque)
{
PS2State *s = (PS2State *)opaque;
@@ -712,6 +728,12 @@ static const VMStateDescription vmstate_ps2_mouse = {
}
};
+static QemuInputHandler ps2_keyboard_handler = {
+ .name = "QEMU PS/2 Keyboard",
+ .mask = INPUT_EVENT_MASK_KEY,
+ .event = ps2_keyboard_event,
+};
+
void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg)
{
PS2KbdState *s = (PS2KbdState *)g_malloc0(sizeof(PS2KbdState));
@@ -720,7 +742,8 @@ void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg)
s->common.update_arg = update_arg;
s->scancode_set = 2;
vmstate_register(NULL, 0, &vmstate_ps2_keyboard, s);
- qemu_add_kbd_event_handler(ps2_put_keycode, s);
+ qemu_input_handler_register((DeviceState *)s,
+ &ps2_keyboard_handler);
qemu_register_reset(ps2_kbd_reset, s);
return s;
}
--
1.8.3.1
next prev parent reply other threads:[~2014-05-07 11:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-07 11:06 [Qemu-devel] [PATCH v2 00/10] input layer rework continued Gerd Hoffmann
2014-05-07 11:06 ` [Qemu-devel] [PATCH v2 01/10] ps2: set ps/2 output buffer size as the same as kernel Gerd Hoffmann
2014-05-07 11:06 ` [Qemu-devel] [PATCH v2 02/10] input: key mapping helpers Gerd Hoffmann
2014-05-07 11:06 ` [Qemu-devel] [PATCH v2 03/10] input: add qemu_input_handler_deactivate Gerd Hoffmann
2014-05-07 11:06 ` [Qemu-devel] [PATCH v2 04/10] input: use KeyValue directly in sendkey monitor command Gerd Hoffmann
2014-05-07 11:06 ` Gerd Hoffmann [this message]
2014-05-07 11:06 ` [Qemu-devel] [PATCH v2 06/10] input: switch ps/2 mouse to new input api Gerd Hoffmann
2014-05-07 11:06 ` [Qemu-devel] [PATCH v2 07/10] input: switch sparc32 kbd " Gerd Hoffmann
2014-05-07 11:06 ` [Qemu-devel] [PATCH v2 08/10] input: remove sparc keymap hack Gerd Hoffmann
2014-05-07 11:06 ` [Qemu-devel] [PATCH v2 09/10] input: sparc32 kbd: fix some key mappings Gerd Hoffmann
2014-05-07 11:06 ` [Qemu-devel] [PATCH v2 10/10] input: sparc32 kbd: claim en-us layout Gerd Hoffmann
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=1399460809-15975-6-git-send-email-kraxel@redhat.com \
--to=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).