[vlc-devel] [PATCH 2/5] input: extends navigation control
Thomas Guillem
thomas at gllm.fr
Mon Sep 4 12:33:02 CEST 2017
Add ControlNav() function. It moves the viewpoint if the input is not a menu.
---
src/input/input.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 64 insertions(+), 2 deletions(-)
diff --git a/src/input/input.c b/src/input/input.c
index 49653db76f..f02557370f 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1763,6 +1763,69 @@ static void ViewpointApply( input_thread_t *p_input )
}
}
+static void ControlNav( input_thread_t *p_input, int i_type )
+{
+ input_thread_private_t *priv = input_priv(p_input);
+
+ /* Handle navigation if input has title */
+ if( priv->master->i_title > 0 )
+ {
+ demux_Control( input_priv(p_input)->master->p_demux, i_type
+ - INPUT_CONTROL_NAV_ACTIVATE + DEMUX_NAV_ACTIVATE );
+ return;
+ }
+
+ vlc_viewpoint_t vp = {};
+ switch( i_type )
+ {
+ case INPUT_CONTROL_NAV_UP:
+ vp.pitch = -1.f;
+ break;
+ case INPUT_CONTROL_NAV_DOWN:
+ vp.pitch = 1.f;
+ break;
+ case INPUT_CONTROL_NAV_LEFT:
+ vp.yaw = -1.f;
+ break;
+ case INPUT_CONTROL_NAV_RIGHT:
+ vp.yaw = 1.f;
+ break;
+ case INPUT_CONTROL_NAV_ACTIVATE:
+ case INPUT_CONTROL_NAV_POPUP:
+ case INPUT_CONTROL_NAV_MENU:
+ return;
+ default:
+ vlc_assert_unreachable();
+ }
+
+ /* Handle Up/Down/Left/Right if the input can't navigate */
+
+ /* Try to change the viewpoint if possible */
+ vout_thread_t **pp_vout;
+ size_t i_vout;
+ bool b_viewpoint_ch = false;
+ input_resource_HoldVouts( priv->p_resource, &pp_vout, &i_vout );
+ for( size_t i = 0; i < i_vout; ++i )
+ {
+ if( !b_viewpoint_ch
+ && var_GetBool( pp_vout[i], "viewpoint-changeable" ) )
+ b_viewpoint_ch = true;
+ vlc_object_release( pp_vout[i] );
+ }
+ free( pp_vout );
+
+ if( b_viewpoint_ch )
+ {
+ priv->viewpoint_changed = true;
+ priv->viewpoint.yaw += vp.yaw;
+ priv->viewpoint.pitch += vp.pitch;
+ priv->viewpoint.roll += vp.roll;
+ priv->viewpoint.fov += vp.fov;
+ ViewpointApply( p_input );
+ return;
+ }
+}
+
static bool Control( input_thread_t *p_input,
int i_type, vlc_value_t val )
{
@@ -2190,8 +2253,7 @@ static bool Control( input_thread_t *p_input,
case INPUT_CONTROL_NAV_RIGHT:
case INPUT_CONTROL_NAV_POPUP:
case INPUT_CONTROL_NAV_MENU:
- demux_Control( input_priv(p_input)->master->p_demux, i_type
- - INPUT_CONTROL_NAV_ACTIVATE + DEMUX_NAV_ACTIVATE );
+ ControlNav( p_input, i_type );
break;
default:
--
2.11.0
More information about the vlc-devel
mailing list