提交 03a23a85 编写于 作者: G Gerd Hoffmann 提交者: Anthony Liguori

kbd leds: infrastructure

Adds infrastructure for keyboard led status tracking to qemu.
Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 32bb404a
...@@ -10,10 +10,16 @@ ...@@ -10,10 +10,16 @@
#define MOUSE_EVENT_RBUTTON 0x02 #define MOUSE_EVENT_RBUTTON 0x02
#define MOUSE_EVENT_MBUTTON 0x04 #define MOUSE_EVENT_MBUTTON 0x04
/* identical to the ps/2 keyboard bits */
#define QEMU_SCROLL_LOCK_LED (1 << 0)
#define QEMU_NUM_LOCK_LED (1 << 1)
#define QEMU_CAPS_LOCK_LED (1 << 2)
/* in ms */ /* in ms */
#define GUI_REFRESH_INTERVAL 30 #define GUI_REFRESH_INTERVAL 30
typedef void QEMUPutKBDEvent(void *opaque, int keycode); typedef void QEMUPutKBDEvent(void *opaque, int keycode);
typedef void QEMUPutLEDEvent(void *opaque, int ledstate);
typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state); typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
typedef struct QEMUPutMouseEntry { typedef struct QEMUPutMouseEntry {
...@@ -26,13 +32,22 @@ typedef struct QEMUPutMouseEntry { ...@@ -26,13 +32,22 @@ typedef struct QEMUPutMouseEntry {
struct QEMUPutMouseEntry *next; struct QEMUPutMouseEntry *next;
} QEMUPutMouseEntry; } QEMUPutMouseEntry;
typedef struct QEMUPutLEDEntry {
QEMUPutLEDEvent *put_led;
void *opaque;
QTAILQ_ENTRY(QEMUPutLEDEntry) next;
} QEMUPutLEDEntry;
void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque); void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
void *opaque, int absolute, void *opaque, int absolute,
const char *name); const char *name);
void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry); void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry);
QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func, void *opaque);
void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry);
void kbd_put_keycode(int keycode); void kbd_put_keycode(int keycode);
void kbd_put_ledstate(int ledstate);
void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
int kbd_mouse_is_absolute(void); int kbd_mouse_is_absolute(void);
......
...@@ -33,6 +33,7 @@ static QEMUPutKBDEvent *qemu_put_kbd_event; ...@@ -33,6 +33,7 @@ static QEMUPutKBDEvent *qemu_put_kbd_event;
static void *qemu_put_kbd_event_opaque; static void *qemu_put_kbd_event_opaque;
static QEMUPutMouseEntry *qemu_put_mouse_event_head; static QEMUPutMouseEntry *qemu_put_mouse_event_head;
static QEMUPutMouseEntry *qemu_put_mouse_event_current; static QEMUPutMouseEntry *qemu_put_mouse_event_current;
static QTAILQ_HEAD(, QEMUPutLEDEntry) led_handlers = QTAILQ_HEAD_INITIALIZER(led_handlers);
void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque) void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
{ {
...@@ -102,6 +103,27 @@ void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry) ...@@ -102,6 +103,27 @@ void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry)
qemu_free(entry); qemu_free(entry);
} }
QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func,
void *opaque)
{
QEMUPutLEDEntry *s;
s = qemu_mallocz(sizeof(QEMUPutLEDEntry));
s->put_led = func;
s->opaque = opaque;
QTAILQ_INSERT_TAIL(&led_handlers, s, next);
return s;
}
void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry)
{
if (entry == NULL)
return;
QTAILQ_REMOVE(&led_handlers, entry, next);
qemu_free(entry);
}
void kbd_put_keycode(int keycode) void kbd_put_keycode(int keycode)
{ {
if (qemu_put_kbd_event) { if (qemu_put_kbd_event) {
...@@ -109,6 +131,15 @@ void kbd_put_keycode(int keycode) ...@@ -109,6 +131,15 @@ void kbd_put_keycode(int keycode)
} }
} }
void kbd_put_ledstate(int ledstate)
{
QEMUPutLEDEntry *cursor;
QTAILQ_FOREACH(cursor, &led_handlers, next) {
cursor->put_led(cursor->opaque, ledstate);
}
}
void kbd_mouse_event(int dx, int dy, int dz, int buttons_state) void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
{ {
QEMUPutMouseEvent *mouse_event; QEMUPutMouseEvent *mouse_event;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册