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
7 *****************************************************************************
8 * Copyright (C) 1999, 2000 VideoLAN
9 * $Id: intf_ggi.c,v 1.7 2001/01/05 18:46:43 massiot Exp $
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
26 *****************************************************************************/
28 /*****************************************************************************
30 *****************************************************************************/
44 #include "stream_control.h"
45 #include "input_ext-intf.h"
48 #include "video_output.h"
50 #include "interface.h"
55 /*****************************************************************************
56 * intf_sys_t: description and status of GGI interface
57 *****************************************************************************/
58 typedef struct intf_sys_s
60 /* GGI system information */
61 ggi_visual_t p_display; /* display */
65 /*****************************************************************************
67 *****************************************************************************/
69 /* vout_SysGetVisual: get back visual from video output thread - in video_ggi.c
70 * This function is used to get back the display pointer once the video output
71 * thread has been spawned. */
72 ggi_visual_t vout_SysGetVisual( vout_thread_t *p_vout );
74 /*****************************************************************************
75 * intf_GGICreate: initialize and create GII interface
76 *****************************************************************************/
77 int intf_GGICreate( intf_thread_t *p_intf )
79 /* Check that b_video is set */
80 if( !p_main->b_video )
82 intf_ErrMsg("error: GGI interface require a video output thread");
86 /* Allocate instance and initialize some members */
87 p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
88 if( p_intf->p_sys == NULL )
90 intf_ErrMsg("error: %s", strerror(ENOMEM) );
94 /* Spawn video output thread */
95 p_intf->p_vout = vout_CreateThread( main_GetPszVariable( VOUT_DISPLAY_VAR,
97 main_GetIntVariable( VOUT_WIDTH_VAR,
99 main_GetIntVariable( VOUT_HEIGHT_VAR,
100 VOUT_HEIGHT_DEFAULT ),
102 (void *)&p_intf->p_sys->p_display );
104 if( p_intf->p_vout == NULL ) /* error */
106 intf_ErrMsg("error: can't create video output thread" );
107 free( p_intf->p_sys );
111 /* Assign basic keys */
112 intf_AssignNormalKeys( p_intf );
118 /*****************************************************************************
119 * intf_GGIDestroy: destroy interface
120 *****************************************************************************/
121 void intf_GGIDestroy( intf_thread_t *p_intf )
123 /* Close input thread, if any (blocking) */
124 if( p_intf->p_input )
126 input_DestroyThread( p_intf->p_input, NULL );
129 /* Close video output thread, if any (blocking) */
132 vout_DestroyThread( p_intf->p_vout, NULL );
135 /* Destroy structure */
136 free( p_intf->p_sys );
140 /*****************************************************************************
141 * intf_GGIManage: event loop
142 *****************************************************************************/
143 void intf_GGIManage( intf_thread_t *p_intf )
145 int i_key; /* unicode key */
147 /* For all events in queue */
148 while( ggiKbhit( p_intf->p_sys->p_display ) )
150 i_key = ggiGetc( p_intf->p_sys->p_display );
151 if( intf_ProcessKey( p_intf, i_key ) )
153 intf_DbgMsg("unhandled key '%c' (%i)", (char) i_key, i_key );