]> git.sesse.net Git - vlc/blobdiff - modules/control/hotkeys.c
subtitles/hotkeys: hotkey accessible subtitle position adjustment
[vlc] / modules / control / hotkeys.c
index 1f536d3c83c8a5cc0cb30ea78b7b4cc65cc43994..bd5d82b1c9155032bafe43cb11d54b92bf12f0e1 100644 (file)
@@ -594,31 +594,37 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
             }
             else if( i_action == ACTIONID_DEINTERLACE && p_vout )
             {
-                vlc_value_t val={0}, val_list, text_list;
-                var_Get( p_vout, "deinterlace-mode", &val );
-                if( var_Change( p_vout, "deinterlace-mode", VLC_VAR_GETLIST,
-                                &val_list, &text_list ) >= 0 )
+                int i_deinterlace = var_GetInteger( p_vout, "deinterlace" );
+                if( i_deinterlace != 0 )
                 {
-                    int i;
-                    for( i = 0; i < val_list.p_list->i_count; i++ )
+                    var_SetInteger( p_vout, "deinterlace", 0 );
+                    vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
+                                     "%s", _("Deinterlace off") );
+                }
+                else
+                {
+                    var_SetInteger( p_vout, "deinterlace", 1 );
+
+                    char *psz_mode = var_GetString( p_vout, "deinterlace-mode" );
+                    vlc_value_t vlist, tlist;
+                    if( psz_mode && !var_Change( p_vout, "deinterlace-mode", VLC_VAR_GETCHOICES, &vlist, &tlist ) >= 0 )
                     {
-                        if( !strcmp( val_list.p_list->p_values[i].psz_string,
-                                     val.psz_string ) )
+                        const char *psz_text = NULL;
+                        for( int i = 0; i < vlist.p_list->i_count; i++ )
                         {
-                            i++;
-                            break;
+                            if( !strcmp( vlist.p_list->p_values[i].psz_string, psz_mode ) )
+                            {
+                                psz_text = tlist.p_list->p_values[i].psz_string;
+                                break;
+                            }
                         }
-                    }
-                    if( i == val_list.p_list->i_count ) i = 0;
-                    var_SetString( p_vout, "deinterlace-mode",
-                                   val_list.p_list->p_values[i].psz_string );
-                    vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
-                                     _("Deinterlace mode: %s"),
-                                     text_list.p_list->p_values[i].psz_string );
+                        vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
+                                         "%s (%s)", _("Deinterlace on"), psz_text ? psz_text : psz_mode );
 
-                    var_FreeList( &val_list, &text_list );
+                        var_FreeList( &vlist, &tlist );
+                    }
+                    free( psz_mode );
                 }
-                free( val.psz_string );
             }
             else if( ( i_action == ACTIONID_ZOOM ||
                        i_action == ACTIONID_UNZOOM ) && p_vout )
@@ -704,7 +710,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
             }
             else if( i_action == ACTIONID_RATE_NORMAL )
             {
-                var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT );
+                var_SetFloat( p_input, "rate", 1. );
                 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
                                  "%s", _("1.00x") );
             }
@@ -715,9 +721,12 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
                  * and we want to increase/decrease it by 0.1 while making sure
                  * that the resulting playback rate is a multiple of 0.1
                  */
-                int i_rate = var_GetInteger( p_input, "rate" );
-                if( i_rate == 0 )
+                int i_rate = 1. * INPUT_RATE_DEFAULT
+                             / var_GetFloat( p_input, "rate" );
+                if( i_rate < INPUT_RATE_MIN )
                     i_rate = INPUT_RATE_MIN;
+                else if( i_rate > INPUT_RATE_MAX )
+                    i_rate = INPUT_RATE_MAX;
                 int i_sign = i_rate < 0 ? -1 : 1;
                 const int i_dir = i_action == ACTIONID_RATE_FASTER_FINE ? 1 : -1;
 
@@ -729,7 +738,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
 
                 i_rate = i_sign * __MIN( __MAX( i_rate, INPUT_RATE_MIN ), INPUT_RATE_MAX );
 
-                var_SetInteger( p_input, "rate", i_rate );
+                var_SetFloat( p_input, "rate", i_rate );
 
                 char psz_msg[7+1];
                 snprintf( psz_msg, sizeof(psz_msg), _("%.2fx"), (double)INPUT_RATE_DEFAULT / i_rate );
@@ -781,6 +790,26 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
                                 _( "Subtitle delay %i ms" ),
                                  (int)(i_delay/1000) );
             }
+            else if( i_action == ACTIONID_SUBPOS_DOWN )
+            {
+                int i_pos = var_GetInteger( p_input, "sub-margin" );
+                --i_pos;
+                var_SetInteger( p_input, "sub-margin", i_pos );
+                ClearChannels( p_intf, p_vout );
+                vout_OSDMessage( p_intf, DEFAULT_CHAN,
+                                _( "Subtitle position %i px" ),
+                                 (int)(i_pos) );
+            }
+            else if( i_action == ACTIONID_SUBPOS_UP )
+            {
+                int i_pos = var_GetInteger( p_input, "sub-margin" );
+                ++i_pos;
+                var_SetInteger( p_input, "sub-margin", i_pos );
+                ClearChannels( p_intf, p_vout );
+                vout_OSDMessage( p_intf, DEFAULT_CHAN,
+                                _( "Subtitle position %i px" ),
+                                 (int)(i_pos) );
+            }
             else if( i_action == ACTIONID_AUDIODELAY_DOWN )
             {
                 int64_t i_delay = var_GetTime( p_input, "audio-delay" );
@@ -803,9 +832,9 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
             }
             else if( i_action == ACTIONID_PLAY )
             {
-                if( var_GetInteger( p_input, "rate" ) != INPUT_RATE_DEFAULT )
+                if( var_GetFloat( p_input, "rate" ) != 1. )
                     /* Return to normal speed */
-                    var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT );
+                    var_SetFloat( p_input, "rate", 1. );
                 else
                 {
                     ClearChannels( p_intf, p_vout );