]> git.sesse.net Git - vlc/blob - plugins/glide/intf_glide.c
The input-II. (more info by mail in about an hour)
[vlc] / plugins / glide / intf_glide.c
1 /*****************************************************************************
2  * intf_glide.c: 3dfx interface plugin
3  *****************************************************************************
4  * Copyright (C) 2000 VideoLAN
5  *
6  * Authors:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  * 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
21  *****************************************************************************/
22
23 /*****************************************************************************
24  * Preamble
25  *****************************************************************************/
26 #include "defs.h"
27
28 #include <stdlib.h>                                      /* malloc(), free() */
29 #include <sys/types.h>                        /* on BSD, uio.h needs types.h */
30 #include <sys/uio.h>                                          /* for input.h */
31 #include <linutil.h>                            /* Glide kbhit() and getch() */
32
33 #include "config.h"
34 #include "common.h"
35 #include "threads.h"
36 #include "mtime.h"
37 #include "plugins.h"
38
39 #include "stream_control.h"
40 #include "input_ext-intf.h"
41
42 #include "video.h"
43 #include "video_output.h"
44
45 #include "intf_msg.h"
46 #include "interface.h"
47
48 #include "main.h"
49
50 /*****************************************************************************
51  * intf_sys_t: description and status of 3dfx interface
52  *****************************************************************************/
53 typedef struct intf_sys_s
54 {
55
56 } intf_sys_t;
57
58 /*****************************************************************************
59  * intf_GlideCreate: initialize 3dfx interface
60  *****************************************************************************/
61 int intf_GlideCreate( intf_thread_t *p_intf )
62 {
63     /* Allocate instance and initialize some members */
64     p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
65     if( p_intf->p_sys == NULL )
66     {
67         return( 1 );
68     };
69
70     /* Spawn video output thread */
71     if( p_main->b_video )
72     {
73         p_intf->p_vout = vout_CreateThread( NULL, 0, 0, 0, NULL, 0, NULL );
74         if( p_intf->p_vout == NULL )                                /* error */
75         {
76             intf_ErrMsg("intf error: can't create output thread\n" );
77             return( 1 );
78         }
79     }
80     
81     /* bind keys */
82     intf_AssignNormalKeys( p_intf );
83
84     return( 0 );
85 }
86
87 /*****************************************************************************
88  * intf_GlideDestroy: destroy 3dfx interface
89  *****************************************************************************/
90 void intf_GlideDestroy( intf_thread_t *p_intf )
91 {
92     /* Close input thread, if any (blocking) */
93     if( p_intf->p_input )
94     {
95         input_DestroyThread( p_intf->p_input, NULL );
96     }
97
98     /* Close video output thread, if any (blocking) */
99     if( p_intf->p_vout )
100     {
101         vout_DestroyThread( p_intf->p_vout, NULL );
102     }
103
104     /* Destroy structure */
105     free( p_intf->p_sys );
106 }
107
108
109 /*****************************************************************************
110  * intf_GlideManage: event loop
111  *****************************************************************************/
112 void intf_GlideManage( intf_thread_t *p_intf )
113 {
114     unsigned int buf;
115
116     /* very Linux specific - see tlib.c in Glide for other versions */
117     while( kbhit() )
118     {
119         if( intf_ProcessKey(p_intf, (int)buf = getch()) )
120         {
121             intf_ErrMsg( "unhandled key '%c' (%i)\n", (char) buf, buf );
122         }
123     }
124 }
125