Commit c28589a4 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* simplified the lirc code to listen for key-* strings which we can directly...

* simplified the lirc code to listen for key-* strings which we can directly use to trigger hotkeys.
* updated the example.lircrc with new required strings
* added a notice to NEWS about changed lirc syntax.
parent e055f5eb
......@@ -61,6 +61,8 @@ Interfaces:
- Fixes
* HTTP
- Support for the new playlist system
* Lirc
- Now uses new config settings. See doc/lirc/example.lirc
Windows port:
* Screensaver disabling fix
......
# This is an example .lircrc file that shows the different config strings that
# vlc understand. button names are from an animax remote, and these may change
# with different remotes
# vlc understand. Button names are from an animax remote, and these may change
# with different remotes.
# The current full list of config strings vlc understands is always in vlc's
# src/libvlc.h file. Look for lines like:
# add_key( "key-fullscreen", KEY_FULLSCREEN, NULL, FULLSCREEN_KEY_TEXT,
# FULLSCREEN_KEY_LONGTEXT, VLC_FALSE );
# You will need the first argument of these lines. in this case: key-fullscreen
begin
prog = vlc
button = PLAY_UP
config = PLAY
config = key-play
end
begin
prog = vlc
button = PAUSE_UP
config = PAUSE
config = key-pause
end
#use this target if you have a combined play/pause button
# Use this target if you have a combined play/pause button
begin
prog = vlc
button = PLAY_UP
config = PLAYPAUSE
config = key-play-pause
end
begin
prog = vlc
button = STOP_UP
config = STOP
config = key-stop
end
begin
prog = vlc
button = POWER_UP
config = QUIT
config = key-quit
end
begin
prog = vlc
button = SKIP_FORWARD_UP
config = NEXT
config = key-next
end
begin
prog = vlc
button = SKIP_BACKWARD
config = PREV
config = key-prev
end
begin
prog = vlc
button = RED_BUTTON_UP
config = FULLSCREEN
config = key-fullscreen
end
begin
prog = vlc
button = REWIND_UP
config = SLOW
config = key-slower
end
begin
prog = vlc
button = FORWARD_UP
config = FAST
config = key-faster
end
#Audio controls
begin
prog = vlc
button = VOLUME_DOWN_DOWN
config = VOL_DOWN
config = key-vol-down
end
begin
prog = vlc
button = VOLUME_UP_DOWN
config = VOL_UP
config = key-vol-up
end
begin
prog = vlc
button = SOMEBUTTON
config = AUDIO_TRACK
config = key-audio-track
end
begin
prog = vlc
button = MUTE_UP
config = MUTE
config = key-vol-mute
end
#For dvd navigation
begin
prog = vlc
button = 4_UP
config = LEFT
config = key-nav-left
end
begin
prog = vlc
button = 5_UP
config = DOWN
config = key-nav-down
end
begin
prog = vlc
button = 2_UP
config = UP
config = key-nav-up
end
begin
prog = vlc
button = 6_UP
config = RIGHT
config = key-nav-right
end
begin
prog = vlc
button = MENU_UP
config = ACTIVATE
config = key-nav-activate
end
begin
prog = vlc
button = 9_UP
config = key-subtitle-track
end
/*****************************************************************************
* lirc.c : lirc module for vlc
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* Copyright (C) 2003-2005 VideoLAN
* $Id$
*
* Author: Sigmund Augdal <sigmunau@idi.ntnu.no>
......@@ -31,9 +31,6 @@
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <vlc/vout.h>
#include <vlc/aout.h>
#include <osd.h>
#include <lirc/lirc_client.h>
......@@ -43,12 +40,6 @@
struct intf_sys_t
{
struct lirc_config *config;
vlc_mutex_t change_lock;
int i_osd_channel;
input_thread_t * p_input;
vout_thread_t * p_vout;
};
/*****************************************************************************
......@@ -106,8 +97,6 @@ static int Open( vlc_object_t *p_this )
return 1;
}
p_intf->p_sys->p_input = NULL;
return 0;
}
......@@ -118,14 +107,6 @@ static void Close( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
if( p_intf->p_sys->p_input )
{
vlc_object_release( p_intf->p_sys->p_input );
}
if( p_intf->p_sys->p_vout )
{
vlc_object_release( p_intf->p_sys->p_vout );
}
/* Destroy structure */
lirc_freeconfig( p_intf->p_sys->config );
lirc_deinit();
......@@ -138,42 +119,12 @@ static void Close( vlc_object_t *p_this )
static void Run( intf_thread_t *p_intf )
{
char *code, *c;
playlist_t *p_playlist;
input_thread_t *p_input;
vout_thread_t *p_vout = NULL;
while( !p_intf->b_die )
{
/* Sleep a bit */
msleep( INTF_IDLE_SLEEP );
/* Update the input */
if( p_intf->p_sys->p_input == NULL )
{
p_intf->p_sys->p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
}
else if( p_intf->p_sys->p_input->b_dead )
{
vlc_object_release( p_intf->p_sys->p_input );
p_intf->p_sys->p_input = NULL;
}
p_input = p_intf->p_sys->p_input;
/* Update the vout */
if( p_vout == NULL )
{
p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
p_intf->p_sys->p_vout = p_vout;
}
else if( p_vout->b_die )
{
vlc_object_release( p_vout );
p_vout = NULL;
p_intf->p_sys->p_vout = NULL;
}
/* We poll the lircsocket */
if( lirc_nextcode(&code) != 0 )
{
......@@ -189,294 +140,17 @@ static void Run( intf_thread_t *p_intf )
&& lirc_code2char( p_intf->p_sys->config, code, &c ) == 0
&& c != NULL )
{
vlc_value_t keyval;
if( !strcmp( c, "QUIT" ) )
{
p_intf->p_vlc->b_die = VLC_TRUE;
vout_OSDMessage( p_intf, DEFAULT_CHAN, _("Quit" ) );
continue;
}
else if( !strcmp( c, "VOL_UP" ) )
{
audio_volume_t i_newvol;
aout_VolumeUp( p_intf, 1, &i_newvol );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _("Vol %%%d"),
i_newvol * 100 / AOUT_VOLUME_MAX );
}
else if( !strcmp( c, "VOL_DOWN" ) )
{
audio_volume_t i_newvol;
aout_VolumeDown( p_intf, 1, &i_newvol );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _("Vol %%%d"),
i_newvol * 100 / AOUT_VOLUME_MAX );
}
else if( !strcmp( c, "MUTE" ) )
{
audio_volume_t i_newvol = -1;
aout_VolumeMute( p_intf, &i_newvol );
if( i_newvol == 0 )
{
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Mute" ) );
}
else
{
vout_OSDMessage( p_intf, DEFAULT_CHAN, _("Vol %d%%"),
i_newvol * 100 / AOUT_VOLUME_MAX );
}
}
if( p_vout )
{
if( !strcmp( c, "FULLSCREEN" ) )
{
p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
continue;
}
if( !strcmp( c, "ACTIVATE" ) )
{
vlc_value_t val;
val.psz_string = "ENTER";
if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS)
{
msg_Warn( p_intf, "key-press failed" );
}
continue;
}
if( !strcmp( c, "LEFT" ) )
{
vlc_value_t val;
val.psz_string = "LEFT";
if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS)
{
msg_Warn( p_intf, "key-press failed" );
}
continue;
}
if( !strcmp( c, "RIGHT" ) )
{
vlc_value_t val;
val.psz_string = "RIGHT";
if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS)
{
msg_Warn( p_intf, "key-press failed" );
}
continue;
}
if( !strcmp( c, "UP" ) )
{
vlc_value_t val;
val.psz_string = "UP";
if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS)
{
msg_Warn( p_intf, "key-press failed" );
}
continue;
}
if( !strcmp( c, "DOWN" ) )
{
vlc_value_t val;
val.psz_string = "DOWN";
if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS)
{
msg_Warn( p_intf, "key-press failed" );
}
continue;
}
}
if( !strcmp( c, "PLAY" ) )
{
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
playlist_Play( p_playlist );
vlc_object_release( p_playlist );
}
continue;
}
if( !strcmp( c, "PLAYPAUSE" ) )
{
vlc_value_t val;
val.i_int = PLAYING_S;
if( p_input )
{
var_Get( p_input, "state", &val );
}
if( p_input && val.i_int != PAUSE_S )
{
vout_OSDMessage( VLC_OBJECT(p_intf), DEFAULT_CHAN,
_( "Pause" ) );
val.i_int = PAUSE_S;
var_Set( p_input, "state", val );
}
else
{
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
vlc_mutex_lock( &p_playlist->object_lock );
if( p_playlist->i_size )
{
vlc_mutex_unlock( &p_playlist->object_lock );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Play" ) );
playlist_Play( p_playlist );
vlc_object_release( p_playlist );
}
}
}
continue;
}
else if( p_input )
{
if( !strcmp( c, "AUDIO_TRACK" ) )
{
vlc_value_t val, list, list2;
int i_count, i;
var_Get( p_input, "audio-es", &val );
var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES,
&list, &list2 );
i_count = list.p_list->i_count;
for( i = 0; i < i_count; i++ )
{
if( val.i_int == list.p_list->p_values[i].i_int )
if( strncmp( "key-", c, 4 )
{
msg_Err( p_intf, "This doesn't appear to be a valid keycombo lirc sent us. Please look at the doc/lirc/example.lirc file in VLC" );
break;
}
keyval.i_int = config_GetInt( p_intf, c );
var_Set( p_intf->p_vlc, "key-pressed", keyval );
}
/* value of audio-es was not in choices list */
if( i == i_count )
{
msg_Warn( p_input,
"invalid current audio track, selecting 0" );
var_Set( p_input, "audio-es",
list.p_list->p_values[0] );
i = 0;
}
else if( i == i_count - 1 )
{
var_Set( p_input, "audio-es",
list.p_list->p_values[0] );
i = 0;
}
else
{
var_Set( p_input, "audio-es",
list.p_list->p_values[i+1] );
i++;
}
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
_("Audio track: %s"),
list2.p_list->p_values[i].psz_string );
}
else if( !strcmp( c, "SUBTITLE_TRACK" ) )
{
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;
for( i = 0; i < i_count; i++ )
{
if( val.i_int == list.p_list->p_values[i].i_int )
{
break;
}
}
/* value of audio-es was not in choices list */
if( i == i_count )
{
msg_Warn( p_input, "invalid current subtitle track, selecting 0" );
var_Set( p_input, "spu-es", list.p_list->p_values[0] );
i = 0;
}
else if( i == i_count - 1 )
{
var_Set( p_input, "spu-es", list.p_list->p_values[0] );
i = 0;
}
else
{
var_Set( p_input, "spu-es", list.p_list->p_values[i+1] );
i = i + 1;
}
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
_("Subtitle track: %s"),
list2.p_list->p_values[i].psz_string );
}
else if( !strcmp( c, "PAUSE" ) )
{
vlc_value_t val;
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Pause" ) );
val.i_int = PAUSE_S;
var_Set( p_input, "state", val );
}
else if( !strcmp( c, "NEXT" ) )
{
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
playlist_Next( p_playlist );
vlc_object_release( p_playlist );
}
}
else if( !strcmp( c, "PREV" ) )
{
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
playlist_Prev( p_playlist );
vlc_object_release( p_playlist );
}
}
else if( !strcmp( c, "STOP" ) )
{
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
}
}
else if( !strcmp( c, "FAST" ) )
{
vlc_value_t val; val.b_bool = VLC_TRUE;
var_Set( p_input, "rate-faster", val );
}
else if( !strcmp( c, "SLOW" ) )
{
vlc_value_t val; val.b_bool = VLC_TRUE;
var_Set( p_input, "rate-slower", val );
}
/* beginning of modifications by stephane Thu Jun 19 15:29:49 CEST 2003 */
else if ( !strcmp(c, "CHAPTER_N" ) ||
!strcmp( c, "CHAPTER_P" ) )
{
unsigned int i_chapter = 0;
if( !strcmp( c, "CHAPTER_N" ) )
{
var_SetVoid( p_input, "next-chapter" );
}
else if( !strcmp( c, "CHAPTER_P" ) )
{
var_SetVoid( p_input, "prev-chapter" );
}
}
/* end of modification by stephane Thu Jun 19 15:29:49 CEST 2003 */
}
}
free( code );
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment