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
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.
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.
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 *****************************************************************************/
27 /*****************************************************************************
29 *****************************************************************************/
36 #include <sys/types.h> /* on BSD, uio.h needs types.h */
37 #include <sys/uio.h> /* for input.h */
47 #include "video_output.h"
49 #include "interface.h"
54 /*****************************************************************************
55 * intf_sys_t: description and status of GGI interface
56 *****************************************************************************/
57 typedef struct intf_sys_s
59 /* GGI system information */
60 ggi_visual_t p_display; /* display */
64 /*****************************************************************************
66 *****************************************************************************/
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 );
73 /*****************************************************************************
74 * intf_GGICreate: initialize and create GII interface
75 *****************************************************************************/
76 int intf_GGICreate( intf_thread_t *p_intf )
78 /* Check that b_video is set */
79 if( !p_main->b_video )
81 intf_ErrMsg("error: GGI interface require a video output thread\n");
85 /* Allocate instance and initialize some members */
86 p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
87 if( p_intf->p_sys == NULL )
89 intf_ErrMsg("error: %s\n", strerror(ENOMEM) );
93 /* Spawn video output thread */
94 p_intf->p_vout = vout_CreateThread( main_GetPszVariable( VOUT_DISPLAY_VAR,
96 main_GetIntVariable( VOUT_WIDTH_VAR,
98 main_GetIntVariable( VOUT_HEIGHT_VAR,
99 VOUT_HEIGHT_DEFAULT ),
101 (void *)&p_intf->p_sys->p_display );
103 if( p_intf->p_vout == NULL ) /* error */
105 intf_ErrMsg("error: can't create video output thread\n" );
106 free( p_intf->p_sys );
110 /* Assign basic keys */
111 intf_AssignNormalKeys( p_intf );
117 /*****************************************************************************
118 * intf_GGIDestroy: destroy interface
119 *****************************************************************************/
120 void intf_GGIDestroy( intf_thread_t *p_intf )
122 /* Close input thread, if any (blocking) */
123 if( p_intf->p_input )
125 input_DestroyThread( p_intf->p_input, NULL );
128 /* Close video output thread, if any (blocking) */
131 vout_DestroyThread( p_intf->p_vout, NULL );
134 /* Destroy structure */
135 free( p_intf->p_sys );
139 /*****************************************************************************
140 * intf_GGIManage: event loop
141 *****************************************************************************/
142 void intf_GGIManage( intf_thread_t *p_intf )
144 int i_key; /* unicode key */
146 /* For all events in queue */
147 while( ggiKbhit( p_intf->p_sys->p_display ) )
149 i_key = ggiGetc( p_intf->p_sys->p_display );
150 if( intf_ProcessKey( p_intf, i_key ) )
152 intf_DbgMsg("unhandled key '%c' (%i)\n", (char) i_key, i_key );