[vlc-commits] vout: add vout_display_SendEventViewpointMoved

Steve Lhomme git at videolan.org
Tue Jul 25 16:43:02 CEST 2017


vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Mon Feb 27 14:16:18 2017 +0100| [25ec3acb840486b55f97d45890815b816eaa553e] | committer: Thomas Guillem

vout: add vout_display_SendEventViewpointMoved

"vout display" modules can call this function to update the view point.

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 include/vlc_vout_display.h   | 8 ++++++++
 src/video_output/display.c   | 6 ++++++
 src/video_output/event.h     | 8 ++++++++
 src/video_output/vout_intf.c | 3 +++
 4 files changed, 25 insertions(+)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 4e243e48d6..38dbded17d 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -215,6 +215,9 @@ enum {
     VOUT_DISPLAY_EVENT_MOUSE_PRESSED,
     VOUT_DISPLAY_EVENT_MOUSE_RELEASED,
     VOUT_DISPLAY_EVENT_MOUSE_DOUBLE_CLICK,
+
+    /* VR navigation */
+    VOUT_DISPLAY_EVENT_VIEWPOINT_MOVED,
 };
 
 /**
@@ -395,6 +398,11 @@ static inline void vout_display_SendEventMouseDoubleClick(vout_display_t *vd)
 {
     vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_MOUSE_DOUBLE_CLICK);
 }
+static inline void vout_display_SendEventViewpointMoved(vout_display_t *vd,
+                                                        const vlc_viewpoint_t *vp)
+{
+    vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_VIEWPOINT_MOVED, vp);
+}
 
 /**
  * Asks for a new window of a given type.
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 07a1f6e3ea..960f08e66e 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -369,6 +369,7 @@ typedef struct {
 
     bool ch_viewpoint;
     vlc_viewpoint_t viewpoint;
+    vlc_viewpoint_t display_viewpoint;
 
     /* */
     video_format_t source;
@@ -654,6 +655,11 @@ static void VoutDisplayEvent(vout_display_t *vd, int event, va_list args)
         VoutDisplayEventMouse(vd, event, args);
         break;
 
+    case VOUT_DISPLAY_EVENT_VIEWPOINT_MOVED:
+        vout_SendEventViewpointMoved(osys->vout,
+                                     va_arg(args, const vlc_viewpoint_t *));
+        break;
+
     case VOUT_DISPLAY_EVENT_FULLSCREEN: {
         const int is_fullscreen = (int)va_arg(args, int);
         const bool window_fullscreen = va_arg(args, int);
diff --git a/src/video_output/event.h b/src/video_output/event.h
index a5e47da295..ece1042c36 100644
--- a/src/video_output/event.h
+++ b/src/video_output/event.h
@@ -52,6 +52,14 @@ static inline void vout_SendEventMouseMoved(vout_thread_t *vout, int x, int y)
 {
     var_SetCoords(vout, "mouse-moved", x, y);
 }
+static inline void vout_SendEventViewpointMoved(vout_thread_t *vout,
+                                                const vlc_viewpoint_t *p_viewpoint)
+{
+    var_SetAddress(vout, "viewpoint-moved", (void *) p_viewpoint);
+    /* This variable can only be read from callbacks */
+    var_Change(vout, "viewpoint-moved", VLC_VAR_SETVALUE,
+               &(vlc_value_t) { .p_address = NULL }, NULL);
+}
 static inline void vout_SendEventMousePressed(vout_thread_t *vout, int button)
 {
     int key = KEY_UNSET;
diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index 97abf1e2f7..14d0c03c5c 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -300,6 +300,9 @@ void vout_IntfInit( vout_thread_t *p_vout )
     var_Create( p_vout, "mouse-moved", VLC_VAR_COORDS );
     var_Create( p_vout, "mouse-clicked", VLC_VAR_COORDS );
 
+    /* Device orientation */
+    var_Create( p_vout, "viewpoint-moved", VLC_VAR_ADDRESS );
+
     /* Viewpoint */
     var_Create( p_vout, "viewpoint", VLC_VAR_ADDRESS  );
     var_AddCallback( p_vout, "viewpoint", ViewpointCallback, NULL );



More information about the vlc-commits mailing list