1 /*****************************************************************************
2 * hotkeys.c: Hotkey handling for vlc
3 *****************************************************************************
4 * Copyright (C) 2005 the VideoLAN team
7 * Authors: Sigmund Augdal Helberg <dnumgis@videolan.org>
8 * Jean-Paul Saman <jpsaman #_at_# m2x.nl>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
32 #include <vlc/input.h>
39 #define BUFFER_SIZE 10
41 #define CHANNELS_NUMBER 4
42 #define VOLUME_TEXT_CHAN p_intf->p_sys->p_channels[ 0 ]
43 #define VOLUME_WIDGET_CHAN p_intf->p_sys->p_channels[ 1 ]
44 #define POSITION_TEXT_CHAN p_intf->p_sys->p_channels[ 2 ]
45 #define POSITION_WIDGET_CHAN p_intf->p_sys->p_channels[ 3 ]
46 /*****************************************************************************
47 * intf_sys_t: description and status of FB interface
48 *****************************************************************************/
51 vlc_mutex_t change_lock; /* mutex to keep the callback
52 * and the main loop from
53 * stepping on each others
55 int p_keys[ BUFFER_SIZE ]; /* buffer that contains
57 int i_size; /* number of events in buffer */
58 int p_channels[ CHANNELS_NUMBER ]; /* contains registered
60 input_thread_t * p_input; /* pointer to input */
61 vout_thread_t * p_vout; /* pointer to vout object */
64 /*****************************************************************************
66 *****************************************************************************/
67 static int Open ( vlc_object_t * );
68 static void Close ( vlc_object_t * );
69 static void Run ( intf_thread_t * );
70 static int GetKey ( intf_thread_t *);
71 static int KeyEvent( vlc_object_t *, char const *,
72 vlc_value_t, vlc_value_t, void * );
73 static int ActionKeyCB( vlc_object_t *, char const *,
74 vlc_value_t, vlc_value_t, void * );
75 static void PlayBookmark( intf_thread_t *, int );
76 static void SetBookmark ( intf_thread_t *, int );
77 static void DisplayPosition( intf_thread_t *, vout_thread_t *, input_thread_t * );
78 static void DisplayVolume ( intf_thread_t *, vout_thread_t *, audio_volume_t );
79 static void ClearChannels ( intf_thread_t *, vout_thread_t * );
81 /*****************************************************************************
83 *****************************************************************************/
84 #define BOOKMARK1_TEXT N_("Playlist bookmark 1")
85 #define BOOKMARK2_TEXT N_("Playlist bookmark 2")
86 #define BOOKMARK3_TEXT N_("Playlist bookmark 3")
87 #define BOOKMARK4_TEXT N_("Playlist bookmark 4")
88 #define BOOKMARK5_TEXT N_("Playlist bookmark 5")
89 #define BOOKMARK6_TEXT N_("Playlist bookmark 6")
90 #define BOOKMARK7_TEXT N_("Playlist bookmark 7")
91 #define BOOKMARK8_TEXT N_("Playlist bookmark 8")
92 #define BOOKMARK9_TEXT N_("Playlist bookmark 9")
93 #define BOOKMARK10_TEXT N_("Playlist bookmark 10")
94 #define BOOKMARK_LONGTEXT N_( \
95 "This option allows you to define playlist bookmarks.")
97 #define JIEXTRASHORT_TEXT N_("Extra short jump key interval")
98 #define JIEXTRASHORT_LONGTEXT N_("Extra short jump key interval in seconds")
99 #define JISHORT_TEXT N_("Short jump key interval")
100 #define JISHORT_LONGTEXT N_("Short jump key interval in seconds")
101 #define JIMEDIUM_TEXT N_("Medium jump key interval")
102 #define JIMEDIUM_LONGTEXT N_("Medium jump key interval in seconds")
103 #define JILONG_TEXT N_("Long jump key interval")
104 #define JILONG_LONGTEXT N_("Long jump key interval in seconds")
107 set_shortname( _("Hotkeys") );
108 set_description( _("Hotkeys management interface") );
109 set_category( CAT_INTERFACE );
110 // set_subcategory( SUBCAT_INTERFACE_GENERAL );
112 /* jump key user defined time intervals */
113 add_integer( "key-jump-extrashort-interval", 3, NULL, JIEXTRASHORT_TEXT,
114 JIEXTRASHORT_LONGTEXT, VLC_FALSE );
115 add_integer( "key-jump-short-interval", 10, NULL, JISHORT_TEXT,
116 JISHORT_LONGTEXT, VLC_FALSE );
117 add_integer( "key-jump-medium-interval", 60, NULL, JIMEDIUM_TEXT,
118 JIMEDIUM_LONGTEXT, VLC_FALSE );
119 add_integer( "key-jump-long-interval", 300, NULL, JILONG_TEXT,
120 JILONG_LONGTEXT, VLC_FALSE );
122 add_string( "bookmark1", NULL, NULL,
123 BOOKMARK1_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
124 add_string( "bookmark2", NULL, NULL,
125 BOOKMARK2_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
126 add_string( "bookmark3", NULL, NULL,
127 BOOKMARK3_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
128 add_string( "bookmark4", NULL, NULL,
129 BOOKMARK4_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
130 add_string( "bookmark5", NULL, NULL,
131 BOOKMARK5_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
132 add_string( "bookmark6", NULL, NULL,
133 BOOKMARK6_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
134 add_string( "bookmark7", NULL, NULL,
135 BOOKMARK7_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
136 add_string( "bookmark8", NULL, NULL,
137 BOOKMARK8_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
138 add_string( "bookmark9", NULL, NULL,
139 BOOKMARK9_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
140 add_string( "bookmark10", NULL, NULL,
141 BOOKMARK10_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
143 set_capability( "interface", 0 );
144 set_callbacks( Open, Close );
147 /*****************************************************************************
148 * Open: initialize interface
149 *****************************************************************************/
150 static int Open( vlc_object_t *p_this )
152 intf_thread_t *p_intf = (intf_thread_t *)p_this;
154 /* Allocate instance and initialize some members */
155 p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
156 if( p_intf->p_sys == NULL )
158 msg_Err( p_intf, "out of memory" );
161 vlc_mutex_init( p_intf, &p_intf->p_sys->change_lock );
162 p_intf->p_sys->i_size = 0;
163 p_intf->pf_run = Run;
165 p_intf->p_sys->p_input = NULL;
166 p_intf->p_sys->p_vout = NULL;
168 var_AddCallback( p_intf->p_vlc, "key-pressed", KeyEvent, p_intf );
172 /*****************************************************************************
173 * Close: destroy interface
174 *****************************************************************************/
175 static void Close( vlc_object_t *p_this )
177 intf_thread_t *p_intf = (intf_thread_t *)p_this;
179 var_DelCallback( p_intf->p_vlc, "key-pressed", KeyEvent, p_intf );
180 if( p_intf->p_sys->p_input )
182 vlc_object_release( p_intf->p_sys->p_input );
184 if( p_intf->p_sys->p_vout )
186 vlc_object_release( p_intf->p_sys->p_vout );
188 /* Destroy structure */
189 free( p_intf->p_sys );
192 /*****************************************************************************
194 *****************************************************************************/
195 static void Run( intf_thread_t *p_intf )
197 playlist_t *p_playlist = NULL;
198 input_thread_t *p_input = NULL;
199 vout_thread_t *p_vout = NULL;
200 vout_thread_t *p_last_vout = NULL;
201 struct hotkey *p_hotkeys = p_intf->p_vlc->p_hotkeys;
205 /* Initialize hotkey structure */
206 for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
208 var_Create( p_intf->p_vlc, p_hotkeys[i].psz_action,
209 VLC_VAR_HOTKEY | VLC_VAR_DOINHERIT );
211 var_AddCallback( p_intf->p_vlc, p_hotkeys[i].psz_action,
213 var_Get( p_intf->p_vlc, p_hotkeys[i].psz_action, &val );
214 var_Set( p_intf->p_vlc, p_hotkeys[i].psz_action, val );
217 while( !p_intf->b_die )
223 msleep( INTF_IDLE_SLEEP );
225 /* Update the input */
226 if( p_intf->p_sys->p_input == NULL )
228 p_intf->p_sys->p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT,
231 else if( p_intf->p_sys->p_input->b_dead )
233 vlc_object_release( p_intf->p_sys->p_input );
234 p_intf->p_sys->p_input = NULL;
236 p_input = p_intf->p_sys->p_input;
238 /* Update the vout */
239 p_last_vout = p_intf->p_sys->p_vout;
242 p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
243 p_intf->p_sys->p_vout = p_vout;
245 else if( p_vout->b_die )
247 vlc_object_release( p_vout );
249 p_intf->p_sys->p_vout = NULL;
252 /* Register OSD channels */
253 if( p_vout && p_vout != p_last_vout )
255 for( i = 0; i < CHANNELS_NUMBER; i++ )
257 spu_Control( p_vout->p_spu, SPU_CHANNEL_REGISTER,
258 &p_intf->p_sys->p_channels[ i ] );
262 /* Find action triggered by hotkey */
264 i_key = GetKey( p_intf );
265 for( i = 0; i_key != -1 && p_hotkeys[i].psz_action != NULL; i++ )
267 if( p_hotkeys[i].i_key == i_key )
269 i_action = p_hotkeys[i].i_action;
270 i_times = p_hotkeys[i].i_times; /* times key pressed within max. delta time */
271 p_hotkeys[i].i_times = 0;
277 /* No key pressed, sleep a bit more */
278 msleep( INTF_IDLE_SLEEP );
282 if( i_action == ACTIONID_QUIT )
284 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
288 playlist_Stop( p_playlist );
289 vlc_object_release( p_playlist );
291 /* Playlist is stopped now kill vlc. */
292 p_intf->p_vlc->b_die = VLC_TRUE;
293 ClearChannels( p_intf, p_vout );
294 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Quit" ) );
297 else if( i_action == ACTIONID_VOL_UP )
299 audio_volume_t i_newvol;
300 aout_VolumeUp( p_intf, 1, &i_newvol );
301 DisplayVolume( p_intf, p_vout, i_newvol );
303 else if( i_action == ACTIONID_VOL_DOWN )
305 audio_volume_t i_newvol;
306 aout_VolumeDown( p_intf, 1, &i_newvol );
307 DisplayVolume( p_intf, p_vout, i_newvol );
309 else if( i_action == ACTIONID_VOL_MUTE )
311 audio_volume_t i_newvol = -1;
312 aout_VolumeMute( p_intf, &i_newvol );
317 ClearChannels( p_intf, p_vout );
318 vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
323 DisplayVolume( p_intf, p_vout, i_newvol );
327 else if( i_action == ACTIONID_INTF_SHOW )
329 val.b_bool = VLC_TRUE;
330 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
334 var_Set( p_playlist, "intf-show", val );
335 vlc_object_release( p_playlist );
338 else if( i_action == ACTIONID_INTF_HIDE )
340 val.b_bool = VLC_FALSE;
341 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
345 var_Set( p_playlist, "intf-show", val );
346 vlc_object_release( p_playlist );
349 else if( i_action == ACTIONID_SNAPSHOT )
351 if( p_vout ) vout_Control( p_vout, VOUT_SNAPSHOT );
353 else if( i_action == ACTIONID_FULLSCREEN )
357 var_Get( p_vout, "fullscreen", &val ); val.b_bool = !val.b_bool;
358 var_Set( p_vout, "fullscreen", val );
362 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
366 var_Get( p_playlist, "fullscreen", &val ); val.b_bool = !val.b_bool;
367 var_Set( p_playlist, "fullscreen", val );
368 vlc_object_release( p_playlist );
372 else if( i_action == ACTIONID_PLAY_PAUSE )
374 val.i_int = PLAYING_S;
377 var_Get( p_input, "state", &val );
379 if( p_input && val.i_int != PAUSE_S )
381 ClearChannels( p_intf, p_vout );
382 vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
385 var_Set( p_input, "state", val );
389 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
393 ClearChannels( p_intf, p_vout );
394 vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
396 playlist_Play( p_playlist );
397 vlc_object_release( p_playlist );
404 * How to get a valid value ?
405 * That's not that easy with some special stream
407 vlc_bool_t b_seekable = VLC_TRUE;
410 if( i_action == ACTIONID_PAUSE )
412 ClearChannels( p_intf, p_vout );
413 vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
416 var_Set( p_input, "state", val );
418 else if( i_action == ACTIONID_JUMP_BACKWARD_EXTRASHORT && b_seekable )
420 #define SET_TIME( a, b ) \
421 i_interval = config_GetInt( p_input, "key-jump-" a "-interval" ); \
422 if( i_interval > 0 ) { \
423 val.i_time = ( (mtime_t)(i_interval * b) * 1000000L \
424 * ((mtime_t)(1 << i_times))); \
425 var_Set( p_input, "time-offset", val ); \
426 DisplayPosition( p_intf, p_vout, p_input ); \
428 SET_TIME( "extrashort", -1 );
430 else if( i_action == ACTIONID_JUMP_FORWARD_EXTRASHORT && b_seekable )
432 SET_TIME( "extrashort", 1 );
434 else if( i_action == ACTIONID_JUMP_BACKWARD_SHORT && b_seekable )
436 SET_TIME( "short", -1 );
438 else if( i_action == ACTIONID_JUMP_FORWARD_SHORT && b_seekable )
440 SET_TIME( "short", 1 );
442 else if( i_action == ACTIONID_JUMP_BACKWARD_MEDIUM && b_seekable )
444 SET_TIME( "medium", -1 );
446 else if( i_action == ACTIONID_JUMP_FORWARD_MEDIUM && b_seekable )
448 SET_TIME( "medium", 1 );
450 else if( i_action == ACTIONID_JUMP_BACKWARD_LONG && b_seekable )
452 SET_TIME( "long", -1 );
454 else if( i_action == ACTIONID_JUMP_FORWARD_LONG && b_seekable )
456 SET_TIME( "long", 1 );
459 else if( i_action == ACTIONID_AUDIO_TRACK )
461 vlc_value_t val, list, list2;
463 var_Get( p_input, "audio-es", &val );
464 var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES,
466 i_count = list.p_list->i_count;
471 for( i = 0; i < i_count; i++ )
473 if( val.i_int == list.p_list->p_values[i].i_int )
478 /* value of audio-es was not in choices list */
482 "invalid current audio track, selecting 0" );
483 var_Set( p_input, "audio-es",
484 list.p_list->p_values[0] );
487 else if( i == i_count - 1 )
489 var_Set( p_input, "audio-es",
490 list.p_list->p_values[1] );
495 var_Set( p_input, "audio-es",
496 list.p_list->p_values[i+1] );
499 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
500 _("Audio track: %s"),
501 list2.p_list->p_values[i].psz_string );
503 else if( i_action == ACTIONID_SUBTITLE_TRACK )
505 vlc_value_t val, list, list2;
507 var_Get( p_input, "spu-es", &val );
509 var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
511 i_count = list.p_list->i_count;
514 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Subtitle track: %s"), _("N/A") );
517 for( i = 0; i < i_count; i++ )
519 if( val.i_int == list.p_list->p_values[i].i_int )
524 /* value of spu-es was not in choices list */
527 msg_Warn( p_input, "invalid current subtitle track, selecting 0" );
528 var_Set( p_input, "spu-es", list.p_list->p_values[0] );
531 else if( i == i_count - 1 )
533 var_Set( p_input, "spu-es", list.p_list->p_values[0] );
538 var_Set( p_input, "spu-es", list.p_list->p_values[i+1] );
541 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
542 _("Subtitle track: %s"),
543 list2.p_list->p_values[i].psz_string );
545 else if( i_action == ACTIONID_NEXT )
547 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
551 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Next") );
552 playlist_Next( p_playlist );
553 vlc_object_release( p_playlist );
556 else if( i_action == ACTIONID_PREV )
558 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
562 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Previous") );
563 playlist_Prev( p_playlist );
564 vlc_object_release( p_playlist );
567 else if( i_action == ACTIONID_STOP )
569 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
573 playlist_Stop( p_playlist );
574 vlc_object_release( p_playlist );
577 else if( i_action == ACTIONID_FASTER )
580 val.b_bool = VLC_TRUE;
581 var_Set( p_input, "rate-faster", val );
582 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Faster") );
584 else if( i_action == ACTIONID_SLOWER )
587 val.b_bool = VLC_TRUE;
588 var_Set( p_input, "rate-slower", val );
589 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Slower") );
591 else if( i_action == ACTIONID_POSITION && b_seekable )
593 DisplayPosition( p_intf, p_vout, p_input );
595 else if( i_action >= ACTIONID_PLAY_BOOKMARK1 &&
596 i_action <= ACTIONID_PLAY_BOOKMARK10 )
598 PlayBookmark( p_intf, i_action - ACTIONID_PLAY_BOOKMARK1 + 1 );
600 else if( i_action >= ACTIONID_SET_BOOKMARK1 &&
601 i_action <= ACTIONID_SET_BOOKMARK10 )
603 SetBookmark( p_intf, i_action - ACTIONID_SET_BOOKMARK1 + 1 );
605 /* Only makes sense with DVD */
606 else if( i_action == ACTIONID_TITLE_PREV )
608 val.b_bool = VLC_TRUE;
609 var_Set( p_input, "prev-title", val );
611 else if( i_action == ACTIONID_TITLE_NEXT )
613 val.b_bool = VLC_TRUE;
614 var_Set( p_input, "next-title", val );
616 else if( i_action == ACTIONID_CHAPTER_PREV )
618 val.b_bool = VLC_TRUE;
619 var_Set( p_input, "prev-chapter", val );
621 else if( i_action == ACTIONID_CHAPTER_NEXT )
623 val.b_bool = VLC_TRUE;
624 var_Set( p_input, "next-chapter", val );
626 else if( i_action == ACTIONID_DISC_MENU )
628 vlc_value_t val; val.i_int = 2;
629 msg_Dbg( p_input, "set dvdmenu" );
630 var_Set( p_input, "title 0", val);
632 else if( i_action == ACTIONID_SUBDELAY_DOWN )
634 int64_t i_delay = var_GetTime( p_input, "spu-delay" );
636 i_delay -= 50000; /* 50 ms */
638 var_SetTime( p_input, "spu-delay", i_delay );
639 ClearChannels( p_intf, p_vout );
640 vout_OSDMessage( p_intf, DEFAULT_CHAN, "Subtitle delay %i ms",
641 (int)(i_delay/1000) );
643 else if( i_action == ACTIONID_SUBDELAY_UP )
645 int64_t i_delay = var_GetTime( p_input, "spu-delay" );
647 i_delay += 50000; /* 50 ms */
649 var_SetTime( p_input, "spu-delay", i_delay );
650 ClearChannels( p_intf, p_vout );
651 vout_OSDMessage( p_intf, DEFAULT_CHAN, "Subtitle delay %i ms",
652 (int)(i_delay/1000) );
654 else if( i_action == ACTIONID_AUDIODELAY_DOWN )
656 int64_t i_delay = var_GetTime( p_input, "audio-delay" );
658 i_delay -= 50000; /* 50 ms */
660 var_SetTime( p_input, "audio-delay", i_delay );
661 ClearChannels( p_intf, p_vout );
662 vout_OSDMessage( p_intf, DEFAULT_CHAN, "Audio delay %i ms",
663 (int)(i_delay/1000) );
665 else if( i_action == ACTIONID_AUDIODELAY_UP )
667 int64_t i_delay = var_GetTime( p_input, "audio-delay" );
669 i_delay += 50000; /* 50 ms */
671 var_SetTime( p_input, "audio-delay", i_delay );
672 ClearChannels( p_intf, p_vout );
673 vout_OSDMessage( p_intf, DEFAULT_CHAN, "Audio delay %i ms",
674 (int)(i_delay/1000) );
676 else if( i_action == ACTIONID_PLAY )
678 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
682 var_Get( p_input, "rate", &val );
683 msg_Dbg( p_input, "rate %d", val.i_int );
684 if( val.i_int != INPUT_RATE_DEFAULT )
686 /* Return to normal speed */
687 val.i_int = INPUT_RATE_DEFAULT;
688 var_Set( p_input, "rate", val );
692 ClearChannels( p_intf, p_vout );
693 vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
695 playlist_Play( p_playlist );
697 vlc_object_release( p_playlist );
704 static int GetKey( intf_thread_t *p_intf)
706 vlc_mutex_lock( &p_intf->p_sys->change_lock );
707 if ( p_intf->p_sys->i_size == 0 )
709 vlc_mutex_unlock( &p_intf->p_sys->change_lock );
714 int i_return = p_intf->p_sys->p_keys[ 0 ];
716 p_intf->p_sys->i_size--;
717 for ( i = 0; i < BUFFER_SIZE - 1; i++)
719 p_intf->p_sys->p_keys[ i ] = p_intf->p_sys->p_keys[ i + 1 ];
721 vlc_mutex_unlock( &p_intf->p_sys->change_lock );
726 /*****************************************************************************
727 * KeyEvent: callback for keyboard events
728 *****************************************************************************/
729 static int KeyEvent( vlc_object_t *p_this, char const *psz_var,
730 vlc_value_t oldval, vlc_value_t newval, void *p_data )
732 intf_thread_t *p_intf = (intf_thread_t *)p_data;
733 vlc_mutex_lock( &p_intf->p_sys->change_lock );
734 if ( p_intf->p_sys->i_size == BUFFER_SIZE )
736 msg_Warn( p_intf, "event buffer full, dropping keypress" );
737 vlc_mutex_unlock( &p_intf->p_sys->change_lock );
742 p_intf->p_sys->p_keys[ p_intf->p_sys->i_size ] = newval.i_int;
743 p_intf->p_sys->i_size++;
745 vlc_mutex_unlock( &p_intf->p_sys->change_lock );
750 static int ActionKeyCB( vlc_object_t *p_this, char const *psz_var,
751 vlc_value_t oldval, vlc_value_t newval, void *p_data )
753 vlc_t *p_vlc = (vlc_t *)p_this;
754 struct hotkey *p_hotkeys = p_vlc->p_hotkeys;
758 for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
760 if( !strcmp( p_hotkeys[i].psz_action, psz_var ) )
762 p_hotkeys[i].i_key = newval.i_int;
763 /* do hotkey accounting */
765 if( (p_hotkeys[i].i_delta_date > 0) &&
766 (p_hotkeys[i].i_delta_date <= (i_date - p_hotkeys[i].i_last_date) ) )
767 p_hotkeys[i].i_times = 0;
769 p_hotkeys[i].i_times++;
770 p_hotkeys[i].i_last_date = i_date;
777 static void PlayBookmark( intf_thread_t *p_intf, int i_num )
781 char psz_bookmark_name[11];
782 playlist_t *p_playlist =
783 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
785 sprintf( psz_bookmark_name, "bookmark%i", i_num );
786 var_Create( p_intf, psz_bookmark_name, VLC_VAR_STRING|VLC_VAR_DOINHERIT );
787 var_Get( p_intf, psz_bookmark_name, &val );
791 char *psz_bookmark = strdup( val.psz_string );
792 for( i_position = 0; i_position < p_playlist->i_size; i_position++)
794 if( !strcmp( psz_bookmark,
795 p_playlist->pp_items[i_position]->input.psz_uri ) )
797 playlist_Goto( p_playlist, i_position );
801 vlc_object_release( p_playlist );
805 static void SetBookmark( intf_thread_t *p_intf, int i_num )
807 playlist_t *p_playlist =
808 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
811 char psz_bookmark_name[11];
812 sprintf( psz_bookmark_name, "bookmark%i", i_num );
813 var_Create( p_intf, psz_bookmark_name,
814 VLC_VAR_STRING|VLC_VAR_DOINHERIT );
815 if( p_playlist->status.p_item )
817 config_PutPsz( p_intf, psz_bookmark_name,
818 p_playlist->status.p_item->input.psz_uri);
819 msg_Info( p_intf, "setting playlist bookmark %i to %s", i_num,
820 p_playlist->status.p_item->input.psz_uri);
821 config_SaveConfigFile( p_intf, "hotkeys" );
823 vlc_object_release( p_playlist );
827 static void DisplayPosition( intf_thread_t *p_intf, vout_thread_t *p_vout,
828 input_thread_t *p_input )
830 char psz_duration[MSTRTIME_MAX_SIZE];
831 char psz_time[MSTRTIME_MAX_SIZE];
832 vlc_value_t time, pos;
839 ClearChannels( p_intf, p_vout );
841 var_Get( p_input, "time", &time );
842 i_seconds = time.i_time / 1000000;
843 secstotimestr ( psz_time, i_seconds );
845 var_Get( p_input, "length", &time );
846 if( time.i_time > 0 )
848 secstotimestr( psz_duration, time.i_time / 1000000 );
849 vout_OSDMessage( p_input, POSITION_TEXT_CHAN, "%s / %s",
850 psz_time, psz_duration );
852 else if( i_seconds > 0 )
854 vout_OSDMessage( p_input, POSITION_TEXT_CHAN, psz_time );
857 if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
859 var_Get( p_input, "position", &pos );
860 vout_OSDSlider( VLC_OBJECT( p_input ), POSITION_WIDGET_CHAN,
861 pos.f_float * 100, OSD_HOR_SLIDER );
865 static void DisplayVolume( intf_thread_t *p_intf, vout_thread_t *p_vout,
866 audio_volume_t i_vol )
872 ClearChannels( p_intf, p_vout );
874 if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
876 vout_OSDSlider( VLC_OBJECT( p_vout ), VOLUME_WIDGET_CHAN,
877 i_vol*100/AOUT_VOLUME_MAX, OSD_VERT_SLIDER );
881 vout_OSDMessage( p_vout, VOLUME_TEXT_CHAN, "Volume %d%%",
882 i_vol*400/AOUT_VOLUME_MAX );
886 static void ClearChannels( intf_thread_t *p_intf, vout_thread_t *p_vout )
892 spu_Control( p_vout->p_spu, SPU_CHANNEL_CLEAR, DEFAULT_CHAN );
893 for( i = 0; i < CHANNELS_NUMBER; i++ )
895 spu_Control( p_vout->p_spu, SPU_CHANNEL_CLEAR,
896 p_intf->p_sys->p_channels[ i ] );