Commit de1de841 authored by Thomas Guillem's avatar Thomas Guillem

input: extends navigation control

Add ControlNav() function. It moves the viewpoint if the input can't navigate.
parent 8d25eb7f
......@@ -1769,6 +1769,64 @@ 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);
if( !demux_Control( priv->master->p_demux, i_type
- INPUT_CONTROL_NAV_ACTIVATE + DEMUX_NAV_ACTIVATE ) )
return; /* The demux handled the navigation control */
/* Handle Up/Down/Left/Right if the demux can't navigate */
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();
}
/* 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 )
{
......@@ -2196,8 +2254,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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment