[vlc-devel] [PATCH 02/10] hotkeys: new hotkeys to change the viewpoint in 360° videos

Steve Lhomme robux4 at videolabs.io
Tue Sep 20 10:11:09 CEST 2016


yaw: Left/Right (same a DVD/BR nav)
pitch: Up/Down (same a DVD/BR nav)
roll:Page Up/Page Down

--
replaces https://patches.videolan.org/patch/14481/
* use vlc_viewpoint instead of old strings
---
 include/vlc_keys.h        |  3 +++
 modules/control/hotkeys.c | 56 +++++++++++++++++++++++++++++++++++++++++++++--
 src/config/keys.c         |  2 ++
 src/libvlc-module.c       | 34 ++++++++++++++++++++++++----
 4 files changed, 89 insertions(+), 6 deletions(-)

diff --git a/include/vlc_keys.h b/include/vlc_keys.h
index ea54950..add5a7e 100644
--- a/include/vlc_keys.h
+++ b/include/vlc_keys.h
@@ -227,6 +227,9 @@ typedef enum vlc_action {
     ACTIONID_PROGRAM_SID_NEXT,
     ACTIONID_PROGRAM_SID_PREV,
     ACTIONID_INTF_POPUP_MENU,
+    /* Viewpoint */
+    ACTIONID_ROLL_CLOCK,
+    ACTIONID_ROLL_ANTICLOCK,
 
 } vlc_action_t;
 
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 11bb9bd..a70cc89 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -767,13 +767,48 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
                 var_SetInteger( p_input, "title  0", 2 );
             break;
         case ACTIONID_NAV_ACTIVATE:
+            if( p_input )
+                input_Control( p_input, INPUT_NAV_ACTIVATE, NULL );
+            break;
         case ACTIONID_NAV_UP:
+            if( p_vout ) {
+                vlc_viewpoint_t viewpoint;
+                vout_GetViewpoint( p_vout, &viewpoint );
+                viewpoint.f_pitch -= M_PI / 32;
+                vout_SetViewpoint( p_vout, &viewpoint );
+            }
+            if( p_input )
+                input_Control( p_input, INPUT_NAV_UP, NULL );
+            break;
         case ACTIONID_NAV_DOWN:
+            if( p_vout ) {
+                vlc_viewpoint_t viewpoint;
+                vout_GetViewpoint( p_vout, &viewpoint );
+                viewpoint.f_pitch += M_PI / 32;
+                vout_SetViewpoint( p_vout, &viewpoint );
+            }
+            if( p_input )
+                input_Control( p_input, INPUT_NAV_DOWN, NULL );
+            break;
         case ACTIONID_NAV_LEFT:
+            if( p_vout ) {
+                vlc_viewpoint_t viewpoint;
+                vout_GetViewpoint( p_vout, &viewpoint );
+                viewpoint.f_yaw -= M_PI / 32;
+                vout_SetViewpoint( p_vout, &viewpoint );
+            }
+            if( p_input )
+                input_Control( p_input, INPUT_NAV_LEFT, NULL );
+            break;
         case ACTIONID_NAV_RIGHT:
+            if( p_vout ) {
+                vlc_viewpoint_t viewpoint;
+                vout_GetViewpoint( p_vout, &viewpoint );
+                viewpoint.f_yaw += M_PI / 32;
+                vout_SetViewpoint( p_vout, &viewpoint );
+            }
             if( p_input )
-                input_Control( p_input, i_action - ACTIONID_NAV_ACTIVATE
-                               + INPUT_NAV_ACTIVATE, NULL );
+                input_Control( p_input, INPUT_NAV_RIGHT, NULL );
             break;
 
         /* Video Output actions */
@@ -892,6 +927,23 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
                 var_DecInteger( p_vout, "crop-right" );
             break;
 
