* src/video_output/video_output.c: add a key-pressed variable to p_vout

 * modules/access/dvdplay/intf.c: allow keyboard naviagation in dvd-menus,
by reading the key-pressed variable
 * modules/control/lirc/lirc.c: allow navigation with remote control by
faking keypresses (closes #38). I think the remotes for dvdplayers usually
have buttons for "root menu" and "title menu". Whould this be easily
implemented in vlc?
parent e2e6b292
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* intf.c: interface for DVD video manager * intf.c: interface for DVD video manager
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: intf.c,v 1.4 2002/11/08 10:26:52 gbazin Exp $ * $Id: intf.c,v 1.5 2003/01/12 15:38:35 sigmunau Exp $
* *
* Authors: Stphane Borel <stef@via.ecp.fr> * Authors: Stphane Borel <stef@via.ecp.fr>
* *
...@@ -50,7 +50,7 @@ struct intf_sys_t ...@@ -50,7 +50,7 @@ struct intf_sys_t
mtime_t m_still_time; mtime_t m_still_time;
dvdplay_ctrl_t control; dvdplay_ctrl_t control;
vlc_bool_t b_click, b_move; vlc_bool_t b_click, b_move, b_key_pressed;
}; };
/***************************************************************************** /*****************************************************************************
...@@ -59,6 +59,8 @@ struct intf_sys_t ...@@ -59,6 +59,8 @@ struct intf_sys_t
static int InitThread ( intf_thread_t *p_intf ); static int InitThread ( intf_thread_t *p_intf );
static int MouseEvent ( vlc_object_t *, char const *, static int MouseEvent ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static int KeyEvent ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
/* Exported functions */ /* Exported functions */
static void RunIntf ( intf_thread_t *p_intf ); static void RunIntf ( intf_thread_t *p_intf );
...@@ -209,6 +211,59 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -209,6 +211,59 @@ static void RunIntf( intf_thread_t *p_intf )
} }
} }
/*
* keyboard event
*/
if( p_vout && p_intf->p_sys->b_key_pressed )
{
vlc_value_t val;
int i_activate;
p_intf->p_sys->b_key_pressed = VLC_FALSE;
var_Get( p_vout, "key-pressed", &val );
if ( val.psz_string )
{
if( !strcmp( val.psz_string, "LEFT" ) )
{
p_intf->p_sys->control.type = DVDCtrlLeftButtonSelect;
}
else if( !strcmp( val.psz_string, "RIGHT" ) )
{
p_intf->p_sys->control.type = DVDCtrlRightButtonSelect;
}
else if( !strcmp( val.psz_string, "UP" ) )
{
p_intf->p_sys->control.type = DVDCtrlUpperButtonSelect;
}
else if( !strcmp( val.psz_string, "DOWN" ) )
{
p_intf->p_sys->control.type = DVDCtrlLowerButtonSelect;
}
else if( !strcmp( val.psz_string, "ENTER" ) )
{
p_intf->p_sys->control.type = DVDCtrlButtonActivate;
}
/* we can safely interact with libdvdplay
* with the stream lock */
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
i_activate = dvdplay_button( p_intf->p_sys->p_dvd->vmg,
&p_intf->p_sys->control );
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
if( i_activate && p_intf->p_sys->b_still )
{
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
p_intf->p_sys->b_still = 0;
p_intf->p_sys->b_inf_still = 0;
p_intf->p_sys->m_still_time = 0;
}
}
}
vlc_mutex_unlock( &p_intf->change_lock ); vlc_mutex_unlock( &p_intf->change_lock );
/* /*
...@@ -218,6 +273,7 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -218,6 +273,7 @@ static void RunIntf( intf_thread_t *p_intf )
{ {
var_DelCallback( p_vout, "mouse-moved", MouseEvent, p_intf ); var_DelCallback( p_vout, "mouse-moved", MouseEvent, p_intf );
var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf ); var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
var_DelCallback( p_vout, "key-pressed", KeyEvent, p_intf );
vlc_object_release( p_vout ); vlc_object_release( p_vout );
p_vout = NULL; p_vout = NULL;
} }
...@@ -230,6 +286,7 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -230,6 +286,7 @@ static void RunIntf( intf_thread_t *p_intf )
{ {
var_AddCallback( p_vout, "mouse-moved", MouseEvent, p_intf ); var_AddCallback( p_vout, "mouse-moved", MouseEvent, p_intf );
var_AddCallback( p_vout, "mouse-clicked", MouseEvent, p_intf ); var_AddCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
var_AddCallback( p_vout, "key-pressed", KeyEvent, p_intf );
} }
} }
...@@ -241,6 +298,7 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -241,6 +298,7 @@ static void RunIntf( intf_thread_t *p_intf )
{ {
var_DelCallback( p_vout, "mouse-moved", MouseEvent, p_intf ); var_DelCallback( p_vout, "mouse-moved", MouseEvent, p_intf );
var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf ); var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
var_DelCallback( p_vout, "key-pressed", KeyEvent, p_intf );
vlc_object_release( p_vout ); vlc_object_release( p_vout );
} }
...@@ -270,6 +328,7 @@ static int InitThread( intf_thread_t * p_intf ) ...@@ -270,6 +328,7 @@ static int InitThread( intf_thread_t * p_intf )
p_intf->p_sys->b_move = VLC_FALSE; p_intf->p_sys->b_move = VLC_FALSE;
p_intf->p_sys->b_click = VLC_FALSE; p_intf->p_sys->b_click = VLC_FALSE;
p_intf->p_sys->b_key_pressed = VLC_FALSE;
vlc_mutex_unlock( &p_intf->change_lock ); vlc_mutex_unlock( &p_intf->change_lock );
...@@ -305,6 +364,22 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var, ...@@ -305,6 +364,22 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/*****************************************************************************
* KeyEvent: callback for keyboard events
*****************************************************************************/
static int KeyEvent( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
intf_thread_t *p_intf = (intf_thread_t *)p_data;
vlc_mutex_lock( &p_intf->change_lock );
p_intf->p_sys->b_key_pressed = VLC_TRUE;
vlc_mutex_unlock( &p_intf->change_lock );
return VLC_SUCCESS;
}
/***************************************************************************** /*****************************************************************************
* dvdIntfStillTime: function provided to demux plugin to request * dvdIntfStillTime: function provided to demux plugin to request
* still images * still images
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* lirc.c : lirc plugin for vlc * lirc.c : lirc plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: lirc.c,v 1.2 2003/01/12 01:26:36 sigmunau Exp $ * $Id: lirc.c,v 1.3 2003/01/12 15:38:35 sigmunau Exp $
* *
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -147,6 +147,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -147,6 +147,7 @@ static void Run( intf_thread_t *p_intf )
vlc_object_release( p_intf->p_sys->p_input ); vlc_object_release( p_intf->p_sys->p_input );
p_intf->p_sys->p_input = NULL; p_intf->p_sys->p_input = NULL;
} }
p_input = p_intf->p_sys->p_input;
/* We poll the lircsocket */ /* We poll the lircsocket */
if( lirc_nextcode(&code) != 0 ) if( lirc_nextcode(&code) != 0 )
...@@ -181,6 +182,95 @@ static void Run( intf_thread_t *p_intf ) ...@@ -181,6 +182,95 @@ static void Run( intf_thread_t *p_intf )
} }
continue; continue;
} }
if( !strcmp( c, "ACTIVATE" ) )
{
vout_thread_t *p_vout;
p_vout = vlc_object_find( p_intf->p_sys->p_input,
VLC_OBJECT_VOUT, FIND_CHILD );
if( p_vout )
{
vlc_value_t val;
val.psz_string = "ENTER";
if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS)
{
msg_Warn( p_intf, "key-press failed" );
}
vlc_object_release( p_vout );
}
continue;
}
if( !strcmp( c, "LEFT" ) )
{
vout_thread_t *p_vout;
p_vout = vlc_object_find( p_intf->p_sys->p_input,
VLC_OBJECT_VOUT, FIND_CHILD );
if( p_vout )
{
vlc_value_t val;
val.psz_string = "LEFT";
if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS)
{
msg_Warn( p_intf, "key-press failed" );
}
vlc_object_release( p_vout );
}
continue;
}
if( !strcmp( c, "RIGHT" ) )
{
vout_thread_t *p_vout;
p_vout = vlc_object_find( p_intf->p_sys->p_input,
VLC_OBJECT_VOUT, FIND_CHILD );
if( p_vout )
{
vlc_value_t val;
val.psz_string = "RIGHT";
if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS)
{
msg_Warn( p_intf, "key-press failed" );
}
vlc_object_release( p_vout );
}
continue;
}
if( !strcmp( c, "UP" ) )
{
vout_thread_t *p_vout;
p_vout = vlc_object_find( p_intf->p_sys->p_input,
VLC_OBJECT_VOUT, FIND_CHILD );
if( p_vout )
{
vlc_value_t val;
val.psz_string = "UP";
if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS)
{
msg_Warn( p_intf, "key-press failed" );
}
vlc_object_release( p_vout );
}
continue;
}
if( !strcmp( c, "DOWN" ) )
{
vout_thread_t *p_vout;
p_vout = vlc_object_find( p_intf->p_sys->p_input,
VLC_OBJECT_VOUT, FIND_CHILD );
if( p_vout )
{
vlc_value_t val;
val.psz_string = "DOWN";
if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS)
{
msg_Warn( p_intf, "key-press failed" );
}
vlc_object_release( p_vout );
}
continue;
}
if( !strcmp( c, "PLAY" ) ) if( !strcmp( c, "PLAY" ) )
{ {
...@@ -199,10 +289,10 @@ static void Run( intf_thread_t *p_intf ) ...@@ -199,10 +289,10 @@ static void Run( intf_thread_t *p_intf )
} }
if( !strcmp( c, "PLAYPAUSE" ) ) if( !strcmp( c, "PLAYPAUSE" ) )
{ {
if( p_intf->p_sys->p_input && if( p_input &&
p_intf->p_sys->p_input->stream.control.i_status != PAUSE_S ) p_input->stream.control.i_status != PAUSE_S )
{ {
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE ); input_SetStatus( p_input, INPUT_STATUS_PAUSE );
} }
else else
{ {
...@@ -220,10 +310,8 @@ static void Run( intf_thread_t *p_intf ) ...@@ -220,10 +310,8 @@ static void Run( intf_thread_t *p_intf )
} }
} }
} }
else if( p_intf->p_sys->p_input ) else if( p_input )
{ {
p_input = p_intf->p_sys->p_input;
if( !strcmp( c, "PAUSE" ) ) if( !strcmp( c, "PAUSE" ) )
{ {
input_SetStatus( p_input, INPUT_STATUS_PAUSE ); input_SetStatus( p_input, INPUT_STATUS_PAUSE );
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* thread, and destroy a previously oppened video output thread. * thread, and destroy a previously oppened video output thread.
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: video_output.c,v 1.205 2002/12/18 14:17:11 sam Exp $ * $Id: video_output.c,v 1.206 2003/01/12 15:38:35 sigmunau Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* *
...@@ -281,6 +281,7 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, ...@@ -281,6 +281,7 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent,
var_Create( p_vout, "mouse-y", VLC_VAR_INTEGER ); var_Create( p_vout, "mouse-y", VLC_VAR_INTEGER );
var_Create( p_vout, "mouse-moved", VLC_VAR_BOOL ); var_Create( p_vout, "mouse-moved", VLC_VAR_BOOL );
var_Create( p_vout, "mouse-clicked", VLC_VAR_INTEGER ); var_Create( p_vout, "mouse-clicked", VLC_VAR_INTEGER );
var_Create( p_vout, "key-pressed", VLC_VAR_STRING );
/* user requested fullscreen? */ /* user requested fullscreen? */
if( config_GetInt( p_vout, "fullscreen" ) ) if( config_GetInt( p_vout, "fullscreen" ) )
......
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