[vlc-commits] Android vout: support the mouse events from jni

Jean-Baptiste Kempf git at videolan.org
Thu May 22 18:54:03 CEST 2014


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue May 13 02:02:42 2014 +0200| [3b671854cfc34dadef9db39da38372bd9047decf] | committer: Jean-Baptiste Kempf

Android vout: support the mouse events from jni

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3b671854cfc34dadef9db39da38372bd9047decf
---

 modules/video_output/android/opaque.c  |    2 +-
 modules/video_output/android/surface.c |    2 +-
 modules/video_output/android/utils.c   |   23 +++++++++++++++++++++++
 modules/video_output/android/utils.h   |    8 ++++++++
 4 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/modules/video_output/android/opaque.c b/modules/video_output/android/opaque.c
index 4812e64..a289004 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 bc51913..139511d 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 027ba6d..21a62b7 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 cd36bc3..9a72df6 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 <android/native_window.h>
 #include <jni.h>
 #include <android/native_window_jni.h>
+#include <android/input.h>
+
+#include <vlc_vout_display.h>
 
 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 *);



More information about the vlc-commits mailing list