aboutsummaryrefslogtreecommitdiffstats
path: root/user-events-qemu.c
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2010-05-25 18:16:10 -0700
committerDavid 'Digit' Turner <digit@android.com>2010-05-25 18:45:33 -0700
commit34f2974ce7ec7c71beb47b5daf9089d5c8c40c79 (patch)
tree0a8291f99ace9a1c770ddd701c08dc581609825d /user-events-qemu.c
parent3bca7734dc4b3a9e1e24964183d9765780dee4ea (diff)
downloadexternal_qemu-34f2974ce7ec7c71beb47b5daf9089d5c8c40c79.zip
external_qemu-34f2974ce7ec7c71beb47b5daf9089d5c8c40c79.tar.gz
external_qemu-34f2974ce7ec7c71beb47b5daf9089d5c8c40c79.tar.bz2
Add small user-event abstraction interface.
Preparation for future UI frontend/backend separation. This is done to ensure that the code under android/skin/ does not depend on any QEMU-specific header. We achieve this by adding a new abstract header "user-events.h" and one QEMU-specific implementations for the functions defined here. This also modifies console.h and vl-android.c to make them closer to upstream (by removing Android-specific changes). + fix Makefile.android to always build SDL from sources in standalone mode. Change-Id: I0d152741e7bb2c9cd283f5c35bd054385c7c1eb3
Diffstat (limited to 'user-events-qemu.c')
-rw-r--r--user-events-qemu.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/user-events-qemu.c b/user-events-qemu.c
new file mode 100644
index 0000000..45a994a
--- /dev/null
+++ b/user-events-qemu.c
@@ -0,0 +1,64 @@
+/* Copyright (C) 2010 The Android Open Source Project
+**
+** This software is licensed under the terms of the GNU General Public
+** License version 2, as published by the Free Software Foundation, and
+** may be copied, distributed, and modified under those terms.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+*/
+#include "user-events.h"
+#include "android/utils/debug.h"
+#include "console.h"
+#include <stdio.h>
+
+void
+user_event_keycodes(int *kcodes, int count)
+{
+ int nn;
+ for (nn = 0; nn < count; nn++)
+ user_event_keycode(kcodes[nn]);
+}
+
+void
+user_event_keycode(int kcode)
+{
+ kbd_put_keycode(kcode);
+}
+
+void
+user_event_key(unsigned code, unsigned down)
+{
+ if(code == 0) {
+ return;
+ }
+ if (VERBOSE_CHECK(keys))
+ printf(">> KEY [0x%03x,%s]\n", (code & 0x1ff), down ? "down" : " up " );
+
+ user_event_keycode((code & 0x1ff) | (down ? 0x200 : 0));
+}
+
+
+void
+user_event_mouse(int dx, int dy, int dz, unsigned buttons_state)
+{
+ kbd_mouse_event(dx, dy, dz, buttons_state);
+}
+
+static QEMUPutGenericEvent *generic_event_callback;
+static void* generic_event_opaque;
+
+void user_event_register_generic(void* opaque, QEMUPutGenericEvent *callback)
+{
+ generic_event_callback = callback;
+ generic_event_opaque = opaque;
+}
+
+void
+user_event_generic(int type, int code, int value)
+{
+ if (generic_event_callback)
+ generic_event_callback(generic_event_opaque, type, code, value);
+}