[Android] DVD: pass different actions event to differentiate up/down/move

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


vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Thu May 22 18:49:12 2014 +0200| [b17066a9fb007c65e33a7ebf1c4acd447a04b0e7] | committer: Jean-Baptiste Kempf

DVD: pass different actions event to differentiate up/down/move

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=b17066a9fb007c65e33a7ebf1c4acd447a04b0e7
---

 vlc-android/jni/vout.c                             |    9 ++++++---
 vlc-android/src/org/videolan/libvlc/LibVLC.java    |    2 +-
 .../vlc/gui/video/VideoPlayerActivity.java         |   20 ++++++++++++++------
 3 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/vlc-android/jni/vout.c b/vlc-android/jni/vout.c
index 2d7d3ce..f2f4346 100644
--- a/vlc-android/jni/vout.c
+++ b/vlc-android/jni/vout.c
@@ -169,19 +169,22 @@ void Java_org_videolan_libvlc_LibVLC_detachSubtitlesSurface(JNIEnv *env, jobject
 static int mouse_x = -1;
 static int mouse_y = -1;
 static int mouse_button = -1;
+static int mouse_action = -1;
 
-void Java_org_videolan_libvlc_LibVLC_sendMouseEvent(JNIEnv* env, jobject thiz, jint button, jint x, jint y)
+void Java_org_videolan_libvlc_LibVLC_sendMouseEvent(JNIEnv* env, jobject thiz, jint action, jint button, jint x, jint y)
 {
     mouse_x = x;
     mouse_y = y;
     mouse_button = button;
+    mouse_action = action;
 }
 
-void jni_getMouseCoordinates(int *button, int *x, int *y)
+void jni_getMouseCoordinates(int *action, int *button, int *x, int *y)
 {
     *x = mouse_x;
     *y = mouse_y;
     *button = mouse_button;
+    *action = mouse_action;
 
-    mouse_button = mouse_x = mouse_y = -1;
+    mouse_button = mouse_action = mouse_x = mouse_y = -1;
 }
diff --git a/vlc-android/src/org/videolan/libvlc/LibVLC.java b/vlc-android/src/org/videolan/libvlc/LibVLC.java
index 5f3d79a..157829e 100644
--- a/vlc-android/src/org/videolan/libvlc/LibVLC.java
+++ b/vlc-android/src/org/videolan/libvlc/LibVLC.java
@@ -639,7 +639,7 @@ public class LibVLC {
 
     public static native String nativeToURI(String path);
     
-    public native static void sendMouseEvent( int button, int x, int y);
+    public native static void sendMouseEvent( int action, int button, int x, int y);
 
     /**
      * Quickly converts path to URIs, which are mandatory in libVLC.
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 4e864b0..1abdbe3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1139,6 +1139,12 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
         float coef = Math.abs (y_changed / x_changed);
         float xgesturesize = ((x_changed / screen.xdpi) * 2.54f);
 
+        /* Offset for Mouse Events */
+        int[] offset = new int[2];
+        mSurface.getLocationOnScreen(offset);
+        int xTouch = Math.round((event.getRawX() - offset[0]) * mVideoWidth / mSurface.getWidth());
+        int yTouch = Math.round((event.getRawY() - offset[1]) * mVideoHeight / mSurface.getHeight());
+
         switch (event.getAction()) {
 
         case MotionEvent.ACTION_DOWN:
@@ -1148,15 +1154,14 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
             mTouchAction = TOUCH_NONE;
             // Seek
             mTouchX = event.getRawX();
-            // Click DVD menus
-            int[] offset = new int[2];
-            mSurface.getLocationOnScreen(offset);
-            LibVLC.sendMouseEvent(0,
-                    Math.round((mTouchX - offset[0]) * mVideoWidth / mSurface.getWidth()),
-                    Math.round((mTouchY - offset[1]) * mVideoHeight / mSurface.getHeight()));
+            // Mouse events for the core
+            LibVLC.sendMouseEvent(MotionEvent.ACTION_DOWN, 0, xTouch, yTouch);
             break;
 
         case MotionEvent.ACTION_MOVE:
+            // Mouse events for the core
+            LibVLC.sendMouseEvent(MotionEvent.ACTION_MOVE, 0, xTouch, yTouch);
+
             // No volume/brightness action if coef < 2 or a secondary display is connected
             //TODO : Volume action when a secondary display is connected
             if (coef > 2 && mPresentation == null) {
@@ -1180,6 +1185,9 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
             break;
 
         case MotionEvent.ACTION_UP:
+            // Mouse events for the core
+            LibVLC.sendMouseEvent(MotionEvent.ACTION_UP, 0, xTouch, yTouch);
+
             // Audio or Brightness
             if ( mTouchAction == TOUCH_NONE) {
                 if (!mShowing) {



More information about the Android mailing list