aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.android5
-rw-r--r--android/console.c3
-rw-r--r--android/main.c15
-rw-r--r--android/skin/keyboard.c3
-rw-r--r--android/skin/window.c12
-rw-r--r--console.h4
-rw-r--r--hw/goldfish_events_device.c3
-rw-r--r--user-events-qemu.c64
-rw-r--r--user-events.h33
-rw-r--r--vl-android.c42
10 files changed, 117 insertions, 67 deletions
diff --git a/Makefile.android b/Makefile.android
index dd1cd38..429632c 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -327,6 +327,10 @@ endif
ifeq ($(QEMU_HOST_TAG),darwin-x86)
BUILD_SDL_FROM_SOURCES := false
endif
+ifeq ($(BUILD_STANDALONE_EMULATOR),true)
+ BUILD_SDL_FROM_SOURCES := true
+endif
+
ifneq ($(SDL_CONFIG),)
BUILD_SDL_FROM_SOURCES := false
endif
@@ -627,6 +631,7 @@ VL_SOURCES := vl-android.c osdep.c cutils.c \
qjson.c \
qlist.c \
qstring.c \
+ user-events-qemu.c \
android/boot-properties.c \
android/charmap.c \
android/cmdline-option.c \
diff --git a/android/console.c b/android/console.c
index 8eb1497..c6b8a4e 100644
--- a/android/console.c
+++ b/android/console.c
@@ -47,6 +47,7 @@
#include <fcntl.h>
#include "android/hw-events.h"
#include "android/skin/keyboard.h"
+#include "user-events.h"
#if defined(CONFIG_SLIRP)
#include "libslirp.h"
@@ -1701,7 +1702,7 @@ do_event_send( ControlClient client, char* args )
return -1;
}
- kbd_generic_event( type, code, value );
+ user_event_generic( type, code, value );
p = q;
}
return 0;
diff --git a/android/main.c b/android/main.c
index c4e94c3..6f5fca4 100644
--- a/android/main.c
+++ b/android/main.c
@@ -24,6 +24,7 @@
#include "qemu-common.h"
#include "sysemu.h"
#include "console.h"
+#include "user-events.h"
#include <SDL.h>
#include <SDL_syswm.h>
@@ -275,16 +276,6 @@ uint64_t convertMBToBytes( unsigned megaBytes )
/***********************************************************************/
/***********************************************************************/
-void send_key_event(unsigned code, unsigned down)
-{
- if(code == 0) {
- return;
- }
- if (VERBOSE_CHECK(keys))
- printf(">> KEY [0x%03x,%s]\n", (code & 0x1ff), down ? "down" : " up " );
- kbd_put_keycode((code & 0x1ff) | (down ? 0x200 : 0));
-}
-
/* called by the emulated framebuffer device each time the content of the
* framebuffer has changed. the rectangle is the bounding box of all changes
*/
@@ -373,7 +364,7 @@ static void sdl_refresh(DisplayState *ds)
kcode = // qemulator_rotate_keycode(kKeyCodeDpadUp);
android_keycode_rotate(kKeyCodeDpadUp,
skin_layout_get_dpad_rotation(qemulator_get_layout(qemulator_get())));
- send_key_event( kcode, down );
+ user_event_key( kcode, down );
}
else if (ev.button.button == 5)
{
@@ -383,7 +374,7 @@ static void sdl_refresh(DisplayState *ds)
kcode = // qemulator_rotate_keycode(kKeyCodeDpadDown);
android_keycode_rotate(kKeyCodeDpadDown,
skin_layout_get_dpad_rotation(qemulator_get_layout(qemulator_get())));
- send_key_event( kcode, down );
+ user_event_key( kcode, down );
}
else if (ev.button.button == SDL_BUTTON_LEFT) {
skin_window_process_event( window, &ev );
diff --git a/android/skin/keyboard.c b/android/skin/keyboard.c
index e3537f1..00fa1df 100644
--- a/android/skin/keyboard.c
+++ b/android/skin/keyboard.c
@@ -14,6 +14,7 @@
#include "android/utils/bufprint.h"
#include "android/utils/system.h"
#include "android/android.h"
+#include "user-events.h"
#define DEBUG 1
@@ -125,7 +126,7 @@ skin_keyboard_flush( SkinKeyboard* kb )
}
printf( "\n" );
}
- kbd_put_keycodes(kb->keycodes, kb->keycode_count);
+ user_event_keycodes(kb->keycodes, kb->keycode_count);
kb->keycode_count = 0;
}
}
diff --git a/android/skin/window.c b/android/skin/window.c
index 24baaa6..4765bba 100644
--- a/android/skin/window.c
+++ b/android/skin/window.c
@@ -17,7 +17,7 @@
#include "android/utils/system.h"
#include "android/hw-sensors.h"
#include <SDL_syswm.h>
-#include "qemu-common.h"
+#include "user-events.h"
#include <math.h>
#include "framebuffer.h"
@@ -855,7 +855,7 @@ add_finger_event(unsigned x, unsigned y, unsigned state)
/* NOTE: the 0 is used in hw/goldfish_events.c to differentiate
* between a touch-screen and a trackball event
*/
- kbd_mouse_event(x, y, 0, state);
+ user_event_mouse(x, y, 0, state);
}
static void
@@ -984,7 +984,7 @@ skin_window_move_mouse( SkinWindow* window,
static void
skin_window_trackball_press( SkinWindow* window, int down )
{
- send_key_event( BTN_MOUSE, down );
+ user_event_key( BTN_MOUSE, down );
}
static void
@@ -1221,7 +1221,7 @@ skin_window_reset_internal ( SkinWindow* window, SkinLayout* slayout )
skin_window_redraw( window, NULL );
if (slayout->event_type != 0) {
- kbd_generic_event( slayout->event_type, slayout->event_code, slayout->event_value );
+ user_event_generic( slayout->event_type, slayout->event_code, slayout->event_value );
/* XXX: hack, replace by better code here */
if (slayout->event_value != 0)
android_sensors_set_coarse_orientation( ANDROID_COARSE_PORTRAIT );
@@ -1457,7 +1457,7 @@ skin_window_process_event( SkinWindow* window, SDL_Event* ev )
skin_window_redraw( window, &button->rect );
window->button.pressed = button;
if(button->keycode) {
- send_key_event(button->keycode, 1);
+ user_event_key(button->keycode, 1);
}
}
}
@@ -1477,7 +1477,7 @@ skin_window_process_event( SkinWindow* window, SDL_Event* ev )
button->down = 0;
skin_window_redraw( window, &button->rect );
if(button->keycode) {
- send_key_event(button->keycode, 0);
+ user_event_key(button->keycode, 0);
}
window->button.pressed = NULL;
window->button.hover = NULL;
diff --git a/console.h b/console.h
index c4baf10..3d0c4f4 100644
--- a/console.h
+++ b/console.h
@@ -17,9 +17,7 @@
#endif
typedef void QEMUPutKBDEvent(void *opaque, int keycode);
-typedef void QEMUPutKBDEventN(void *opaque, int* keycodes, int count);
typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
-typedef void QEMUPutGenericEvent(void* opaque, int type, int code, int value);
typedef struct QEMUPutMouseEntry {
QEMUPutMouseEvent *qemu_put_mouse_event;
@@ -38,8 +36,6 @@ QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry);
void kbd_put_keycode(int keycode);
-void kbd_put_keycodes(int* keycodes, int count);
-void kbd_generic_event(int type, int code, int value);
void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
int kbd_mouse_is_absolute(void);
diff --git a/hw/goldfish_events_device.c b/hw/goldfish_events_device.c
index d8e265c..9050aa6 100644
--- a/hw/goldfish_events_device.c
+++ b/hw/goldfish_events_device.c
@@ -14,6 +14,7 @@
#include "android/charmap.h"
#include "android/globals.h" /* for android_hw */
#include "irq.h"
+#include "user-events.h"
#define MAX_EVENTS 256*4
@@ -385,7 +386,7 @@ void events_dev_init(uint32_t base, qemu_irq irq)
qemu_add_kbd_event_handler(events_put_keycode, s);
qemu_add_mouse_event_handler(events_put_mouse, s, 1, "goldfish-events");
- qemu_add_generic_event_handler(events_put_generic, s);
+ user_event_register_generic(s, events_put_generic);
s->base = base;
s->irq = irq;
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);
+}
diff --git a/user-events.h b/user-events.h
new file mode 100644
index 0000000..608134a
--- /dev/null
+++ b/user-events.h
@@ -0,0 +1,33 @@
+/* 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.
+*/
+#ifndef _QEMU_USEREVENTS_H
+#define _QEMU_USEREVENTS_H
+
+/* A simple abstract interface to user-events. This is used to de-couple
+ * QEMU-specific and UI-specific code.
+ *
+ * QEMU-specific implementation in user-events-qemu.c
+ */
+
+void user_event_key(unsigned key, unsigned down);
+void user_event_keycode(int kcode);
+void user_event_keycodes(int *kcodes, int count);
+void user_event_mouse(int dx, int dy, int dz, unsigned buttons_state);
+void user_event_generic(int type, int code, int value);
+
+/* The following is used to register a callback function that will receive
+ * user_event_generic() calls. This is used by hw/goldfish_events_device.c
+ */
+typedef void QEMUPutGenericEvent(void* opaque, int type, int code, int value);
+void user_event_register_generic(void* opaque, QEMUPutGenericEvent callback);
+
+#endif /* _QEMU_USEREVENTS_H */
diff --git a/vl-android.c b/vl-android.c
index 7be2eae..e598f38 100644
--- a/vl-android.c
+++ b/vl-android.c
@@ -479,13 +479,6 @@ ram_addr_t qemu_balloon_status(void)
static QEMUPutKBDEvent* qemu_put_kbd_event;
static void* qemu_put_kbd_event_opaque;
-static QEMUPutKBDEventN* qemu_put_kbd_event_n;
-static void* qemu_put_kbd_event_n_opaque;
-
-
-static QEMUPutGenericEvent* qemu_put_generic_event;
-static void* qemu_put_generic_event_opaque;
-
static QEMUPutMouseEntry *qemu_put_mouse_event_head;
static QEMUPutMouseEntry *qemu_put_mouse_event_current;
@@ -495,12 +488,6 @@ void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
qemu_put_kbd_event = func;
}
-void qemu_add_kbd_event_n_handler(QEMUPutKBDEventN *func, void *opaque)
-{
- qemu_put_kbd_event_n_opaque = opaque;
- qemu_put_kbd_event_n = func;
-}
-
#if 0
void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque, int absolute)
{
@@ -574,12 +561,6 @@ void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry)
}
#endif
-void qemu_add_generic_event_handler(QEMUPutGenericEvent *func, void* opaque)
-{
- qemu_put_generic_event = func;
- qemu_put_generic_event_opaque = opaque;
-}
-
void kbd_put_keycode(int keycode)
{
if (qemu_put_kbd_event) {
@@ -587,29 +568,6 @@ void kbd_put_keycode(int keycode)
}
}
-void kbd_put_keycodes(int* keycodes, int count)
-{
- if (qemu_put_kbd_event_n)
- {
- qemu_put_kbd_event_n(qemu_put_kbd_event_n_opaque, keycodes, count);
- }
- else if (qemu_put_kbd_event)
- {
- int nn;
-
- for (nn = 0; nn < count; nn++)
- qemu_put_kbd_event(qemu_put_kbd_event_opaque, keycodes[nn]);
- }
-}
-
-
-void kbd_generic_event(int type, int code, int value)
-{
- if (qemu_put_generic_event)
- qemu_put_generic_event(qemu_put_generic_event_opaque, type, code, value);
-}
-
-
void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
{
QEMUPutMouseEvent *mouse_event;