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

Steve Lhomme robux4 at videolabs.io
Wed Sep 7 16:17:05 CEST 2016


Alt+Shift+<direction>
---
 include/vlc_keys.h        |  7 +++++++
 modules/control/hotkeys.c | 37 +++++++++++++++++++++++++++++++++++
 src/config/keys.c         |  6 ++++++
 src/libvlc-module.c       | 50 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 100 insertions(+)

diff --git a/include/vlc_keys.h b/include/vlc_keys.h
index ea54950..06e2b3b 100644
--- a/include/vlc_keys.h
+++ b/include/vlc_keys.h
@@ -227,6 +227,13 @@ typedef enum vlc_action {
     ACTIONID_PROGRAM_SID_NEXT,
     ACTIONID_PROGRAM_SID_PREV,
     ACTIONID_INTF_POPUP_MENU,
+    /* Viewpoint */
+    ACTIONID_YAW_EAST,
+    ACTIONID_YAW_WEST,
+    ACTIONID_PITCH_DOWN,
+    ACTIONID_PITCH_UP,
+    ACTIONID_ROLL_CLOCK,
+    ACTIONID_ROLL_ANTICLOCK,
 
 } vlc_action_t;
 
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 11bb9bd..0abde0d 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -892,6 +892,43 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
                 var_DecInteger( p_vout, "crop-right" );
             break;
 
