qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 3/4] adb.c: NO_KEY


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v2 3/4] adb.c: NO_KEY
Date: Thu, 5 May 2016 16:23:23 +0100

On 24 March 2016 at 14:06, Programmingkid <address@hidden> wrote:
> Sets keys that are not supported by ADB to an unusable value of 0xff.
>
> Signed-off-by: John Arbuckle <address@hidden>
> ---
>  hw/input/adb.c | 32 +++++++++++++++++++-------------
>  1 file changed, 19 insertions(+), 13 deletions(-)
>
> diff --git a/hw/input/adb.c b/hw/input/adb.c
> index 3bfa686..8413db9 100644
> --- a/hw/input/adb.c
> +++ b/hw/input/adb.c
> @@ -62,6 +62,9 @@ do { printf("ADB: " fmt , ## __VA_ARGS__); } while (0)
>  /* error codes */
>  #define ADB_RET_NOTPRESENT (-2)
>
> +/* The adb keyboard doesn't have every key imaginable */
> +#define NO_KEY 0xff
> +
>  static void adb_device_reset(ADBDevice *d)
>  {
>      qdev_reset_all(DEVICE(d));
> @@ -192,6 +195,9 @@ typedef struct ADBKeyboardClass {
>
>  int qcode_to_adb_keycode[] = {
>
> +     /* Make sure future additions are automatically set to NO_KEY */
> +    [0 ... 0xff]               = NO_KEY,
> +
>      [Q_KEY_CODE_SHIFT]         = ADB_KEY_LEFT_SHIFT,
>      [Q_KEY_CODE_SHIFT_R]       = ADB_KEY_RIGHT_SHIFT,
>      [Q_KEY_CODE_ALT]           = ADB_KEY_LEFT_OPTION,
> @@ -309,19 +315,19 @@ int qcode_to_adb_keycode[] = {
>      [Q_KEY_CODE_PGUP]          = ADB_KEY_PAGE_UP,
>      [Q_KEY_CODE_PGDN]          = ADB_KEY_PAGE_DOWN,
>
> -    [Q_KEY_CODE_LESS]          = 0,
> -    [Q_KEY_CODE_STOP]          = 0,
> -    [Q_KEY_CODE_AGAIN]         = 0,
> -    [Q_KEY_CODE_PROPS]         = 0,
> -    [Q_KEY_CODE_UNDO]          = 0,
> -    [Q_KEY_CODE_FRONT]         = 0,
> -    [Q_KEY_CODE_COPY]          = 0,
> -    [Q_KEY_CODE_OPEN]          = 0,
> -    [Q_KEY_CODE_PASTE]         = 0,
> -    [Q_KEY_CODE_FIND]          = 0,
> -    [Q_KEY_CODE_CUT]           = 0,
> -    [Q_KEY_CODE_LF]            = 0,
> -    [Q_KEY_CODE_COMPOSE]       = 0,
> +    [Q_KEY_CODE_LESS]          = NO_KEY,
> +    [Q_KEY_CODE_STOP]          = NO_KEY,
> +    [Q_KEY_CODE_AGAIN]         = NO_KEY,
> +    [Q_KEY_CODE_PROPS]         = NO_KEY,
> +    [Q_KEY_CODE_UNDO]          = NO_KEY,
> +    [Q_KEY_CODE_FRONT]         = NO_KEY,
> +    [Q_KEY_CODE_COPY]          = NO_KEY,
> +    [Q_KEY_CODE_OPEN]          = NO_KEY,
> +    [Q_KEY_CODE_PASTE]         = NO_KEY,
> +    [Q_KEY_CODE_FIND]          = NO_KEY,
> +    [Q_KEY_CODE_CUT]           = NO_KEY,
> +    [Q_KEY_CODE_LF]            = NO_KEY,
> +    [Q_KEY_CODE_COMPOSE]       = NO_KEY,

Since NO_KEY is the default value, there's no need to explicitly
list these keys as generating it.

You need to add a check to adb_keyboard_event() to make it
return early if the array entry is NO_KEY, because otherwise
we'll end up sending the 0xff to the guest.

thanks
-- PMM



reply via email to

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