Patchwork ui/input.c: replace magic numbers by macros

login
register
mail settings
Submitter Amos Kong
Date April 22, 2013, 8:25 a.m.
Message ID <1366619129-23189-1-git-send-email-akong@redhat.com>
Download mbox | patch
Permalink /patch/238361/
State New
Headers show

Comments

Amos Kong - April 22, 2013, 8:25 a.m.
Signed-off-by: Amos Kong <akong@redhat.com>
---
It's based on http://lists.nongnu.org/archive/html/qemu-devel/2013-04/msg03822.html
---
 ui/input.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

Patch

diff --git a/ui/input.c b/ui/input.c
index 143c421..fac5d6d 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -28,6 +28,7 @@ 
 #include "qapi/error.h"
 #include "qmp-commands.h"
 #include "qapi-types.h"
+#include "ui/keymaps.h"
 
 static QEMUPutKBDEvent *qemu_put_kbd_event;
 static void *qemu_put_kbd_event_opaque;
@@ -239,10 +240,10 @@  static void enter_keys(void *opaque)
 
     /* key down events */
     for (i = 0; i < keycodes_size; i++) {
-        if (keycodes[i] & 0x80) {
-            kbd_put_keycode(0xe0);
+        if (keycodes[i] & SCANCODE_GREY) {
+            kbd_put_keycode(SCANCODE_EMUL0);
         }
-        kbd_put_keycode(keycodes[i] & 0x7f);
+        kbd_put_keycode(keycodes[i] & SCANCODE_KEYCODEMASK);
     }
 
     rest_time -= 100;
@@ -255,10 +256,10 @@  static void enter_keys(void *opaque)
 
     /* key up events */
     while (keycodes_size > 0) {
-        if (keycodes[--keycodes_size] & 0x80) {
-            kbd_put_keycode(0xe0);
+        if (keycodes[--keycodes_size] & SCANCODE_GREY) {
+            kbd_put_keycode(SCANCODE_EMUL0);
         }
-        kbd_put_keycode(keycodes[keycodes_size] | 0x80);
+        kbd_put_keycode(keycodes[keycodes_size] | SCANCODE_UP);
     }
 
     free_keycodes();