From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PULL 05/10] input: switch hid keyboard to new input layer api.
Date: Mon, 26 May 2014 09:51:21 +0200 [thread overview]
Message-ID: <1401090686-1095-6-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1401090686-1095-1-git-send-email-kraxel@redhat.com>
Minimal patch to get the switchover done. We continue processing ps/2
scancodes for now as they are part of the live migration stream. Fixing
that, then mapping directly from QKeyValue to HID keycodes is left as
excercise for another day.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/input/hid.c | 29 ++++++++++++++++++++++-------
include/hw/input/hid.h | 3 ++-
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/hw/input/hid.c b/hw/input/hid.c
index bb0fa6a..ff75e41 100644
--- a/hw/input/hid.c
+++ b/hw/input/hid.c
@@ -158,17 +158,24 @@ static void hid_pointer_event(void *opaque,
hs->event(hs);
}
-static void hid_keyboard_event(void *opaque, int keycode)
+static void hid_keyboard_event(DeviceState *dev, QemuConsole *src,
+ InputEvent *evt)
{
- HIDState *hs = opaque;
+ HIDState *hs = (HIDState *)dev;
+ int scancodes[3], i, count;
int slot;
- if (hs->n == QUEUE_LENGTH) {
+ count = qemu_input_key_value_to_scancode(evt->key->key,
+ evt->key->down,
+ scancodes);
+ if (hs->n + count > QUEUE_LENGTH) {
fprintf(stderr, "usb-kbd: warning: key event queue full\n");
return;
}
- slot = (hs->head + hs->n) & QUEUE_MASK; hs->n++;
- hs->kbd.keycodes[slot] = keycode;
+ for (i = 0; i < count; i++) {
+ slot = (hs->head + hs->n) & QUEUE_MASK; hs->n++;
+ hs->kbd.keycodes[slot] = scancodes[i];
+ }
hs->event(hs);
}
@@ -415,7 +422,7 @@ void hid_free(HIDState *hs)
{
switch (hs->kind) {
case HID_KEYBOARD:
- qemu_remove_kbd_event_handler(hs->kbd.eh_entry);
+ qemu_input_handler_unregister(hs->s);
break;
case HID_MOUSE:
case HID_TABLET:
@@ -425,13 +432,21 @@ void hid_free(HIDState *hs)
hid_del_idle_timer(hs);
}
+static QemuInputHandler hid_keyboard_handler = {
+ .name = "QEMU HID Keyboard",
+ .mask = INPUT_EVENT_MASK_KEY,
+ .event = hid_keyboard_event,
+};
+
void hid_init(HIDState *hs, int kind, HIDEventFunc event)
{
hs->kind = kind;
hs->event = event;
if (hs->kind == HID_KEYBOARD) {
- hs->kbd.eh_entry = qemu_add_kbd_event_handler(hid_keyboard_event, hs);
+ hs->s = qemu_input_handler_register((DeviceState *)hs,
+ &hid_keyboard_handler);
+ qemu_input_handler_activate(hs->s);
} else if (hs->kind == HID_MOUSE) {
hs->ptr.eh_entry = qemu_add_mouse_event_handler(hid_pointer_event, hs,
0, "QEMU HID Mouse");
diff --git a/include/hw/input/hid.h b/include/hw/input/hid.h
index 2567879..fb913ba 100644
--- a/include/hw/input/hid.h
+++ b/include/hw/input/hid.h
@@ -2,6 +2,7 @@
#define QEMU_HID_H
#include "migration/vmstate.h"
+#include "ui/input.h"
#define HID_MOUSE 1
#define HID_TABLET 2
@@ -31,7 +32,6 @@ typedef struct HIDKeyboardState {
uint8_t leds;
uint8_t key[16];
int32_t keys;
- QEMUPutKbdEntry *eh_entry;
} HIDKeyboardState;
struct HIDState {
@@ -47,6 +47,7 @@ struct HIDState {
bool idle_pending;
QEMUTimer *idle_timer;
HIDEventFunc event;
+ QemuInputHandlerState *s;
};
void hid_init(HIDState *hs, int kind, HIDEventFunc event);
--
1.8.3.1
next prev parent reply other threads:[~2014-05-26 7:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-26 7:51 [Qemu-devel] [PULL 00/10] input: add event routing and multiseat support Gerd Hoffmann
2014-05-26 7:51 ` [Qemu-devel] [PULL 01/10] input (curses): mask keycodes to remove modifier bits Gerd Hoffmann
2014-05-26 7:51 ` [Qemu-devel] [PULL 02/10] input: add qemu_input_key_number_to_qcode Gerd Hoffmann
2014-05-26 7:51 ` [Qemu-devel] [PULL 03/10] input: add name to input_event_key_number Gerd Hoffmann
2014-05-26 7:51 ` [Qemu-devel] [PULL 04/10] input: keymap: add meta keys Gerd Hoffmann
2014-05-26 7:51 ` Gerd Hoffmann [this message]
2014-05-26 7:51 ` [Qemu-devel] [PULL 06/10] input: switch hid mouse and tablet to the new input layer api Gerd Hoffmann
2014-05-26 7:51 ` [Qemu-devel] [PULL 07/10] input: bind devices and input routing Gerd Hoffmann
2014-05-26 7:51 ` [Qemu-devel] [PULL 08/10] sdl: pass key event source to input layer Gerd Hoffmann
2014-05-26 7:51 ` [Qemu-devel] [PULL 09/10] usb: add input routing support for tablet and keyboard Gerd Hoffmann
2014-05-26 7:51 ` [Qemu-devel] [PULL 10/10] docs: add multiseat.txt 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=1401090686-1095-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).