]> git.sesse.net Git - vlc/blobdiff - modules/control/hotkeys.c
* change hotkeys OSD message from 0-100% to 0-400%
[vlc] / modules / control / hotkeys.c
old mode 100755 (executable)
new mode 100644 (file)
index c935af2..21d7b4f
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * hotkeys.c: Hotkey handling for vlc
  *****************************************************************************
- * Copyright (C) 2004 VideoLAN
+ * Copyright (C) 2005 the VideoLAN team
  * $Id$
  *
  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
@@ -228,15 +228,15 @@ static void Run( intf_thread_t *p_intf )
         {
             for( i = 0; i < CHANNELS_NUMBER; i++ )
             {
-                p_intf->p_sys->p_channels[ i ] =
-                    vout_RegisterOSDChannel( p_vout );
+                spu_Control( p_vout->p_spu, SPU_CHANNEL_REGISTER,
+                             &p_intf->p_sys->p_channels[ i ] );
             }
         }
 
         /* Find action triggered by hotkey */
         i_action = 0;
         i_key = GetKey( p_intf );
-        for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
+        for( i = 0; i_key != -1 && p_hotkeys[i].psz_action != NULL; i++ )
         {
             if( p_hotkeys[i].i_key == i_key )
             {
@@ -253,6 +253,14 @@ static void Run( intf_thread_t *p_intf )
 
         if( i_action == ACTIONID_QUIT )
         {
+            p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                    FIND_ANYWHERE );
+            if( p_playlist )
+            {
+                playlist_Stop( p_playlist );
+                vlc_object_release( p_playlist );
+            }
+            /* Playlist is stopped now kill vlc. */
             p_intf->p_vlc->b_die = VLC_TRUE;
             ClearChannels( p_intf, p_vout );
             vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Quit" ) );
@@ -288,12 +296,26 @@ static void Run( intf_thread_t *p_intf )
                 }
             }
         }
-
+        else if( i_action == ACTIONID_INTF_SHOW )
+        {
+            val.b_bool = VLC_TRUE;
+            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 );
+        }
         else if( i_action == ACTIONID_SUBDELAY_DOWN )
         {
             int64_t i_delay = var_GetTime( p_input, "spu-delay" );
 
-            i_delay -= 10000;    /* 10 ms */
+            i_delay -= 50000;    /* 50 ms */
 
             var_SetTime( p_input, "spu-delay", i_delay );
             ClearChannels( p_intf, p_vout );
@@ -304,17 +326,53 @@ static void Run( intf_thread_t *p_intf )
         {
             int64_t i_delay = var_GetTime( p_input, "spu-delay" );
 
-            i_delay += 10000;    /* 10 ms */
+            i_delay += 50000;    /* 50 ms */
 
             var_SetTime( p_input, "spu-delay", i_delay );
             ClearChannels( p_intf, p_vout );
             vout_OSDMessage( p_intf, DEFAULT_CHAN, "Subtitle delay %i ms",
                                  (int)(i_delay/1000) );
         }
-        else if( i_action == ACTIONID_FULLSCREEN && p_vout )
+        else if( i_action == ACTIONID_AUDIODELAY_DOWN )
+        {
+            int64_t i_delay = var_GetTime( p_input, "audio-delay" );
+
+            i_delay -= 50000;    /* 50 ms */
+
+            var_SetTime( p_input, "audio-delay", i_delay );
+            ClearChannels( p_intf, p_vout );
+            vout_OSDMessage( p_intf, DEFAULT_CHAN, "Audio delay %i ms",
+                                 (int)(i_delay/1000) );
+        }
+        else if( i_action == ACTIONID_AUDIODELAY_UP )
+        {
+            int64_t i_delay = var_GetTime( p_input, "audio-delay" );
+
+            i_delay += 50000;    /* 50 ms */
+
+            var_SetTime( p_input, "audio-delay", i_delay );
+            ClearChannels( p_intf, p_vout );
+            vout_OSDMessage( p_intf, DEFAULT_CHAN, "Audio delay %i ms",
+                                 (int)(i_delay/1000) );
+        }
+        else if( i_action == ACTIONID_FULLSCREEN )
         {
-            var_Get( p_vout, "fullscreen", &val );
-            var_Set( p_vout, "fullscreen", (vlc_value_t)!val.b_bool );
+            if( p_vout )
+            {
+                var_Get( p_vout, "fullscreen", &val ); val.b_bool = !val.b_bool;
+                var_Set( p_vout, "fullscreen", val );
+            }
+            else
+            {
+                p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                          FIND_ANYWHERE );
+                if( p_playlist )
+                {
+                    var_Get( p_playlist, "fullscreen", &val ); val.b_bool = !val.b_bool;
+                    var_Set( p_playlist, "fullscreen", val );
+                    vlc_object_release( p_playlist );
+                }
+            }
         }
         else if( i_action == ACTIONID_PLAY )
         {
@@ -459,9 +517,15 @@ static void Run( intf_thread_t *p_intf )
                 vlc_value_t val, list, list2;
                 int i_count, i;
                 var_Get( p_input, "spu-es", &val );
+                
                 var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
                             &list, &list2 );
                 i_count = list.p_list->i_count;