+        case ACTIONID_ROLL_CLOCK:
+            if( p_vout ) {
+                vlc_viewpoint_t viewpoint;
+                vout_GetViewpoint( p_vout, &viewpoint );
+                viewpoint.f_roll += M_PI / 32;
+                vout_SetViewpoint( p_vout, &viewpoint );
+            }
+            break;
+        case ACTIONID_ROLL_ANTICLOCK:
+            if( p_vout ) {
+                vlc_viewpoint_t viewpoint;
+                vout_GetViewpoint( p_vout, &viewpoint );
+                viewpoint.f_roll += M_PI / 32;
+                vout_SetViewpoint( p_vout, &viewpoint );
+            }
+            break;
+
          case ACTIONID_TOGGLE_AUTOSCALE:
             if( p_vout )
             {
diff --git a/src/config/keys.c b/src/config/keys.c
index 8b8aef6..30d2069 100644
--- a/src/config/keys.c
+++ b/src/config/keys.c
@@ -368,6 +368,8 @@ static const struct action actions[] =
     { "uncrop-right", ACTIONID_UNCROP_RIGHT, },
     { "uncrop-top", ACTIONID_UNCROP_TOP, },
     { "unzoom", ACTIONID_UNZOOM, },
+    { "viewpoint-roll-anticlock", ACTIONID_ROLL_ANTICLOCK, },
+    { "viewpoint-roll-clock", ACTIONID_ROLL_CLOCK, },
     { "vol-down", ACTIONID_VOL_DOWN, },
     { "vol-mute", ACTIONID_VOL_MUTE, },
     { "vol-up", ACTIONID_VOL_UP, },
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index ea13769..7f720cd 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -433,6 +433,11 @@ static const char *const ppsz_pos_descriptions[] =
     "aspect, or a float value (1.25, 1.3333, etc.) expressing pixel " \
     "squareness.")
 
+#define VIEWPOINT_TEXT N_("Viewpoint")
+#define VIEWPOINT_LONGTEXT N_( \
+    "This forces the viewpoint for the displayed video. " \
+    "Accepted formats are yaw:pitch:roll expressing the user viewpoint.")
+
 #define AUTOSCALE_TEXT N_("Video Auto Scaling")
 #define AUTOSCALE_LONGTEXT N_( \
     "Let the video scale to fit a given window or fullscreen.")
