All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 3/4] adb.c: NO_KEY
@ 2016-03-24 14:06 Programmingkid
  2016-05-05 15:23 ` Peter Maydell
  0 siblings, 1 reply; 2+ messages in thread
From: Programmingkid @ 2016-03-24 14:06 UTC (permalink / raw)
  To: Peter Maydell, Gerd Hoffmann, qemu-devel qemu-devel

Sets keys that are not supported by ADB to an unusable value of 0xff.

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
---
 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,
 };
 
 static void adb_kbd_put_keycode(void *opaque, int keycode)
-- 
2.7.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH v2 3/4] adb.c: NO_KEY
  2016-03-24 14:06 [Qemu-devel] [PATCH v2 3/4] adb.c: NO_KEY Programmingkid
@ 2016-05-05 15:23 ` Peter Maydell
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2016-05-05 15:23 UTC (permalink / raw)
  To: Programmingkid; +Cc: Gerd Hoffmann, qemu-devel qemu-devel

On 24 March 2016 at 14:06, Programmingkid <programmingkidx@gmail.com> wrote:
> Sets keys that are not supported by ADB to an unusable value of 0xff.
>
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-05-05 15:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-24 14:06 [Qemu-devel] [PATCH v2 3/4] adb.c: NO_KEY Programmingkid
2016-05-05 15:23 ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.