From: Jean-Baptiste Kempf Date: Tue, 13 May 2014 00:02:42 +0000 (+0200) Subject: Android vout: support the mouse events from jni X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=3b671854cfc34dadef9db39da38372bd9047decf;hp=d4485d3f17123e2e747a6d0c68c7eb9643ea4a2a;p=vlc Android vout: support the mouse events from jni Signed-off-by: Jean-Baptiste Kempf --- diff --git a/modules/video_output/android/opaque.c b/modules/video_output/android/opaque.c index 4812e64a2e..a289004985 100644 --- a/modules/video_output/android/opaque.c +++ b/modules/video_output/android/opaque.c @@ -235,7 +235,7 @@ static int Open(vlc_object_t *p_this) vd->display = Display; vd->control = Control; vd->prepare = NULL; - vd->manage = NULL; + vd->manage = Manage; /* Fix initial state */ vout_display_SendEventFullscreen(vd, false); diff --git a/modules/video_output/android/surface.c b/modules/video_output/android/surface.c index bc519132f7..139511ddf3 100644 --- a/modules/video_output/android/surface.c +++ b/modules/video_output/android/surface.c @@ -274,7 +274,7 @@ static int Open(vlc_object_t *p_this) vd->display = Display; vd->control = Control; vd->prepare = NULL; - vd->manage = NULL; + vd->manage = Manage; /* Fix initial state */ vout_display_SendEventFullscreen(vd, false); diff --git a/modules/video_output/android/utils.c b/modules/video_output/android/utils.c index 027ba6d45c..21a62b7da7 100644 --- a/modules/video_output/android/utils.c +++ b/modules/video_output/android/utils.c @@ -48,3 +48,26 @@ void *LoadNativeWindowAPI(native_window_api_t *native) dlclose(p_library); return NULL; } + +extern void jni_getMouseCoordinates(int *, int *, int *, int *); + +void Manage(vout_display_t *vd) +{ + int x, y, button, action; + jni_getMouseCoordinates(&action, &button, &x, &y); + if (x >= 0 && y >= 0) + { + switch( action ) + { + case AMOTION_EVENT_ACTION_DOWN: + vout_display_SendEventMouseMoved(vd, x, y); + vout_display_SendEventMousePressed(vd, button); break; + case AMOTION_EVENT_ACTION_UP: + vout_display_SendEventMouseMoved(vd, x, y); + vout_display_SendEventMouseReleased(vd, button); break; + case AMOTION_EVENT_ACTION_MOVE: + vout_display_SendEventMouseMoved(vd, x, y); break; + } + } +} + diff --git a/modules/video_output/android/utils.h b/modules/video_output/android/utils.h index cd36bc343b..9a72df67bc 100644 --- a/modules/video_output/android/utils.h +++ b/modules/video_output/android/utils.h @@ -20,9 +20,16 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include #include +#include + +#include typedef ANativeWindow* (*ptr_ANativeWindow_fromSurface)(JNIEnv*, jobject); typedef void (*ptr_ANativeWindow_release)(ANativeWindow*); @@ -40,3 +47,4 @@ typedef struct /* Fill the structure passed as parameter and return a library handle that should be destroyed with dlclose. */ void *LoadNativeWindowAPI(native_window_api_t *native); +void Manage(vout_display_t *);