@@ -1257,13 +1262,13 @@ static const char *const mouse_wheel_texts[] = {
 #define QUIT_KEY_TEXT N_("Quit")
 #define QUIT_KEY_LONGTEXT N_("Select the hotkey to quit the application.")
 #define NAV_UP_KEY_TEXT N_("Navigate up")
-#define NAV_UP_KEY_LONGTEXT N_("Select the key to move the selector up in DVD menus.")
+#define NAV_UP_KEY_LONGTEXT N_("Select the key to move the selector up in DVD menus / Move viewpoint to up (pitch).")
 #define NAV_DOWN_KEY_TEXT N_("Navigate down")
-#define NAV_DOWN_KEY_LONGTEXT N_("Select the key to move the selector down in DVD menus.")
+#define NAV_DOWN_KEY_LONGTEXT N_("Select the key to move the selector down in DVD menus / Move viewpoint to down (pitch).")
 #define NAV_LEFT_KEY_TEXT N_("Navigate left")
-#define NAV_LEFT_KEY_LONGTEXT N_("Select the key to move the selector left in DVD menus.")
+#define NAV_LEFT_KEY_LONGTEXT N_("Select the key to move the selector left in DVD menus / Move viewpoint to left (yaw).")
 #define NAV_RIGHT_KEY_TEXT N_("Navigate right")
-#define NAV_RIGHT_KEY_LONGTEXT N_("Select the key to move the selector right in DVD menus.")
+#define NAV_RIGHT_KEY_LONGTEXT N_("Select the key to move the selector right in DVD menus / Move viewpoint to left (yaw).")
 #define NAV_ACTIVATE_KEY_TEXT N_("Activate")
 #define NAV_ACTIVATE_KEY_LONGTEXT N_("Select the key to activate selected item in DVD menus.")
 #define DISC_MENU_TEXT N_("Go to the DVD menu")
@@ -1417,6 +1422,12 @@ static const char *const mouse_wheel_texts[] = {
 #define UNCROP_RIGHT_KEY_TEXT N_("Uncrop one pixel from the right of the video")
 #define UNCROP_RIGHT_KEY_LONGTEXT N_("Uncrop one pixel from the right of the video")
 
+/* 360° Viewpoint */
+#define VIEWPOINT_ROLL_KEY_TEXT N_("Roll the viewpoint clockwise")
+#define VIEWPOINT_ROLL_KEY_LONGTEXT N_("Roll the viewpoint clockwise (roll)")
+#define VIEWPOINT_UNROLL_KEY_TEXT N_("Roll the viewpoint anti-clockwise")
+#define VIEWPOINT_UNROLL_KEY_LONGTEXT N_("Roll the viewpoint anti-clockwise (roll)")
+
 #define WALLPAPER_KEY_TEXT N_("Toggle wallpaper mode in video output")
 #define WALLPAPER_KEY_LONGTEXT N_( \
     "Toggle wallpaper mode in video output." )
@@ -1584,6 +1595,9 @@ vlc_module_begin ()
     add_string( "aspect-ratio", NULL,
                 ASPECT_RATIO_TEXT, ASPECT_RATIO_LONGTEXT, false )
         change_safe ()
+    add_string( "viewpoint", NULL,
+                VIEWPOINT_TEXT, VIEWPOINT_LONGTEXT, false )
+        change_safe ()
     add_bool( "autoscale", true, AUTOSCALE_TEXT, AUTOSCALE_LONGTEXT, false )
         change_safe ()
     add_obsolete_float( "scale" ) /* since 3.0.0 */
@@ -2217,6 +2231,9 @@ vlc_module_begin ()
 #   define KEY_CROP_RIGHT         "Alt+l"
 #   define KEY_UNCROP_RIGHT       "Alt+Shift+l"
 
+#   define KEY_VIEWPOINT_ROLL     "Page Up"
+#   define KEY_VIEWPOINT_UNROLL   "Page Down"
+
 /* the macosx-interface already has bindings */
 #   define KEY_ZOOM_QUARTER       NULL
 #   define KEY_ZOOM_HALF          "Command+0"
@@ -2360,6 +2377,10 @@ vlc_module_begin ()
 #   define KEY_CROP_RIGHT         "Alt+f"
 #   define KEY_UNCROP_RIGHT       "Alt+Shift+f"
 
+/* 360° Viewpoint */
+#   define KEY_VIEWPOINT_ROLL     "Page Up"
+#   define KEY_VIEWPOINT_UNROLL   "Page Down"
+
 /* Zooming */
 #   define KEY_ZOOM_QUARTER       "Alt+1"
 #   define KEY_ZOOM_HALF          "Alt+2"
@@ -2553,6 +2574,11 @@ vlc_module_begin ()
     add_key( "key-loop", KEY_LOOP,
              LOOP_KEY_TEXT, LOOP_KEY_LONGTEXT, false )
 
+    add_key( "key-viewpoint-roll-clock", KEY_VIEWPOINT_ROLL,
+             VIEWPOINT_ROLL_KEY_TEXT, VIEWPOINT_ROLL_KEY_LONGTEXT, true )
+    add_key( "key-viewpoint-roll-anticlock", KEY_VIEWPOINT_UNROLL,
+             VIEWPOINT_UNROLL_KEY_TEXT, VIEWPOINT_UNROLL_KEY_LONGTEXT, true )
+
     set_section ( N_("Zoom" ), NULL )
     add_key( "key-zoom-quarter",  KEY_ZOOM_QUARTER,
         ZOOM_QUARTER_KEY_TEXT,  NULL, false )
-- 
2.8.2



More information about the vlc-devel mailing list