Shahar Havivi <shah...@redhat.com> writes:

> Currently you get segfault when trying to remove keyboard (device_del
> monitor command) because no keyboard handling is done.
>
> This patch add QEMUPutKbdEntry structure, handling each keyboard entry.
> Adding a keyboard add to the list, removing keyboard select the previous
> keyboard in list.
>
> Signed-off-by: Shahar Havivi <shah...@redhat.com>
> ---
[...]
> diff --git a/input.c b/input.c
> index 8f0941e..e6dda25 100644
> --- a/input.c
> +++ b/input.c
[...]
> @@ -60,6 +54,38 @@ static void check_mode_change(void)
>      current_has_absolute = has_absolute;
>  }
>  
> +QEMUPutKbdEntry *qemu_add_kbd_event_handler(QEMUPutKBDEvent *func,
> +                                            void *opaque,
> +                                            const char *name)
> +{
> +    static int mouse_index = 0;

"mouse_index" is an unorthodox name for counting keyboards ;)

> +    QEMUPutKbdEntry *s, *cursor;
> +
> +    QTAILQ_FOREACH(cursor, &kbd_handlers, node) {
> +        if (cursor->qemu_put_kbd_event == func &&
> +            cursor->qemu_put_kbd_event_opaque == opaque) {
> +            return cursor;
> +        }
> +    }
> +
> +    s = qemu_mallocz(sizeof(QEMUPutKbdEntry));
> +
> +    s->qemu_put_kbd_event_opaque = opaque;
> +    s->qemu_put_kbd_event = func;
> +    s->qemu_put_kbd_name = qemu_strdup(name);
> +    s->index = mouse_index++;
> +
> +    QTAILQ_INSERT_TAIL(&kbd_handlers, s, node);
> +
> +    return s;
> +}
[...]


Reply via email to