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
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 @@
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 @@
/***********************************************************************/
/***********************************************************************/
-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 @@
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 @@
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 @@
}
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 @@
/* 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 @@
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_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_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 @@
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;