~ubuntu-branches/ubuntu/natty/vlc/natty

« back to all changes in this revision

Viewing changes to modules/control/lirc.c

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2010-06-25 01:09:16 UTC
  • mfrom: (1.1.30 upstream)
  • Revision ID: james.westby@ubuntu.com-20100625010916-asxhep2mutg6g6pd
Tags: 1.1.0-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - build and install the libx264 plugin
  - add Xb-Npp header to vlc package
  - Add apport hook to include more vlc dependencies in bug reports
* Drop xulrunner patches.
* Drop 502_xulrunner_191.diff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * lirc.c : lirc module for vlc
3
3
 *****************************************************************************
4
4
 * Copyright (C) 2003-2005 the VideoLAN team
5
 
 * $Id: 8b3325768ce4dab32bc3baede2949c9e4939c461 $
 
5
 * $Id: 5688c97ab106c2e64038f3d05faf42d113b62ff3 $
6
6
 *
7
7
 * Author: Sigmund Augdal Helberg <dnumgis@videolan.org>
8
8
 *
35
35
#include <vlc_plugin.h>
36
36
#include <vlc_interface.h>
37
37
#include <vlc_osd.h>
 
38
#include <vlc_keys.h>
38
39
 
39
40
#ifdef HAVE_POLL
40
41
# include <poll.h>
42
43
 
43
44
#include <lirc/lirc_client.h>
44
45
 
45
 
#define LIRC_TEXT N_("Change the lirc configuration file.")
 
46
#define LIRC_TEXT N_("Change the lirc configuration file")
46
47
#define LIRC_LONGTEXT N_( \
47
48
    "Tell lirc to read this configuration file. By default it " \
48
49
    "searches in the users home directory." )
70
71
 *****************************************************************************/
71
72
struct intf_sys_t
72
73
{
73
 
    char *psz_file;
74
74
    struct lirc_config *config;
75
75
 
76
76
    int i_fd;
81
81
 *****************************************************************************/
82
82
static void Run( intf_thread_t * );
83
83
 
84
 
static int  Process( intf_thread_t * );
 
84
static void Process( intf_thread_t * );
85
85
 
86
86
/*****************************************************************************
87
87
 * Open: initialize interface
90
90
{
91
91
    intf_thread_t *p_intf = (intf_thread_t *)p_this;
92
92
    intf_sys_t *p_sys;
 
93
    char *psz_file;
93
94
 
94
95
    /* Allocate instance and initialize some members */
95
96
    p_intf->p_sys = p_sys = malloc( sizeof( intf_sys_t ) );
98
99
 
99
100
    p_intf->pf_run = Run;
100
101
 
101
 
    p_sys->psz_file = var_CreateGetNonEmptyString( p_intf, "lirc-file" );
102
102
    p_sys->i_fd = lirc_init( "vlc", 1 );
103
103
    if( p_sys->i_fd == -1 )
104
104
    {
109
109
    /* We want polling */
110
110
    fcntl( p_sys->i_fd, F_SETFL, fcntl( p_sys->i_fd, F_GETFL ) | O_NONBLOCK );
111
111
 
112
 
    /* */
113
 
    if( lirc_readconfig( p_sys->psz_file, &p_sys->config, NULL ) != 0 )
 
112
    /* Read the configuration file */
 
113
    psz_file = var_CreateGetNonEmptyString( p_intf, "lirc-file" );
 
114
    if( lirc_readconfig( psz_file, &p_sys->config, NULL ) != 0 )
114
115
    {
115
116
        msg_Err( p_intf, "failure while reading lirc config" );
 
117
        free( psz_file );
116
118
        goto exit;
117
119
    }
 
120
    free( psz_file );
118
121
 
119
122
    return VLC_SUCCESS;
120
123
 
121
124
exit:
122
125
    if( p_sys->i_fd != -1 )
123
126
        lirc_deinit();
124
 
    free( p_sys->psz_file );
125
127
    free( p_sys );
126
128
    return VLC_EGENERIC;
127
129
}
137
139
    /* Destroy structure */
138
140
    lirc_freeconfig( p_sys->config );
139
141
    lirc_deinit();
140
 
    free( p_sys->psz_file );
141
142
    free( p_sys );
142
143
}
143
144
 
162
163
    }
163
164
}
164
165
 
165
 
static int Process( intf_thread_t *p_intf )
 
166
static void Process( intf_thread_t *p_intf )
166
167
{
167
168
    for( ;; )
168
169
    {
169
170
        char *code, *c;
170
 
        int i_ret = lirc_nextcode( &code );
171
 
 
172
 
        if( i_ret )
173
 
            return i_ret;
 
171
        if( lirc_nextcode( &code ) )
 
172
            return;
174
173
 
175
174
        if( code == NULL )
176
 
            return 0;
 
175
            return;
177
176
 
178
177
        while( vlc_object_alive( p_intf )
179
178
                && (lirc_code2char( p_intf->p_sys->config, code, &c ) == 0)
180
179
                && (c != NULL) )
181
180
        {
182
 
            vlc_value_t keyval;
183
 
 
184
181
            if( !strncmp( "key-", c, 4 ) )
185
182
            {
186
 
                keyval.i_int = config_GetInt( p_intf, c );
187
 
                var_Set( p_intf->p_libvlc, "key-pressed", keyval );
 
183
                vlc_key_t i_key = vlc_GetActionId( c );
 
184
                if( i_key )
 
185
                    var_SetInteger( p_intf->p_libvlc, "key-action", i_key );
 
186
                else
 
187
                    msg_Err( p_intf, "Unknown hotkey '%s'", c );
188
188
            }
189
189
            else if( !strncmp( "menu ", c, 5)  )
190
190
            {
213
213
            }
214
214
            else
215
215
            {
216
 
                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" );
 
216
                msg_Err( p_intf, "this doesn't appear to be a valid keycombo "
 
217
                                 "lirc sent us. Please look at the "
 
218
                                 "doc/lirc/example.lirc file in VLC" );
217
219
                break;
218
220
            }
219
221
        }