[vlc-devel] [PATCH] Add hotkeys for fine grain control of playback rate
Rov Juvano
rovjuvano at users.sourceforge.net
Thu Jul 3 09:43:48 CEST 2008
---
include/vlc_keys.h | 3 +++
modules/control/hotkeys.c | 20 +++++++++++++++++++-
src/input/var.c | 13 ++++++++++++-
src/libvlc-module.c | 21 +++++++++++++++++++++
4 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/include/vlc_keys.h b/include/vlc_keys.h
index 3275fed..b005737 100644
--- a/include/vlc_keys.h
+++ b/include/vlc_keys.h
@@ -239,6 +239,9 @@ typedef enum vlc_key {
ACTIONID_NEXT,
ACTIONID_SLOWER,
ACTIONID_FASTER,
+ ACTIONID_SLOWER_STEP,
+ ACTIONID_FASTER_STEP,
+ ACTIONID_NORMAL_SPEED,
ACTIONID_TOGGLE_FULLSCREEN,
ACTIONID_VOL_UP,
ACTIONID_VOL_DOWN,
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 88b5210..b50d7aa 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -688,14 +688,32 @@ static void Run( intf_thread_t *p_intf )
{
var_SetVoid( p_input, "rate-faster" );
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
- _("Faster") );
+ _("Faster 2x") );
}
else if( i_action == ACTIONID_SLOWER )
{
var_SetVoid( p_input, "rate-slower" );
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
+ _("Slower 1/2x") );
+ }
+ else if( i_action == ACTIONID_FASTER_STEP )
+ {
+ var_SetVoid( p_input, "rate-faster-step" );
+ vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
+ _("Faster") );
+ }
+ else if( i_action == ACTIONID_SLOWER_STEP )
+ {
+ var_SetVoid( p_input, "rate-slower-step" );
+ vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
_("Slower") );
}
+ else if( i_action == ACTIONID_NORMAL_SPEED )
+ {
+ var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT );
+ vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
+ _("Normal Speed") );
+ }
else if( i_action == ACTIONID_POSITION && b_seekable )
{
DisplayPosition( p_intf, p_vout, p_input );
diff --git a/src/input/var.c b/src/input/var.c
index 663e4b3..86e7bdf 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -77,6 +77,8 @@ static const vlc_input_callback_t p_input_callbacks[] =
CALLBACK( "rate", RateCallback ),
CALLBACK( "rate-slower", RateCallback ),
CALLBACK( "rate-faster", RateCallback ),
+ CALLBACK( "rate-slower-step", RateCallback ),
+ CALLBACK( "rate-faster-step", RateCallback ),
CALLBACK( "position", PositionCallback ),
CALLBACK( "position-offset", PositionCallback ),
CALLBACK( "time", TimeCallback ),
@@ -126,8 +128,9 @@ void input_ControlVarInit ( input_thread_t *p_input )
var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL );
var_Create( p_input, "rate-slower", VLC_VAR_VOID );
-
var_Create( p_input, "rate-faster", VLC_VAR_VOID );
+ var_Create( p_input, "rate-slower-step", VLC_VAR_VOID );
+ var_Create( p_input, "rate-faster-step", VLC_VAR_VOID );
/* Position */
var_Create( p_input, "position", VLC_VAR_FLOAT );
@@ -532,6 +535,14 @@ static int RateCallback( vlc_object_t *p_this, char const *psz_cmd,
{
input_ControlPush( p_input, INPUT_CONTROL_SET_RATE_FASTER, NULL );
}
+ else if( !strcmp( psz_cmd, "rate-slower-step" ) )
+ {
+ input_ControlPush( p_input, INPUT_CONTROL_SET_RATE_SLOWER_STEP, NULL );
+ }
+ else if( !strcmp( psz_cmd, "rate-faster-step" ) )
+ {
+ input_ControlPush( p_input, INPUT_CONTROL_SET_RATE_FASTER_STEP, NULL );
+ }
else
{
input_ControlPush( p_input, INPUT_CONTROL_SET_RATE, &newval );
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 3f5f458..5fd4805 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1160,6 +1160,12 @@ static const char *const ppsz_albumart_descriptions[] =
#define FASTER_KEY_LONGTEXT N_("Select the hotkey to use for fast forward playback.")
#define SLOWER_KEY_TEXT N_("Slower")
#define SLOWER_KEY_LONGTEXT N_("Select the hotkey to use for slow motion playback.")
+#define FASTER_STEP_KEY_TEXT N_("Faster (small)")
+#define FASTER_STEP_KEY_LONGTEXT N_("Select the hotkey to increase playback speed.")
+#define SLOWER_STEP_KEY_TEXT N_("Slower (small)")
+#define SLOWER_STEP_KEY_LONGTEXT N_("Select the hotkey to decrease playback speed.")
+#define NORMAL_SPEED_KEY_TEXT N_("Normal Speed")
+#define NORMAL_SPEED_KEY_LONGTEXT N_("Select the hotkey to set the playback speed back to normal.")
#define NEXT_KEY_TEXT N_("Next")
#define NEXT_KEY_LONGTEXT N_("Select the hotkey to use to skip to the next item in the playlist.")
#define PREV_KEY_TEXT N_("Previous")
@@ -2013,6 +2019,9 @@ vlc_module_begin();
# define KEY_PLAY KEY_UNSET
# define KEY_FASTER KEY_MODIFIER_COMMAND|'='
# define KEY_SLOWER KEY_MODIFIER_COMMAND|'-'
+# define KEY_FASTER_STEP ']'
+# define KEY_SLOWER_STEP '['
+# define KEY_NORMAL_SPEED '\\'
# define KEY_NEXT KEY_MODIFIER_COMMAND|KEY_RIGHT
# define KEY_PREV KEY_MODIFIER_COMMAND|KEY_LEFT
# define KEY_STOP KEY_MODIFIER_COMMAND|'.'
@@ -2113,6 +2122,9 @@ vlc_module_begin();
# define KEY_PLAY KEY_UNSET
# define KEY_FASTER '+'
# define KEY_SLOWER '-'
+# define KEY_FASTER_STEP ']'
+# define KEY_SLOWER_STEP '['
+# define KEY_NORMAL_SPEED '\\'
# define KEY_NEXT 'n'
# define KEY_PREV 'p'
# define KEY_STOP 's'
@@ -2223,6 +2235,12 @@ vlc_module_begin();
FASTER_KEY_LONGTEXT, false );
add_key( "key-slower", KEY_SLOWER, NULL, SLOWER_KEY_TEXT,
SLOWER_KEY_LONGTEXT, false );
+ add_key( "key-faster-step", KEY_FASTER_STEP, NULL, FASTER_STEP_KEY_TEXT,
+ FASTER_STEP_KEY_LONGTEXT, false );
+ add_key( "key-slower-step", KEY_SLOWER_STEP, NULL, SLOWER_STEP_KEY_TEXT,
+ SLOWER_STEP_KEY_LONGTEXT, false );
+ add_key( "key-normal-speed", KEY_NORMAL_SPEED, NULL, NORMAL_SPEED_KEY_TEXT,
+ NORMAL_SPEED_KEY_LONGTEXT, false );
add_key( "key-next", KEY_NEXT, NULL, NEXT_KEY_TEXT,
NEXT_KEY_LONGTEXT, false );
add_key( "key-prev", KEY_PREV, NULL, PREV_KEY_TEXT,
@@ -2551,6 +2569,9 @@ const struct hotkey libvlc_hotkeys[] =
{ "key-next", ACTIONID_NEXT, 0, },
{ "key-faster", ACTIONID_FASTER, 0, },
{ "key-slower", ACTIONID_SLOWER, 0, },
+ { "key-faster-step", ACTIONID_FASTER_STEP, 0, },
+ { "key-slower-step", ACTIONID_SLOWER_STEP, 0, },
+ { "key-normal-speed", ACTIONID_NORMAL_SPEED, 0, },
{ "key-toggle-fullscreen", ACTIONID_TOGGLE_FULLSCREEN, 0, },
{ "key-leave-fullscreen", ACTIONID_LEAVE_FULLSCREEN, 0, },
{ "key-vol-up", ACTIONID_VOL_UP, 0, },
--
1.5.4.3
More information about the vlc-devel
mailing list