From aefb3ee3af0df92a8aae12feef5bb6fc299baf9a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 28 Oct 2012 03:14:50 +0100 Subject: [PATCH] (GL) Fix build for HAVE_OPENGLES target (Android) Input - add device ID per joypad --- android/native/jni/input_android.c | 25 +++++++++++++------------ gfx/gl.c | 4 ++-- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/android/native/jni/input_android.c b/android/native/jni/input_android.c index 58fb231096..65982f6fae 100644 --- a/android/native/jni/input_android.c +++ b/android/native/jni/input_android.c @@ -27,23 +27,24 @@ static float AMotionEvent_getAxisValue(const AInputEvent* motion_event, int32_t static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) { float x,y; - int action, keycode, source, type; + int action, keycode, source, type, id; action = AKEY_EVENT_NO_ACTION; type = AInputEvent_getType(event); source = AInputEvent_getSource(event); + id = AInputEvent_getDeviceId(event); switch(type) { case AINPUT_EVENT_TYPE_KEY: action = AKeyEvent_getAction(event); keycode = AKeyEvent_getKeyCode(event); - RARCH_LOG("AINPUT_EVENT_TYPE_KEY.\n"); + RARCH_LOG("AINPUT_EVENT_TYPE_KEY, id: %d.\n", id); break; case AINPUT_EVENT_TYPE_MOTION: x = AMotionEvent_getX(event, 0); y = AMotionEvent_getY(event, 0); - RARCH_LOG("AINPUT_EVENT_TYPE_MOTION - x: %f, y: %f.\n", x, y); + RARCH_LOG("AINPUT_EVENT_TYPE_MOTION, id: %d, x: %f, y: %f.\n", id, x, y); break; } @@ -56,16 +57,16 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) switch(action) { case AKEY_EVENT_ACTION_DOWN: - RARCH_LOG("AKEY_EVENT_ACTION_DOWN, keycode: %d.\n", keycode); + RARCH_LOG("AKEY_EVENT_ACTION_DOWN, id: %d, keycode: %d.\n", id, keycode); break; case AKEY_EVENT_ACTION_UP: - RARCH_LOG("AKEY_EVENT_ACTION_UP, keycode: %d.\n", keycode); + RARCH_LOG("AKEY_EVENT_ACTION_UP, id: %d, keycode: %d.\n", id, keycode); break; case AKEY_EVENT_ACTION_MULTIPLE: - RARCH_LOG("AKEY_EVENT_ACTION_MULTIPLE, keycode: %d.\n", keycode); + RARCH_LOG("AKEY_EVENT_ACTION_MULTIPLE, id: %d, keycode: %d.\n", id, keycode); break; default: - RARCH_LOG("AKEY_EVENT_NO_ACTION.\n"); + RARCH_LOG("AKEY_EVENT_NO_ACTION, id: %d, keycode: %d.\n", id, keycode); break; } } @@ -73,19 +74,19 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) switch(source) { case AINPUT_SOURCE_DPAD: - RARCH_LOG("AINPUT_SOURCE_DPAD.\n"); + RARCH_LOG("AINPUT_SOURCE_DPAD, id: %d, keycode: %d.\n", id, keycode); break; case AINPUT_SOURCE_TOUCHSCREEN: - RARCH_LOG("AINPUT_SOURCE_TOUCHSCREEN.\n"); + RARCH_LOG("AINPUT_SOURCE_TOUCHSCREEN, id: %d, keycode: %d.\n", id, keycode); break; case AINPUT_SOURCE_TOUCHPAD: - RARCH_LOG("AINPUT_SOURCE_TOUCHPAD.\n"); + RARCH_LOG("AINPUT_SOURCE_TOUCHPAD, id: %d, keycode: %d.\n", id, keycode); break; case AINPUT_SOURCE_ANY: - RARCH_LOG("AINPUT_SOURCE_ANY.\n"); + RARCH_LOG("AINPUT_SOURCE_ANY, id: %d, keycode: %d.\n", id, keycode); break; default: - RARCH_LOG("AINPUT_SOURCE_DEFAULT.\n"); + RARCH_LOG("AINPUT_SOURCE_DEFAULT, id: %d, keycode: %d.\n", id, keycode); break; } diff --git a/gfx/gl.c b/gfx/gl.c index 6daaddcf44..85f0794e09 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -1512,8 +1512,8 @@ static bool gl_read_viewport(void *data, uint8_t *buffer) glPixelStorei(GL_PACK_ALIGNMENT, 1); #ifdef HAVE_OPENGLES - glReadPixels(vp[0], vp[1], - vp[2], vp[3], + glReadPixels(gl->vp.x, gl->vp.y, + gl->vp.width, gl->vp.height, GL_RGB, GL_UNSIGNED_BYTE, buffer); uint8_t *pixels = (uint8_t*)buffer;