]> git.sesse.net Git - vlc/blob - plugins/ggi/intf_ggi.c
. autod�tection des plugins
[vlc] / plugins / ggi / intf_ggi.c
1 /*****************************************************************************
2  * intf_ggi.c: GGI interface plugin
3  * Since GII doesnt seem to work well for keyboard events, the GGI display is
4  * used, and therefore the GII interface can't be spawned without a video output
5  * thread. It also needs a kludge to get the visual from the video output GGI
6  * driver.
7  *****************************************************************************
8  * Copyright (C) 1999, 2000 VideoLAN
9  *
10  * Authors:
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  * 
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
25  *****************************************************************************/
26
27 /*****************************************************************************
28  * Preamble
29  *****************************************************************************/
30 #include "defs.h"
31
32 #include <errno.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <ggi/ggi.h>
36 #include <sys/types.h>                        /* on BSD, uio.h needs types.h */
37 #include <sys/uio.h>                                          /* for input.h */
38
39 #include "config.h"
40 #include "common.h"
41 #include "threads.h"
42 #include "mtime.h"
43 #include "plugins.h"
44
45 #include "input.h"
46 #include "video.h"
47 #include "video_output.h"
48
49 #include "interface.h"
50 #include "intf_msg.h"
51
52 #include "main.h"
53
54 /*****************************************************************************
55  * intf_sys_t: description and status of GGI interface
56  *****************************************************************************/
57 typedef struct intf_sys_s
58 {
59     /* GGI system information */
60     ggi_visual_t                 p_display;                       /* display */
61
62 } intf_sys_t;
63
64 /*****************************************************************************
65  * External prototypes
66  *****************************************************************************/
67
68 /* vout_SysGetVisual: get back visual from video output thread - in video_ggi.c
69  * This function is used to get back the display pointer once the video output
70  * thread has been spawned. */
71 ggi_visual_t    vout_SysGetVisual( vout_thread_t *p_vout );
72
73 /*****************************************************************************
74  * intf_GGICreate: initialize and create GII interface
75  *****************************************************************************/
76 int intf_GGICreate( intf_thread_t *p_intf )
77 {
78     /* Check that b_video is set */
79     if( !p_main->b_video )
80     {
81         intf_ErrMsg("error: GGI interface require a video output thread\n");
82         return( 1 );
83     }
84
85     /* Allocate instance and initialize some members */
86     p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
87     if( p_intf->p_sys == NULL )
88     {
89         intf_ErrMsg("error: %s\n", strerror(ENOMEM) );
90         return( 1 );
91     }
92
93     /* Spawn video output thread */
94     p_intf->p_vout = vout_CreateThread( main_GetPszVariable( VOUT_DISPLAY_VAR,
95                                                              NULL), 0,
96                                         main_GetIntVariable( VOUT_WIDTH_VAR,
97                                                          VOUT_WIDTH_DEFAULT ),
98                                         main_GetIntVariable( VOUT_HEIGHT_VAR,
99                                                         VOUT_HEIGHT_DEFAULT ),
100                                         NULL, 0,
101                                         (void *)&p_intf->p_sys->p_display );
102
103     if( p_intf->p_vout == NULL )                                  /* error */
104     {
105         intf_ErrMsg("error: can't create video output thread\n" );
106         free( p_intf->p_sys );
107         return( 1 );
108     }
109
110     return( 0 );
111 }
112
113 /*****************************************************************************
114  * intf_GGIDestroy: destroy interface
115  *****************************************************************************/
116 void intf_GGIDestroy( intf_thread_t *p_intf )
117 {
118     /* Close input thread, if any (blocking) */
119     if( p_intf->p_input )
120     {
121         input_DestroyThread( p_intf->p_input, NULL );
122     }
123
124     /* Close video output thread, if any (blocking) */
125     if( p_intf->p_vout )
126     {
127         vout_DestroyThread( p_intf->p_vout, NULL );
128     }
129
130     /* Destroy structure */
131     free( p_intf->p_sys );
132 }
133
134
135 /*****************************************************************************
136  * intf_GGIManage: event loop
137  *****************************************************************************/
138 void intf_GGIManage( intf_thread_t *p_intf )
139 {
140     int         i_key;                                        /* unicode key */
141
142     /* For all events in queue */
143     while( ggiKbhit( p_intf->p_sys->p_display ) )
144     {
145         i_key = ggiGetc( p_intf->p_sys->p_display );
146         if( intf_ProcessKey( p_intf, i_key ) )
147         {
148             intf_DbgMsg("unhandled key '%c' (%i)\n", (char) i_key, i_key );
149         }
150     }
151 }
152
153
154