[vlc-commits] hotkeys: Implement reverse sub track cycling

Mohammed (Shaan) Huzaifa Danish git at videolan.org
Wed May 3 22:14:47 CEST 2017


vlc | branch: master | Mohammed (Shaan) Huzaifa Danish <shaan3 at gmail.com> | Tue May  2 22:36:49 2017 -0700| [b959f4053f2411c3d168909ff873d152788c0dca] | committer: Jean-Baptiste Kempf

hotkeys: Implement reverse sub track cycling

Pressing 'v' to change the cycle track, we now use 'Alt+v' to cycle in the reverse direction.

Close #8958

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b959f4053f2411c3d168909ff873d152788c0dca
---

 include/vlc_keys.h        | 1 +
 modules/control/hotkeys.c | 8 ++++++--
 src/config/keys.c         | 1 +
 src/libvlc-module.c       | 6 ++++++
 4 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/include/vlc_keys.h b/include/vlc_keys.h
index 8d8df53edb..9e5880839f 100644
--- a/include/vlc_keys.h
+++ b/include/vlc_keys.h
@@ -171,6 +171,7 @@ typedef enum vlc_action {
     ACTIONID_SUBPOS_UP,
     ACTIONID_SUBPOS_DOWN,
     ACTIONID_AUDIO_TRACK,
+    ACTIONID_SUBTITLE_REVERSE_TRACK,
     ACTIONID_SUBTITLE_TRACK,
     ACTIONID_SUBTITLE_TOGGLE,
     ACTIONID_SUBTITLE_TEXT_SCALE_NORMAL,
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 4e4f36897e..6c52ce8848 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -737,7 +737,9 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
                 var_FreeList( &list, &list2 );
             }
             break;
+
         case ACTIONID_SUBTITLE_TRACK:
+        case ACTIONID_SUBTITLE_REVERSE_TRACK:
             if( p_input )
             {
                 vlc_value_t val, list, list2;
@@ -768,10 +770,12 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
                               "invalid current subtitle track, selecting 0" );
                     i = 0;
                 }
-                else if( i == i_count - 1 )
+                else if ((i == i_count - 1) && (i_action == ACTIONID_SUBTITLE_TRACK))
                     i = 0;
+                else if ((i == 0) && (i_action == ACTIONID_SUBTITLE_REVERSE_TRACK))
+                    i = i_count - 1;
                 else
-                    i++;
+                    i = (i_action == ACTIONID_SUBTITLE_TRACK) ? i+1 : i-1;
                 var_SetInteger( p_input, "spu-es", list.p_list->p_values[i].i_int );
                 var_SetInteger( p_input, "spu-choice", list.p_list->p_values[i].i_int );
                 DisplayMessage( p_vout, _("Subtitle track: %s"),
diff --git a/src/config/keys.c b/src/config/keys.c
index 336466bda5..5c68caeeeb 100644
--- a/src/config/keys.c
+++ b/src/config/keys.c
@@ -354,6 +354,7 @@ static const struct action actions[] =
     { "subsync-markaudio", ACTIONID_SUBSYNC_MARKAUDIO, },
     { "subsync-marksub", ACTIONID_SUBSYNC_MARKSUB, },
     { "subsync-reset", ACTIONID_SUBSYNC_RESET, },
+    { "subtitle-revtrack", ACTIONID_SUBTITLE_REVERSE_TRACK, },
     { "subtitle-text-scale-down", ACTIONID_SUBTITLE_TEXT_SCALE_DOWN, },
     { "subtitle-text-scale-normal", ACTIONID_SUBTITLE_TEXT_SCALE_NORMAL, },
     { "subtitle-text-scale-up", ACTIONID_SUBTITLE_TEXT_SCALE_UP, },
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 780785f9b0..cef03d342d 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1357,6 +1357,8 @@ static const char *const mouse_wheel_texts[] = {
 
 #define AUDIO_TRACK_KEY_TEXT N_("Cycle audio track")
 #define AUDIO_TRACK_KEY_LONGTEXT N_("Cycle through the available audio tracks(languages).")
+#define SUBTITLE_REVERSE_TRACK_KEY_TEXT N_("Cycle subtitle track in reverse order")
+#define SUBTITLE_REVERSE_TRACK_KEY_LONGTEXT N_("Cycle through the available subtitle tracks in reverse order.")
 #define SUBTITLE_TRACK_KEY_TEXT N_("Cycle subtitle track")
 #define SUBTITLE_TRACK_KEY_LONGTEXT N_("Cycle through the available subtitle tracks.")
 #define SUBTITLE_TOGGLE_KEY_TEXT N_("Toggle subtitles")
@@ -2200,6 +2202,7 @@ vlc_module_begin ()
 #   define KEY_AUDIO_TRACK        "l"
 #   define KEY_SUBTITLE_TRACK     "s"
 #   define KEY_SUBTITLE_TOGGLE    "Shift+s"
+#   define KEY_SUBTITLE_REVTRACK  "Alt+s"
 #   define KEY_PROGRAM_SID_NEXT   "x"
 #   define KEY_PROGRAM_SID_PREV   "Shift+x"
 #   define KEY_ASPECT_RATIO       "a"
@@ -2342,6 +2345,7 @@ vlc_module_begin ()
 #   define KEY_AUDIO_TRACK        "b"
 #   define KEY_SUBTITLE_TRACK     "v"
 #   define KEY_SUBTITLE_TOGGLE    "Shift+v"
+#   define KEY_SUBTITLE_REVTRACK  "Alt+v"
 #   define KEY_PROGRAM_SID_NEXT   "x"
 #   define KEY_PROGRAM_SID_PREV   "Shift+x"
 #   define KEY_ASPECT_RATIO       "a"
@@ -2514,6 +2518,8 @@ vlc_module_begin ()
              AUDIO_TRACK_KEY_LONGTEXT, false )
     add_key( "key-audiodevice-cycle", KEY_AUDIODEVICE_CYCLE, AUDI_DEVICE_CYCLE_KEY_TEXT,
              AUDI_DEVICE_CYCLE_KEY_LONGTEXT, false )
+    add_key("key-subtitle-revtrack", KEY_SUBTITLE_REVTRACK,
+             SUBTITLE_REVERSE_TRACK_KEY_TEXT, SUBTITLE_REVERSE_TRACK_KEY_LONGTEXT, false)
     add_key( "key-subtitle-track", KEY_SUBTITLE_TRACK,
              SUBTITLE_TRACK_KEY_TEXT, SUBTITLE_TRACK_KEY_LONGTEXT, false )
     add_key( "key-subtitle-toggle", KEY_SUBTITLE_TOGGLE,



More information about the vlc-commits mailing list