Commit 0369c9f0 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Added new hotkeys (key-intf-hide, key-jump-3sec, key-jump+3sec,...

Added new hotkeys (key-intf-hide, key-jump-3sec, key-jump+3sec, key-title-next, key-title-prev, key-chapter-next, key-chapter-prev) and expanded the hotkey structure. This is a forward port from branch vlc-0.8.1-jpsaman-thedj revision 11756.
parent 90a27edc
......@@ -116,7 +116,11 @@ struct vlc_t
const char *psz_action;
int i_action;
int i_key;
/* hotkey accounting information */
mtime_t i_delta_date;/*< minimum delta time between two key presses */
mtime_t i_last_date; /*< last date key was pressed */
int i_times; /*< n times pressed within delta date*/
} *p_hotkeys;
};
......@@ -200,46 +200,55 @@ static inline int StringToKey( char *psz_key )
#define ACTIONID_NAV_DOWN 15
#define ACTIONID_NAV_LEFT 16
#define ACTIONID_NAV_RIGHT 17
#define ACTIONID_JUMP_BACKWARD_10SEC 18
#define ACTIONID_JUMP_FORWARD_10SEC 19
#define ACTIONID_JUMP_BACKWARD_1MIN 20
#define ACTIONID_JUMP_FORWARD_1MIN 21
#define ACTIONID_JUMP_BACKWARD_5MIN 22
#define ACTIONID_JUMP_FORWARD_5MIN 23
#define ACTIONID_POSITION 24
#define ACTIONID_VOL_MUTE 25
#define ACTIONID_JUMP_BACKWARD_3SEC 18
#define ACTIONID_JUMP_FORWARD_3SEC 19
#define ACTIONID_JUMP_BACKWARD_10SEC 20
#define ACTIONID_JUMP_FORWARD_10SEC 21
#define ACTIONID_JUMP_BACKWARD_1MIN 21
#define ACTIONID_JUMP_FORWARD_1MIN 23
#define ACTIONID_JUMP_BACKWARD_5MIN 24
#define ACTIONID_JUMP_FORWARD_5MIN 25
#define ACTIONID_POSITION 26
#define ACTIONID_VOL_MUTE 27
/* let ACTIONID_SET_BOOMARK* and ACTIONID_PLAY_BOOKMARK* be contiguous */
#define ACTIONID_SET_BOOKMARK1 26
#define ACTIONID_SET_BOOKMARK2 27
#define ACTIONID_SET_BOOKMARK3 28
#define ACTIONID_SET_BOOKMARK4 29
#define ACTIONID_SET_BOOKMARK5 30
#define ACTIONID_SET_BOOKMARK6 31
#define ACTIONID_SET_BOOKMARK7 32
#define ACTIONID_SET_BOOKMARK8 33
#define ACTIONID_SET_BOOKMARK9 34
#define ACTIONID_SET_BOOKMARK10 35
#define ACTIONID_PLAY_BOOKMARK1 36
#define ACTIONID_PLAY_BOOKMARK2 37
#define ACTIONID_PLAY_BOOKMARK3 38
#define ACTIONID_PLAY_BOOKMARK4 39
#define ACTIONID_PLAY_BOOKMARK5 40
#define ACTIONID_PLAY_BOOKMARK6 41
#define ACTIONID_PLAY_BOOKMARK7 42
#define ACTIONID_PLAY_BOOKMARK8 43
#define ACTIONID_PLAY_BOOKMARK9 44
#define ACTIONID_PLAY_BOOKMARK10 45
#define ACTIONID_SET_BOOKMARK1 28
#define ACTIONID_SET_BOOKMARK2 29
#define ACTIONID_SET_BOOKMARK3 39
#define ACTIONID_SET_BOOKMARK4 31
#define ACTIONID_SET_BOOKMARK5 32
#define ACTIONID_SET_BOOKMARK6 33
#define ACTIONID_SET_BOOKMARK7 34
#define ACTIONID_SET_BOOKMARK8 35
#define ACTIONID_SET_BOOKMARK9 36
#define ACTIONID_SET_BOOKMARK10 37
#define ACTIONID_PLAY_BOOKMARK1 38
#define ACTIONID_PLAY_BOOKMARK2 39
#define ACTIONID_PLAY_BOOKMARK3 40
#define ACTIONID_PLAY_BOOKMARK4 41
#define ACTIONID_PLAY_BOOKMARK5 42
#define ACTIONID_PLAY_BOOKMARK6 43
#define ACTIONID_PLAY_BOOKMARK7 44
#define ACTIONID_PLAY_BOOKMARK8 45
#define ACTIONID_PLAY_BOOKMARK9 46
#define ACTIONID_PLAY_BOOKMARK10 47
/* end of contiguous zone */
#define ACTIONID_SUBDELAY_UP 46
#define ACTIONID_SUBDELAY_DOWN 47
#define ACTIONID_HISTORY_BACK 48
#define ACTIONID_HISTORY_FORWARD 49
#define ACTIONID_AUDIO_TRACK 50
#define ACTIONID_SUBTITLE_TRACK 51
#define ACTIONID_CUBESPEED_UP 52
#define ACTIONID_CUBESPEED_DOWN 53
#define ACTIONID_INTF_SHOW 52
#define ACTIONID_AUDIODELAY_UP 53
#define ACTIONID_AUDIODELAY_DOWN 54
#define ACTIONID_SNAPSHOT 55
#define ACTIONID_RECORD 56
#define ACTIONID_SUBDELAY_UP 48
#define ACTIONID_SUBDELAY_DOWN 49
#define ACTIONID_HISTORY_BACK 50
#define ACTIONID_HISTORY_FORWARD 51
#define ACTIONID_AUDIO_TRACK 52
#define ACTIONID_SUBTITLE_TRACK 53
#define ACTIONID_CUBESPEED_UP 54
#define ACTIONID_CUBESPEED_DOWN 55
#define ACTIONID_INTF_SHOW 56
#define ACTIONID_INTF_HIDE 57
/* chapter and title navigation */
#define ACTIONID_TITLE_PREV 58
#define ACTIONID_TITLE_NEXT 59
#define ACTIONID_CHAPTER_PREV 60
#define ACTIONID_CHAPTER_NEXT 61
/* end of chapter and title navigation */
#define ACTIONID_AUDIODELAY_UP 62
#define ACTIONID_AUDIODELAY_DOWN 63
#define ACTIONID_SNAPSHOT 64
#define ACTIONID_RECORD 65
......@@ -5,6 +5,7 @@
* $Id$
*
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* Jean-Paul Saman <jpsaman #_at_# m2x.nl>
*
* 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
......@@ -152,6 +153,7 @@ static void Close( 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 );
if( p_intf->p_sys->p_input )
{
vlc_object_release( p_intf->p_sys->p_input );
......@@ -169,10 +171,10 @@ static void Close( vlc_object_t *p_this )
*****************************************************************************/
static void Run( intf_thread_t *p_intf )
{
playlist_t *p_playlist;
input_thread_t *p_input;
playlist_t *p_playlist = NULL;
input_thread_t *p_input = NULL;
vout_thread_t *p_vout = NULL;
vout_thread_t *p_last_vout;
vout_thread_t *p_last_vout = NULL;
struct hotkey *p_hotkeys = p_intf->p_vlc->p_hotkeys;
vlc_value_t val;
int i;
......@@ -192,6 +194,7 @@ static void Run( intf_thread_t *p_intf )
while( !p_intf->b_die )
{
int i_key, i_action;
int i_times = 0;
/* Sleep a bit */
msleep( INTF_IDLE_SLEEP );
......@@ -241,6 +244,7 @@ static void Run( intf_thread_t *p_intf )
if( p_hotkeys[i].i_key == i_key )
{
i_action = p_hotkeys[i].i_action;
i_times = p_hotkeys[i].i_times; /* times key pressed within max. delta time */
}
}
......@@ -307,6 +311,17 @@ static void Run( intf_thread_t *p_intf )
vlc_object_release( p_playlist );
}
}
else if( i_action == ACTIONID_INTF_HIDE )
{
val.b_bool = VLC_FALSE;
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
var_Set( p_playlist, "intf-show", val );
vlc_object_release( p_playlist );
}
}
else if( i_action == ACTIONID_SNAPSHOT )
{
if( p_vout ) vout_Control( p_vout, VOUT_SNAPSHOT );
......@@ -380,12 +395,24 @@ static void Run( intf_thread_t *p_intf )
FIND_ANYWHERE );
if( p_playlist )
{
ClearChannels( p_intf, p_vout );
vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
OSD_PAUSE_ICON );
playlist_Play( p_playlist );
var_Get( p_input, "rate", &val );
msg_Dbg( p_input, "rate %d", val.i_int );
if( val.i_int != INPUT_RATE_DEFAULT )
{
/* Return to normal speed */
val.i_int = INPUT_RATE_DEFAULT;
var_Set( p_input, "rate", val );
}
else
{
ClearChannels( p_intf, p_vout );
vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
OSD_PAUSE_ICON );
playlist_Play( p_playlist );
}
vlc_object_release( p_playlist );
}
}
else if( i_action == ACTIONID_PLAY_PAUSE )
{
......@@ -432,39 +459,51 @@ static void Run( intf_thread_t *p_intf )
val.i_int = PAUSE_S;
var_Set( p_input, "state", val );
}
else if( i_action == ACTIONID_JUMP_BACKWARD_3SEC && b_seekable )
{
val.i_time = (-3000000 * 2^i_times);
var_Set( p_input, "time-offset", val );
DisplayPosition( p_intf, p_vout, p_input );
}
else if( i_action == ACTIONID_JUMP_FORWARD_3SEC && b_seekable )
{
val.i_time = (3000000 * 2^i_times);
var_Set( p_input, "time-offset", val );
DisplayPosition( p_intf, p_vout, p_input );
}
else if( i_action == ACTIONID_JUMP_BACKWARD_10SEC && b_seekable )
{
val.i_time = -10000000;
val.i_time = (-10000000 * 2^i_times);
var_Set( p_input, "time-offset", val );
DisplayPosition( p_intf, p_vout, p_input );
}
else if( i_action == ACTIONID_JUMP_FORWARD_10SEC && b_seekable )
{
val.i_time = 10000000;
val.i_time = (10000000 * 2^i_times);
var_Set( p_input, "time-offset", val );
DisplayPosition( p_intf, p_vout, p_input );
}
else if( i_action == ACTIONID_JUMP_BACKWARD_1MIN && b_seekable )
{
val.i_time = -60000000;
val.i_time = (-60000000 * 2^i_times);
var_Set( p_input, "time-offset", val );
DisplayPosition( p_intf, p_vout, p_input );
}
else if( i_action == ACTIONID_JUMP_FORWARD_1MIN && b_seekable )
{
val.i_time = 60000000;
val.i_time = (60000000 * 2^i_times);
var_Set( p_input, "time-offset", val );
DisplayPosition( p_intf, p_vout, p_input );
}
else if( i_action == ACTIONID_JUMP_BACKWARD_5MIN && b_seekable )
{
val.i_time = -300000000;
val.i_time = (-300000000 * 2^i_times);
var_Set( p_input, "time-offset", val );
DisplayPosition( p_intf, p_vout, p_input );
}
else if( i_action == ACTIONID_JUMP_FORWARD_5MIN && b_seekable )
{
val.i_time = 300000000;
val.i_time = (300000000 * 2^i_times);
var_Set( p_input, "time-offset", val );
DisplayPosition( p_intf, p_vout, p_input );
}
......@@ -588,13 +627,15 @@ static void Run( intf_thread_t *p_intf )
}
else if( i_action == ACTIONID_FASTER )
{
vlc_value_t val; val.b_bool = VLC_TRUE;
vlc_value_t val;
val.b_bool = VLC_TRUE;
var_Set( p_input, "rate-faster", val );
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Faster") );
}
else if( i_action == ACTIONID_SLOWER )
{
vlc_value_t val; val.b_bool = VLC_TRUE;
vlc_value_t val;
val.b_bool = VLC_TRUE;
var_Set( p_input, "rate-slower", val );
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Slower") );
}
......@@ -612,6 +653,27 @@ static void Run( intf_thread_t *p_intf )
{
SetBookmark( p_intf, i_action - ACTIONID_SET_BOOKMARK1 + 1 );
}
/* Only makes sense with DVD */
else if( i_action == ACTIONID_TITLE_PREV )
{
val.b_bool = VLC_TRUE;
var_Set( p_input, "prev-title", val );
}
else if( i_action == ACTIONID_TITLE_NEXT )
{
val.b_bool = VLC_TRUE;
var_Set( p_input, "next-title", val );
}
else if( i_action == ACTIONID_CHAPTER_PREV )
{
val.b_bool = VLC_TRUE;
var_Set( p_input, "prev-chapter", val );
}
else if( i_action == ACTIONID_CHAPTER_NEXT )
{
val.b_bool = VLC_TRUE;
var_Set( p_input, "next-chapter", val );
}
}
}
}
......@@ -667,6 +729,7 @@ static int ActionKeyCB( vlc_object_t *p_this, char const *psz_var,
{
vlc_t *p_vlc = (vlc_t *)p_this;
struct hotkey *p_hotkeys = p_vlc->p_hotkeys;
mtime_t i_date;
int i;
for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
......@@ -674,6 +737,14 @@ static int ActionKeyCB( vlc_object_t *p_this, char const *psz_var,
if( !strcmp( p_hotkeys[i].psz_action, psz_var ) )
{
p_hotkeys[i].i_key = newval.i_int;
/* do hotkey accounting */
i_date = mdate();
if( (p_hotkeys[i].i_delta_date > 0) &&
(p_hotkeys[i].i_delta_date <= (i_date - p_hotkeys[i].i_last_date) ) )
p_hotkeys[i].i_times = 0;
else
p_hotkeys[i].i_times++;
p_hotkeys[i].i_last_date = i_date;
}
}
......
This diff is collapsed.
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