Commit c7897a28 authored by Rocky Bernstein's avatar Rocky Bernstein

Handle keyboard input: numeric entry, next, prev, return and default.

parent 204044c9
......@@ -2,7 +2,7 @@
* demux.c: demux functions for dvdplay.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: demux.c,v 1.1 2003/10/04 18:55:13 gbazin Exp $
* $Id: demux.c,v 1.2 2003/11/09 00:52:32 rocky Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -90,7 +90,7 @@ int E_(InitVCD) ( vlc_object_t *p_this )
p_demux = p_input->p_demux_data = malloc( sizeof(demux_sys_t ) );
if( p_demux == NULL )
{
return VLC_ENOMEM;
return VLC_ENOMOD;
}
p_input->p_private = (void*)&p_demux->mpeg;
......@@ -104,6 +104,7 @@ int E_(InitVCD) ( vlc_object_t *p_this )
p_input->p_demux_data->p_vcd = p_vcd;
p_input->pf_demux = Demux;
p_input->pf_demux_control = demux_vaControlDefault;
p_input->pf_rewind = NULL;
p_vcd->p_intf = NULL;
......
......@@ -2,10 +2,10 @@
* intf.c: Video CD interface to handle user interaction and still time
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: intf.c,v 1.1 2003/10/04 18:55:13 gbazin Exp $
* $Id: intf.c,v 1.2 2003/11/09 00:52:32 rocky Exp $
*
* Authors: Stphane Borel <stef@via.ecp.fr>
* Current modification and breakage for VCD by rocky.
* Authors: Rocky Bernstein <rocky@panix.com>
* from DVD code by Stphane Borel <stef@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -35,16 +35,18 @@
#include "stream_control.h"
#include "input_ext-intf.h"
#include "input_ext-dec.h"
#include "vlc_keys.h"
#include "vcd.h"
#include "vcdplayer.h"
/*****************************************************************************
* intf_sys_t: description and status of interface
*****************************************************************************/
struct intf_sys_t
{
input_thread_t * p_input;
vcd_data_t * p_vcd;
input_thread_t * p_input;
thread_vcd_data_t * p_vcd;
vlc_bool_t b_still;
vlc_bool_t b_inf_still;
......@@ -77,7 +79,8 @@ int E_(VCDOpenIntf) ( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
printf("+++++Called VCDOpenIntf\n");
msg_Dbg( p_intf, "VCDOpenIntf" );
/* Allocate instance and initialize some members */
p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL )
......@@ -87,6 +90,7 @@ int E_(VCDOpenIntf) ( vlc_object_t *p_this )
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;
......@@ -111,48 +115,167 @@ void E_(VCDCloseIntf) ( vlc_object_t *p_this )
*****************************************************************************/
static void RunIntf( intf_thread_t *p_intf )
{
vlc_object_t * p_vout = NULL;
printf("+++++Called RunIntf\n");
vlc_object_t * p_vout = NULL;
thread_vcd_data_t * p_vcd;
input_thread_t * p_input;
/* What you add to the last input number entry. It accumulates all of
the 10_ADD keypresses */
int number_addend = 0;
if( InitThread( p_intf ) < 0 )
{
msg_Err( p_intf, "can't initialize intf" );
return;
}
msg_Dbg( p_intf, "intf initialized" );
p_input = p_intf->p_sys->p_input;
p_vcd = p_intf->p_sys->p_vcd =
(thread_vcd_data_t *) p_input->p_access_data;
dbg_print( INPUT_DBG_CALL, "intf initialized" );
/* Main loop */
while( !p_intf->b_die )
{
vlc_mutex_lock( &p_intf->change_lock );
/*
* keyboard event
*/
if( p_vout && p_intf->p_sys->b_key_pressed )
/*
* keyboard event
*/
if( p_vout && p_intf->p_sys->b_key_pressed )
{
p_intf->p_sys->b_key_pressed = VLC_FALSE;
printf("++++key pressed...\n");
vlc_value_t val;
int i, 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 );
dbg_print( INPUT_DBG_EVENT, "Key pressed %d", val.i_int );
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 != -1) {
switch (i_action) {
case ACTIONID_NAV_LEFT:
dbg_print( INPUT_DBG_EVENT, "ACTIONID_NAV_LEFT - prev (%d)",
number_addend );
do {
vcdplayer_play_prev( p_input );
} while (number_addend-- > 0);
break;
case ACTIONID_NAV_RIGHT:
dbg_print( INPUT_DBG_EVENT, "ACTIONID_NAV_RIGHT - next (%d)",
number_addend );
do {
vcdplayer_play_next( p_input );
} while (number_addend-- > 0);
break;
case ACTIONID_NAV_UP:
dbg_print( INPUT_DBG_EVENT, "ACTIONID_NAV_UP - return" );
vcdplayer_play_return( p_input );
break;
case ACTIONID_NAV_DOWN:
dbg_print( INPUT_DBG_EVENT, "ACTIONID_NAV_DOWN - default" );
vcdplayer_play_default( p_input );
break;
case ACTIONID_NAV_ACTIVATE:
{
vcdinfo_itemid_t itemid;
itemid.type=p_vcd->play_item.type;
dbg_print( INPUT_DBG_EVENT, "ACTIONID_NAV_ACTIVATE" );
if ( vcdplayer_pbc_is_on( p_vcd ) && number_addend != 0 ) {
lid_t next_num=vcdplayer_selection2lid(p_input,
number_addend);
if (VCDINFO_INVALID_LID != next_num) {
itemid.num = next_num;
itemid.type = VCDINFO_ITEM_TYPE_LID;
VCDPlay( p_input, itemid );
}
} else {
itemid.num = number_addend;
VCDPlay( p_input, itemid );
}
break;
}
}
number_addend = 0;
} else {
unsigned int digit_entered=0;
switch (val.i_int) {
case '9':
digit_entered++;
case '8':
digit_entered++;
case '7':
digit_entered++;
case '6':
digit_entered++;
case '5':
digit_entered++;
case '4':
digit_entered++;
case '3':
digit_entered++;
case '2':
digit_entered++;
case '1':
digit_entered++;
case '0':
{
number_addend *= 10;
number_addend += digit_entered;
dbg_print( INPUT_DBG_EVENT,
"Added %d. Number is now: %d\n",
digit_entered, number_addend);
break;
}
}
}
}
vlc_mutex_unlock( &p_intf->change_lock );
if( p_vout == NULL )
vlc_mutex_unlock( &p_intf->change_lock );
if( p_vout == NULL )
{
p_vout = vlc_object_find( p_intf->p_sys->p_input,
VLC_OBJECT_VOUT, FIND_CHILD );
if( p_vout )
p_vout = vlc_object_find( p_intf->p_sys->p_input,
VLC_OBJECT_VOUT, FIND_CHILD );
if( p_vout )
{
var_AddCallback( p_vout, "mouse-moved", MouseEvent, p_intf );
var_AddCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
var_AddCallback( p_vout, "key-pressed", KeyEvent, p_intf );
var_AddCallback( p_vout, "mouse-moved", MouseEvent, p_intf );
var_AddCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
var_AddCallback( p_vout, "key-pressed", KeyEvent, p_intf );
}
}
/* Wait a bit */
msleep( INTF_IDLE_SLEEP );
}
/* Wait a bit */
msleep( INTF_IDLE_SLEEP );
if( p_vout )
{
var_DelCallback( p_vout, "mouse-moved", MouseEvent, p_intf );
var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
vlc_object_release( p_vout );
}
vlc_object_release( p_intf->p_sys->p_input );
......@@ -167,7 +290,6 @@ static int InitThread( intf_thread_t * p_intf )
if( !p_intf->b_die )
{
input_thread_t * p_input;
vcd_data_t * p_vcd;
p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_PARENT );
......@@ -177,13 +299,9 @@ static int InitThread( intf_thread_t * p_intf )
return VLC_EGENERIC;
}
p_vcd = (vcd_data_t*)p_input->p_access_data;
p_vcd->p_intf = p_intf;
vlc_mutex_lock( &p_intf->change_lock );
p_intf->p_sys->p_input = p_input;
p_intf->p_sys->p_vcd = p_vcd;
p_intf->p_sys->b_move = VLC_FALSE;
p_intf->p_sys->b_click = VLC_FALSE;
......
......@@ -4,7 +4,7 @@
* to go here.
*****************************************************************************
* Copyright (C) 2000 VideoLAN
* $Id: vcd.c,v 1.2 2003/11/07 10:33:41 rocky Exp $
* $Id: vcd.c,v 1.3 2003/11/09 00:52:32 rocky Exp $
*
* Authors: Johan Bilien <jobi@via.ecp.fr>
* Rocky Bernstein <rocky@panix.com>
......@@ -30,6 +30,7 @@
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc_interface.h>
#include "../../demux/mpeg/system.h"
#include "vcd.h"
......@@ -345,6 +346,10 @@ VCDOpen( vlc_object_t *p_this )
#endif
}
p_vcd->p_intf = intf_Create( p_input, "vcdx" );
p_vcd->p_intf->b_block = VLC_FALSE;
intf_RunThread( p_vcd->p_intf );
return VLC_SUCCESS;
}
......@@ -362,8 +367,22 @@ VCDClose( vlc_object_t *p_this )
free( p_vcd->p_entries );
free( p_vcd->p_segments );
/* The following if block get moved elsewhere... */
if( p_vcd->p_intf != NULL )
{
intf_StopThread( p_vcd->p_intf );
vlc_object_detach( p_vcd->p_intf );
vlc_object_release( p_vcd->p_intf );
intf_Destroy( p_vcd->p_intf );
p_vcd->p_intf = NULL;
}
free( p_vcd );
p_vcd_input = NULL;
}
/*****************************************************************************
......
......@@ -3,7 +3,7 @@
* using libcdio, libvcd and libvcdinfo
*****************************************************************************
* Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
* $Id: vcdplayer.c,v 1.1 2003/10/04 18:55:13 gbazin Exp $
* $Id: vcdplayer.c,v 1.2 2003/11/09 00:52:32 rocky Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -327,7 +327,7 @@ vcdplayer_pbc_nav ( input_thread_t * p_input )
return READ_ERROR;
}
/*
/*!
Get the next play-item in the list given in the LIDs. Note play-item
here refers to list of play-items for a single LID It shouldn't be
confused with a user's list of favorite things to play or the
......@@ -367,3 +367,268 @@ vcdplayer_inc_play_item( input_thread_t *p_input )
return VLC_SUCCESS == VCDPlay( p_input, trans_itemid );
}
}
/*!
Play item assocated with the "default" selection.
Return false if there was some problem.
*/
bool
vcdplayer_play_default( input_thread_t * p_input )
{
thread_vcd_data_t *p_vcd= (thread_vcd_data_t *)p_input->p_access_data;
vcdinfo_obj_t *obj = p_vcd->vcd;
vcdinfo_itemid_t itemid;
dbg_print( (INPUT_DBG_CALL|INPUT_DBG_PBC),
"current: %d" , p_vcd->play_item.num);
itemid.type = p_vcd->play_item.type;
if (vcdplayer_pbc_is_on(p_vcd)) {
vcdinfo_lid_get_pxd(obj, &(p_vcd->pxd), p_vcd->cur_lid);
switch (p_vcd->pxd.descriptor_type) {
case PSD_TYPE_SELECTION_LIST:
case PSD_TYPE_EXT_SELECTION_LIST:
if (p_vcd->pxd.psd == NULL) return false;
vcdplayer_update_entry( p_input,
vcdinfo_get_default_offset(p_vcd->vcd,
p_vcd->cur_lid),
&itemid.num, "default");
break;
case PSD_TYPE_PLAY_LIST:
case PSD_TYPE_END_LIST:
case PSD_TYPE_COMMAND_LIST:
LOG_WARN( "There is no PBC 'default' selection here" );
return false;
}
} else {
/* PBC is not on. "default" selection beginning of current
selection . */
p_vcd->play_item.num = p_vcd->play_item.num;
}
/** ??? p_vcd->update_title(); ***/
return VLC_SUCCESS == VCDPlay( p_input, itemid );
}
/*!
Play item assocated with the "next" selection.
Return false if there was some problem.
*/
bool
vcdplayer_play_next( input_thread_t * p_input )
{
thread_vcd_data_t *p_vcd= (thread_vcd_data_t *)p_input->p_access_data;
vcdinfo_obj_t *obj = p_vcd->vcd;
vcdinfo_itemid_t itemid;
dbg_print( (INPUT_DBG_CALL|INPUT_DBG_PBC),
"current: %d" , p_vcd->play_item.num);
itemid.type = p_vcd->play_item.type;
if (vcdplayer_pbc_is_on(p_vcd)) {
vcdinfo_lid_get_pxd(obj, &(p_vcd->pxd), p_vcd->cur_lid);
switch (p_vcd->pxd.descriptor_type) {
case PSD_TYPE_SELECTION_LIST:
case PSD_TYPE_EXT_SELECTION_LIST:
if (p_vcd->pxd.psd == NULL) return false;
vcdplayer_update_entry( p_input,
vcdinf_psd_get_next_offset(p_vcd->pxd.psd),
&itemid.num, "next");
break;
case PSD_TYPE_PLAY_LIST:
if (p_vcd->pxd.pld == NULL) return false;
vcdplayer_update_entry( p_input,
vcdinf_pld_get_next_offset(p_vcd->pxd.pld),
&itemid.num, "next");
break;
case PSD_TYPE_END_LIST:
case PSD_TYPE_COMMAND_LIST:
LOG_WARN( "There is no PBC 'next' selection here" );
return false;
}
} else {
/* PBC is not on. "Next" selection is play_item.num+1 if possible. */
int max_entry = 0;
switch (p_vcd->play_item.type) {
case VCDINFO_ITEM_TYPE_ENTRY:
case VCDINFO_ITEM_TYPE_SEGMENT:
case VCDINFO_ITEM_TYPE_TRACK:
switch (p_vcd->play_item.type) {
case VCDINFO_ITEM_TYPE_ENTRY:
max_entry = p_vcd->num_entries;
break;
case VCDINFO_ITEM_TYPE_SEGMENT:
max_entry = p_vcd->num_segments;
break;
case VCDINFO_ITEM_TYPE_TRACK:
max_entry = p_vcd->num_tracks;
break;
default: ; /* Handle exceptional cases below */
}
if (p_vcd->play_item.num+1 < max_entry) {
itemid.num = p_vcd->play_item.num+1;
} else {
LOG_WARN( "At the end - non-PBC 'next' not possible here" );
return false;
}
break;
case VCDINFO_ITEM_TYPE_LID:
{
/* Should have handled above. */
LOG_WARN( "Internal inconsistency - should not have gotten here." );
return false;
}
default:
return false;
}
}
/** ??? p_vcd->update_title(); ***/
return VLC_SUCCESS == VCDPlay( p_input, itemid );
}
/*!
Play item assocated with the "prev" selection.
Return false if there was some problem.
*/
bool
vcdplayer_play_prev( input_thread_t * p_input )
{
thread_vcd_data_t *p_vcd= (thread_vcd_data_t *)p_input->p_access_data;
vcdinfo_obj_t *obj = p_vcd->vcd;
vcdinfo_itemid_t itemid;
dbg_print( (INPUT_DBG_CALL|INPUT_DBG_PBC),
"current: %d" , p_vcd->play_item.num);
itemid.type = p_vcd->play_item.type;
if (vcdplayer_pbc_is_on(p_vcd)) {
vcdinfo_lid_get_pxd(obj, &(p_vcd->pxd), p_vcd->cur_lid);
switch (p_vcd->pxd.descriptor_type) {
case PSD_TYPE_SELECTION_LIST:
case PSD_TYPE_EXT_SELECTION_LIST:
if (p_vcd->pxd.psd == NULL) return false;
vcdplayer_update_entry( p_input,
vcdinf_psd_get_prev_offset(p_vcd->pxd.psd),
&itemid.num, "prev");
break;
case PSD_TYPE_PLAY_LIST:
if (p_vcd->pxd.pld == NULL) return false;
vcdplayer_update_entry( p_input,
vcdinf_pld_get_prev_offset(p_vcd->pxd.pld),
&itemid.num, "prev");
break;
case PSD_TYPE_END_LIST:
case PSD_TYPE_COMMAND_LIST:
LOG_WARN( "There is no PBC 'prev' selection here" );
return false;
}
} else {
/* PBC is not on. "Prev" selection is play_item.num-1 if possible. */
int min_entry = (VCDINFO_ITEM_TYPE_ENTRY == p_vcd->play_item.type)
? 0 : 1;
if (p_vcd->play_item.num > min_entry) {
itemid.num = p_vcd->play_item.num-1;
} else {
LOG_WARN( "At the beginning - non-PBC 'prev' not possible here" );
return false;
}
}
/** ??? p_vcd->update_title(); ***/
return VLC_SUCCESS == VCDPlay( p_input, itemid );
}
/*!
Play item assocated with the "return" selection.
Return false if there was some problem.
*/
bool
vcdplayer_play_return( input_thread_t * p_input )
{
thread_vcd_data_t *p_vcd= (thread_vcd_data_t *)p_input->p_access_data;
vcdinfo_obj_t *obj = p_vcd->vcd;
vcdinfo_itemid_t itemid;
dbg_print( (INPUT_DBG_CALL|INPUT_DBG_PBC),
"current: %d" , p_vcd->play_item.num);
itemid.type = p_vcd->play_item.type;
if (vcdplayer_pbc_is_on(p_vcd)) {
vcdinfo_lid_get_pxd(obj, &(p_vcd->pxd), p_vcd->cur_lid);
switch (p_vcd->pxd.descriptor_type) {
case PSD_TYPE_SELECTION_LIST:
case PSD_TYPE_EXT_SELECTION_LIST:
if (p_vcd->pxd.psd == NULL) return false;
vcdplayer_update_entry( p_input,
vcdinf_psd_get_return_offset(p_vcd->pxd.psd),
&itemid.num, "return");
break;
case PSD_TYPE_PLAY_LIST:
if (p_vcd->pxd.pld == NULL) return false;
vcdplayer_update_entry( p_input,
vcdinf_pld_get_return_offset(p_vcd->pxd.pld),
&itemid.num, "return");
break;
case PSD_TYPE_END_LIST:
case PSD_TYPE_COMMAND_LIST:
LOG_WARN( "There is no PBC 'return' selection here" );
return false;
}
} else {
/* PBC is not on. "Return" selection is min_entry if possible. */
p_vcd->play_item.num = (VCDINFO_ITEM_TYPE_ENTRY == p_vcd->play_item.type)
? 0 : 1;
}
/** ??? p_vcd->update_title(); ***/
return VLC_SUCCESS == VCDPlay( p_input, itemid );
}
/*****************************************************************************
* Copyright (C) 2003 Rocky Bernstein (for VideoLAN)
* $Id: vcdplayer.h,v 1.1 2003/10/04 18:55:13 gbazin Exp $
* $Id: vcdplayer.h,v 1.2 2003/11/09 00:52:32 rocky Exp $
*
* Authors: Rocky Bernstein <rocky@panix.com>
*
......@@ -26,15 +26,18 @@
#include <libvcd/info.h>
#define INPUT_DBG_MRL 1
#define INPUT_DBG_EXT 2 /* Calls from external routines */
#define INPUT_DBG_CALL 4 /* all calls */
#define INPUT_DBG_LSN 8 /* LSN changes */
#define INPUT_DBG_PBC 16 /* Playback control */
#define INPUT_DBG_CDIO 32 /* Debugging from CDIO */
#define INPUT_DBG_SEEK 64 /* Seeks to set location */
#define INPUT_DBG_STILL 128 /* Still-frame */
#define INPUT_DBG_VCDINFO 256 /* Debugging from VCDINFO */
#define INPUT_DBG_META 1 /* Meta information */
#define INPUT_DBG_EVENT 2 /* input (keyboard/mouse) events */
#define INPUT_DBG_MRL 4 /* MRL parsing */
#define INPUT_DBG_EXT 8 /* Calls from external routines */
#define INPUT_DBG_CALL 16 /* all calls */
#define INPUT_DBG_LSN 32 /* LSN changes */
#define INPUT_DBG_PBC 64 /* Playback control */
#define INPUT_DBG_CDIO 128 /* Debugging from CDIO */
#define INPUT_DBG_SEEK 256 /* Seeks to set location */
#define INPUT_DBG_SEEK_CUR 512 /* Seeks to find current location */
#define INPUT_DBG_STILL 1024 /* Still-frame */
#define INPUT_DBG_VCDINFO 2048 /* Debugging from VCDINFO */
#define INPUT_DEBUG 1
#if INPUT_DEBUG
......@@ -45,7 +48,8 @@
#define dbg_print(mask, s, args...)
#endif
#define LOG_ERR(args...) msg_Err( p_input, args )
#define LOG_ERR(args...) msg_Err( p_input, args )
#define LOG_WARN(args...) msg_Warn( p_input, args )
/* vcdplayer_read return status */
typedef enum {
......@@ -97,11 +101,56 @@ typedef struct thread_vcd_data_s
bool b_valid_ep; /* Valid entry points flag */
vlc_bool_t b_end_of_track; /* If the end of track was reached */
int i_debug; /* Debugging mask */
/* Probably gets moved into another structure...*/
intf_thread_t * p_intf;
int i_audio_nb;
int i_still_time;
vlc_bool_t b_end_of_cell;
} thread_vcd_data_t;
bool vcdplayer_inc_play_item( input_thread_t *p_input );
bool vcdplayer_pbc_is_on(const thread_vcd_data_t *p_this);
/*!
Get the next play-item in the list given in the LIDs. Note play-item
here refers to list of play-items for a single LID It shouldn't be
confused with a user's list of favorite things to play or the
"next" field of a LID which moves us to a different LID.
*/
bool vcdplayer_inc_play_item( input_thread_t *p_input );
/*!
Return true if playback control (PBC) is on
*/
bool vcdplayer_pbc_is_on(const thread_vcd_data_t *p_this);
/*!
Play item assocated with the "default" selection.
Return false if there was some problem.
*/
bool vcdplayer_play_default( input_thread_t * p_input );
/*!
Play item assocated with the "next" selection.
Return false if there was some problem.
*/
bool vcdplayer_play_next( input_thread_t * p_input );
/*!
Play item assocated with the "prev" selection.
Return false if there was some problem.
*/
bool vcdplayer_play_prev( input_thread_t * p_input );
/*!
Play item assocated with the "return" selection.
Return false if there was some problem.
*/
bool
vcdplayer_play_return( input_thread_t * p_input );
vcdplayer_read_status_t vcdplayer_pbc_nav ( input_thread_t * p_input );
vcdplayer_read_status_t vcdplayer_non_pbc_nav ( input_thread_t * p_input );
......
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