qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH v2 1/7] kbd-state: add keyboard state tracke


From: Daniel P . Berrangé
Subject: Re: [Qemu-devel] [RFC PATCH v2 1/7] kbd-state: add keyboard state tracker
Date: Fri, 21 Dec 2018 10:56:31 +0000
User-agent: Mutt/1.10.1 (2018-07-13)

On Wed, Dec 19, 2018 at 01:08:58PM +0100, Gerd Hoffmann wrote:
> Now that most user interfaces are using QKeyCodes it is easier to have
> common keyboard code useable by all user interfaces.
> 
> This patch adds helper code to track the state of all keyboard keys,
> using a bitmap indexed by QKeyCode.  Modifier state is tracked too,
> as separate bitmap.  That makes checking modifier state easier.
> Likewise we can easily apply special handling for capslock & numlock
> (toggles on keypress) and ctrl + shift (we have two keys for that).
> 
> Signed-off-by: Gerd Hoffmann <address@hidden>
> ---
>  include/ui/kbd-state.h |  32 +++++++++++++
>  ui/kbd-state.c         | 125 
> +++++++++++++++++++++++++++++++++++++++++++++++++
>  ui/Makefile.objs       |   2 +-
>  3 files changed, 158 insertions(+), 1 deletion(-)
>  create mode 100644 include/ui/kbd-state.h
>  create mode 100644 ui/kbd-state.c
> 
> diff --git a/include/ui/kbd-state.h b/include/ui/kbd-state.h
> new file mode 100644
> index 0000000000..0bef75a5d5
> --- /dev/null
> +++ b/include/ui/kbd-state.h
> @@ -0,0 +1,32 @@
> +#ifndef QEMU_UI_KBD_STATE_H
> +#define QEMU_UI_KBD_STATE_H 1
> +
> +#include "qapi/qapi-types-ui.h"
> +
> +typedef enum KbdModifier KbdModifier;
> +
> +enum KbdModifier {
> +    KBD_MOD_NONE = 0,
> +
> +    KBD_MOD_SHIFT,
> +    KBD_MOD_CTRL,
> +    KBD_MOD_ALT,
> +    KBD_MOD_ALTGR,
> +
> +    KBD_MOD_NUMLOCK,
> +    KBD_MOD_CAPSLOCK,
> +
> +    KBD_MOD__MAX
> +};
> +
> +typedef struct KbdState KbdState;
> +
> +bool kbd_state_modifier_get(KbdState *kbd, KbdModifier mod);
> +bool kbd_state_key_get(KbdState *kbd, QKeyCode qcode);
> +void kbd_state_key_event(KbdState *kbd, QKeyCode qcode, bool down);
> +void kbd_state_lift_all_keys(KbdState *kbd);
> +void kbd_state_set_delay(KbdState *kbd, int delay_ms);
> +void kbd_state_free(KbdState *kbd);
> +KbdState *kbd_state_init(QemuConsole *con);

I would suggest using a slightly more QEMU specific namespace "qkbd_"
methods, m"QKBD_" constants, & "QKbd" struct, as 'kbd' is very generic,
but upto you if you want to, or ignore it.

I would, however, like to see API docs written in the header file for
each of these methods.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



reply via email to

[Prev in Thread] Current Thread [Next in Thread]