+        case ACTIONID_YAW_EAST:
+            if( p_vout ) {
+                float yaw = var_GetFloat( p_vout, "viewpoint-yaw" ) + M_PI / 32;
+                var_SetFloat( p_vout, "viewpoint-yaw", yaw);
+            }
+            break;
+        case ACTIONID_YAW_WEST:
+            if( p_vout ) {
+                float yaw = var_GetFloat( p_vout, "viewpoint-yaw" ) - M_PI / 32;
+                var_SetFloat( p_vout, "viewpoint-yaw", yaw);
+            }
+            break;
+        case ACTIONID_PITCH_DOWN:
+            if( p_vout ) {
+                float pitch = var_GetFloat( p_vout, "viewpoint-pitch" ) + M_PI / 32;
+                var_SetFloat( p_vout, "viewpoint-pitch", pitch);
+            }
+            break;
+        case ACTIONID_PITCH_UP:
+            if( p_vout ) {
+                float pitch = var_GetFloat( p_vout, "viewpoint-pitch" ) - M_PI / 32;
+                var_SetFloat( p_vout, "viewpoint-pitch", pitch);
+            }
+            break;
+        case ACTIONID_ROLL_CLOCK:
+            if( p_vout ) {
+                float roll = var_GetFloat( p_vout, "viewpoint-roll" ) + M_PI / 32;
+                var_SetFloat( p_vout, "viewpoint-roll", roll);
+            }
+            break;
+        case ACTIONID_ROLL_ANTICLOCK:
+            if( p_vout ) {
+                float roll = var_GetFloat( p_vout, "viewpoint-roll" ) - M_PI / 32;
+                var_SetFloat( p_vout, "viewpoint-roll", roll);
+            }
+            break;
+
          case ACTIONID_TOGGLE_AUTOSCALE:
             if( p_vout )
             {
diff --git a/src/config/keys.c b/src/config/keys.c
index 8b8aef6..c32b858 100644
--- a/src/config/keys.c
+++ b/src/config/keys.c
@@ -368,6 +368,12 @@ static const struct action actions[] =
     { "uncrop-right", ACTIONID_UNCROP_RIGHT, },
     { "uncrop-top", ACTIONID_UNCROP_TOP, },
     { "unzoom", ACTIONID_UNZOOM, },
+    { "viewpoint-pitch-down", ACTIONID_PITCH_DOWN, },
+    { "viewpoint-pitch-up", ACTIONID_PITCH_UP, },
+    { "viewpoint-roll-anticlock", ACTIONID_ROLL_ANTICLOCK, },
+    { "viewpoint-roll-clock", ACTIONID_ROLL_CLOCK, },
+    { "viewpoint-yaw-east", ACTIONID_YAW_EAST, },
+    { "viewpoint-yaw-west", ACTIONID_YAW_WEST, },
     { "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..85adf5a 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.")
@@ -1417,6 +1422,20 @@ 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_WEST_KEY_TEXT N_("Move the viewpoint to the West")
+#define VIEWPOINT_WEST_KEY_LONGTEXT N_("Move the viewpoint to the West (yaw)")
+#define VIEWPOINT_EAST_KEY_TEXT N_("Move the viewpoint to the East")
+#define VIEWPOINT_EAST_KEY_LONGTEXT N_("Move the viewpoint to the East (yaw)")
+#define VIEWPOINT_UP_KEY_TEXT N_("Move the viewpoint to the top")
+#define VIEWPOINT_UP_KEY_LONGTEXT N_("Move the viewpoint to the top (pitch)")
+#define VIEWPOINT_DOWN_KEY_TEXT N_("Move the viewpoint to the bottom")
+#define VIEWPOINT_DOWN_KEY_LONGTEXT N_("Move the viewpoint to the bottom (pitch)")
+#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 +1603,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 +2239,13 @@ vlc_module_begin ()
 #   define KEY_CROP_RIGHT         "Alt+l"
 #   define KEY_UNCROP_RIGHT       "Alt+Shift+l"
 
+#   define KEY_VIEWPOINT_WEST     "Alt+Shift+Left"
+#   define KEY_VIEWPOINT_EAST     "Alt+Shift+Right"
+#   define KEY_VIEWPOINT_UP       "Alt+Shift+Up"
+#   define KEY_VIEWPOINT_DOWN     "Alt+Shift+Down"
+#   define KEY_VIEWPOINT_ROLL     "Alt+Shift+Page Up"
+#   define KEY_VIEWPOINT_UNROLL   "Alt+Shift+Page Down"
+
 /* the macosx-interface already has bindings */
 #   define KEY_ZOOM_QUARTER       NULL
 #   define KEY_ZOOM_HALF          "Command+0"
@@ -2360,6 +2389,14 @@ vlc_module_begin ()
 #   define KEY_CROP_RIGHT         "Alt+f"
 #   define KEY_UNCROP_RIGHT       "Alt+Shift+f"
 
+/* 360° Viewpoint */
+#   define KEY_VIEWPOINT_WEST     "Alt+Shift+Left"
+#   define KEY_VIEWPOINT_EAST     "Alt+Shift+Right"
+#   define KEY_VIEWPOINT_UP       "Alt+Shift+Up"
+#   define KEY_VIEWPOINT_DOWN     "Alt+Shift+Down"
+#   define KEY_VIEWPOINT_ROLL     "Alt+Shift+Page Up"
+#   define KEY_VIEWPOINT_UNROLL   "Alt+Shift+Page Down"
+
 /* Zooming */
 #   define KEY_ZOOM_QUARTER       "Alt+1"
 #   define KEY_ZOOM_HALF          "Alt+2"
@@ -2553,6 +2590,19 @@ vlc_module_begin ()
     add_key( "key-loop", KEY_LOOP,
              LOOP_KEY_TEXT, LOOP_KEY_LONGTEXT, false )
 
+    add_key( "key-viewpoint-yaw-west", KEY_VIEWPOINT_WEST,
+             VIEWPOINT_WEST_KEY_TEXT, VIEWPOINT_WEST_KEY_LONGTEXT, true )
+    add_key( "key-viewpoint-yaw-east", KEY_VIEWPOINT_EAST,
+             VIEWPOINT_EAST_KEY_TEXT, VIEWPOINT_EAST_KEY_LONGTEXT, true )
+    add_key( "key-viewpoint-pitch-down", KEY_VIEWPOINT_DOWN,
+             VIEWPOINT_DOWN_KEY_TEXT, VIEWPOINT_DOWN_KEY_LONGTEXT, true )
+    add_key( "key-viewpoint-pitch-up", KEY_VIEWPOINT_UP,
+             VIEWPOINT_UP_KEY_TEXT, VIEWPOINT_UP_KEY_LONGTEXT, true )
+    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