+                if( i_count <= 1 )
+                {
+                    vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Subtitle track: %s"), _("N/A") );
+                    continue;
+                }
                 for( i = 0; i < i_count; i++ )
                 {
                     if( val.i_int == list.p_list->p_values[i].i_int )
@@ -469,7 +533,7 @@ static void Run( intf_thread_t *p_intf )
                         break;
                     }
                 }
-                /* value of audio-es was not in choices list */
+                /* value of spu-es was not in choices list */
                 if( i == i_count )
                 {
                     msg_Warn( p_input, "invalid current subtitle track, selecting 0" );
@@ -646,7 +710,6 @@ static void PlayBookmark( intf_thread_t *p_intf, int i_num )
 
 static void SetBookmark( intf_thread_t *p_intf, int i_num )
 {
-    vlc_value_t val;
     playlist_t *p_playlist =
         vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
     if( p_playlist )
@@ -655,10 +718,14 @@ static void SetBookmark( intf_thread_t *p_intf, int i_num )
         sprintf( psz_bookmark_name, "bookmark%i", i_num );
         var_Create( p_intf, psz_bookmark_name,
                     VLC_VAR_STRING|VLC_VAR_DOINHERIT );
-        val.psz_string = strdup( p_playlist->pp_items[p_playlist->i_index]->input.psz_uri );
-        var_Set( p_intf, psz_bookmark_name, val );
-        msg_Info( p_intf, "setting playlist bookmark %i to %s", i_num,
-                  val.psz_string );
+        if( p_playlist->status.p_item )
+        {
+            config_PutPsz( p_intf, psz_bookmark_name, 
+                           p_playlist->status.p_item->input.psz_uri);
+            msg_Info( p_intf, "setting playlist bookmark %i to %s", i_num,
+                           p_playlist->status.p_item->input.psz_uri);
+            config_SaveConfigFile( p_intf, "hotkeys" );
+        }
         vlc_object_release( p_playlist );
     }
 }
@@ -717,8 +784,8 @@ static void DisplayVolume( intf_thread_t *p_intf, vout_thread_t *p_vout,
     }
     else
     {
-        vout_OSDMessage( p_vout, VOLUME_TEXT_CHAN, "Vol %d%%",
-                         2*i_vol*100/AOUT_VOLUME_MAX );
+        vout_OSDMessage( p_vout, VOLUME_TEXT_CHAN, "Volume %d%%",
+                         i_vol*400/AOUT_VOLUME_MAX );
     }
 }
 
@@ -728,10 +795,11 @@ static void ClearChannels( intf_thread_t *p_intf, vout_thread_t *p_vout )
 
     if( p_vout )
     {
-        vout_ClearOSDChannel( p_vout, DEFAULT_CHAN );
+        spu_Control( p_vout->p_spu, SPU_CHANNEL_CLEAR, DEFAULT_CHAN );
         for( i = 0; i < CHANNELS_NUMBER; i++ )
         {
-            vout_ClearOSDChannel( p_vout, p_intf->p_sys->p_channels[ i ] );
+            spu_Control( p_vout->p_spu, SPU_CHANNEL_CLEAR,
+                         p_intf->p_sys->p_channels[ i ] );
         }
     }
 }