* intf.c: interface for DVD video manager
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: intf.c,v 1.4 2002/11/08 10:26:52 gbazin Exp $
+ * $Id: intf.c,v 1.9 2003/10/29 01:33:27 gbazin Exp $
*
* Authors: Stéphane Borel <stef@via.ecp.fr>
*
#include "input_ext-intf.h"
#include "input_ext-dec.h"
+#include "vlc_keys.h"
+
#include "dvd.h"
/*****************************************************************************
mtime_t m_still_time;
dvdplay_ctrl_t control;
- vlc_bool_t b_click, b_move;
+ vlc_bool_t b_click, b_move, b_key_pressed;
};
/*****************************************************************************
static int InitThread ( intf_thread_t *p_intf );
static int MouseEvent ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
+static int KeyEvent ( vlc_object_t *, char const *,
+ vlc_value_t, vlc_value_t, void * );
/* Exported functions */
static void RunIntf ( intf_thread_t *p_intf );
};
p_intf->pf_run = RunIntf;
-
+
+ var_AddCallback( p_intf->p_vlc, "key-pressed", KeyEvent, p_intf );
p_intf->p_sys->m_still_time = 0;
p_intf->p_sys->b_inf_still = 0;
p_intf->p_sys->b_still = 0;
void E_(CloseIntf) ( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
-
+ var_DelCallback( p_intf->p_vlc, "key-pressed", KeyEvent, p_intf );
/* Destroy structure */
free( p_intf->p_sys );
}
}
}
+ /*
+ * keyboard event
+ */
+ if( p_intf->p_sys->b_key_pressed )
+ {
+ vlc_value_t val;
+ int i, i_activate, i_action = -1;
+ struct hotkey *p_hotkeys = p_intf->p_vlc->p_hotkeys;
+
+ p_intf->p_sys->b_key_pressed = VLC_FALSE;
+
+ /* Find action triggered by hotkey (if any) */
+ var_Get( p_intf->p_vlc, "key-pressed", &val );
+ for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
+ {
+ if( p_hotkeys[i].i_key == val.i_int )
+ {
+ i_action = p_hotkeys[i].i_action;
+ }
+ }
+
+ if( i_action )
+ {
+ if( i_action == ACTIONID_NAV_LEFT )
+ {
+ p_intf->p_sys->control.type = DVDCtrlLeftButtonSelect;
+ }
+ else if( i_action == ACTIONID_NAV_RIGHT )
+ {
+ p_intf->p_sys->control.type = DVDCtrlRightButtonSelect;
+ }
+ else if( i_action == ACTIONID_NAV_UP )
+ {
+ p_intf->p_sys->control.type = DVDCtrlUpperButtonSelect;
+ }
+ else if( i_action == ACTIONID_NAV_DOWN )
+ {
+ p_intf->p_sys->control.type = DVDCtrlLowerButtonSelect;
+ }
+ else if( i_action == ACTIONID_NAV_ACTIVATE )
+ {
+ 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 );
/*
*****************************************************************************/
static int InitThread( intf_thread_t * p_intf )
{
- /* we might need some locking here */
+ /* We might need some locking here */
if( !p_intf->b_die )
{
input_thread_t * p_input;
dvd_data_t * p_dvd;
p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_PARENT );
- p_dvd = (dvd_data_t*)p_input->p_access_data;
+ /* Maybe the input just died */
+ if( p_input == NULL )
+ {
+ return VLC_EGENERIC;
+ }
+
+ p_dvd = (dvd_data_t*)p_input->p_access_data;
p_dvd->p_intf = p_intf;
vlc_mutex_lock( &p_intf->change_lock );
p_intf->p_sys->b_move = 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 );
- return 0;
+ return VLC_SUCCESS;
}
else
{
- return -1;
+ return VLC_EGENERIC;
}
}
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
* still images
return VLC_SUCCESS;
}
+/*****************************************************************************
+ * dvdIntfStillTime: function provided to reset still image
+ *****************************************************************************/
+int dvdIntfResetStillTime( intf_thread_t *p_intf )
+{
+ vlc_mutex_lock( &p_intf->change_lock );
+ p_intf->p_sys->m_still_time = 0;
+ input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
+ vlc_mutex_unlock( &p_intf->change_lock );
+
+ return VLC_SUCCESS;
+}