From 9cd71818132327c5aaa682235ba6ca23d3796572 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Oct 2012 20:22:00 +0200 Subject: [PATCH] (Android) AMotionEvent_getAxisValue function pointer - even USB joystick support in NDK code requires hacks even in ICS 4.0 and up - Google worst faildevs of the century --- android/native/jni/input_android.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/android/native/jni/input_android.c b/android/native/jni/input_android.c index 913b25e757..1cf27e26d6 100644 --- a/android/native/jni/input_android.c +++ b/android/native/jni/input_android.c @@ -14,11 +14,13 @@ * If not, see . */ +#include #include "android-general.h" #include "../../../general.h" #include "../../../driver.h" /* Process the next input event */ +static float (*AMotionEvent_getAxisValue)(const AInputEvent* motion_event, int32_t axis, size_t pointer_index) = 0; static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) { @@ -34,7 +36,22 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) static void *android_input_init(void) { + void *libandroid = 0; + g_android.app->onInputEvent = engine_handle_input; + + /* check if libandroid can be opened */ + if((libandroid = dlopen("/system/lib/libandroid.so", RTLD_LOCAL | RTLD_LAZY)) == 0) + { + RARCH_ERR("Unable to open library /system/lib/libandroid.so.\n"); + return 0; + } + + if((AMotionEvent_getAxisValue = (float (*)(const AInputEvent*, int32_t, size_t))dlsym(libandroid, "AMotionEvent_getAxisValue")) == 0) + { + RARCH_ERR("AMotionEvent_getAxisValue not available on your particular Android version.\n Joystick support will be disabled.\n"); + return 0; + } return (void*)-1; }