Revert some accidental cross-merge changes. Remove i915GetString. Migrate
[mesa.git] / src / glut / dos / callback.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 3.4
4 * Copyright (C) 1995-1998 Brian Paul
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 /*
22 * DOS/DJGPP glut driver v1.5 for Mesa
23 *
24 * Copyright (C) 2002 - Borca Daniel
25 * Email : dborca@yahoo.com
26 * Web : http://www.geocities.com/dborca
27 */
28
29
30 #include "glutint.h"
31
32
33
34 typedef struct {
35 void (*func) (int); /* function to call */
36 int value; /* value to pass to callback */
37 int ttl; /* time to live (blank shots) */
38 int fid; /* func-id as returned from PCHW */
39 } GLUTSShotCB;
40
41 GLUTidleCB g_idle_func = NULL;
42
43
44
45 static void g_single_shot_callback (void *opaque)
46 {
47 GLUTSShotCB *cb = (GLUTSShotCB *)opaque;
48 if (!--cb->ttl) {
49 cb->func(cb->value);
50 pc_remove_int(cb->fid);
51 /* We won't be needing this slot anymore, so free it. This operation
52 * must be the last thing, and must be atomic, to mutex `glutTimerFunc'
53 */
54 cb->func = NULL;
55 }
56 } ENDOFUNC(g_single_shot_callback)
57
58
59
60 void APIENTRY glutDisplayFunc (GLUTdisplayCB func)
61 {
62 g_curwin->display = func;
63 }
64
65
66
67 void APIENTRY glutReshapeFunc (GLUTreshapeCB func)
68 {
69 g_curwin->reshape = func;
70 }
71
72
73
74 void APIENTRY glutKeyboardFunc (GLUTkeyboardCB func)
75 {
76 g_curwin->keyboard = func;
77 }
78
79
80
81 void APIENTRY glutMouseFunc (GLUTmouseCB func)
82 {
83 g_curwin->mouse = func;
84 }
85
86
87
88 void APIENTRY glutMotionFunc (GLUTmotionCB func)
89 {
90 g_curwin->motion = func;
91 }
92
93
94
95 void APIENTRY glutPassiveMotionFunc (GLUTpassiveCB func)
96 {
97 g_curwin->passive = func;
98 }
99
100
101
102 void APIENTRY glutEntryFunc (GLUTentryCB func)
103 {
104 g_curwin->entry = func;
105 }
106
107
108
109 void APIENTRY glutVisibilityFunc (GLUTvisibilityCB func)
110 {
111 g_curwin->visibility = func;
112 }
113
114
115
116 void APIENTRY glutWindowStatusFunc (GLUTwindowStatusCB func)
117 {
118 }
119
120
121
122 void APIENTRY glutIdleFunc (GLUTidleCB func)
123 {
124 g_idle_func = func;
125 }
126
127
128
129 void APIENTRY glutTimerFunc (unsigned int millis, GLUTtimerCB func, int value)
130 {
131 static GLUTSShotCB g_sscb[MAX_SSHOT_CB];
132 static GLboolean virgin = GL_TRUE;
133
134 int i;
135 int ttl;
136 unsigned int freq;
137
138 if (virgin) {
139 virgin = GL_FALSE;
140 LOCKDATA(g_sscb);
141 LOCKFUNC(g_single_shot_callback);
142 /* we should lock the callee also... */
143 }
144
145 if (millis > 0) {
146 if (millis > 50) {
147 /* don't go beyond 20Hz */
148 freq = 200;
149 ttl = millis * freq / 1000;
150 } else {
151 freq = 1000 / millis;
152 ttl = 1;
153 }
154 for (i = 0; i < MAX_SSHOT_CB; i++) {
155 if (g_sscb[i].func == NULL) {
156 /* We will be needing this slot, so alloc it. This operation
157 * must be the first thing, and must be atomic, to mutex callbacks!
158 */
159 g_sscb[i].func = func;
160 g_sscb[i].value = value;
161 g_sscb[i].ttl = ttl;
162 /* There is a very small gap here: `pc_install_int' enables
163 * interrupts just before returning FID value (which will be
164 * used inside callback). The critical gap is 1 millisecond
165 * - which I'm sure we won't overrun...
166 */
167 g_sscb[i].fid = pc_install_int((PFUNC)func, &g_sscb[i], freq);
168 if (g_sscb[i].fid < 0) {
169 /* Interrupt could not be set! Release the slot back */
170 g_sscb[i].func = NULL;
171 }
172 break;
173 }
174 }
175 }
176 }
177
178
179
180 void APIENTRY glutSpecialFunc (GLUTspecialCB func)
181 {
182 g_curwin->special = func;
183 }
184
185
186
187 void APIENTRY glutSpaceballMotionFunc (GLUTspaceMotionCB func)
188 {
189 }
190
191
192
193 void APIENTRY glutSpaceballRotateFunc (GLUTspaceRotateCB func)
194 {
195 }
196
197
198
199 void APIENTRY glutSpaceballButtonFunc (GLUTspaceButtonCB func)
200 {
201 }
202
203
204
205 void APIENTRY glutDialsFunc (GLUTdialsCB func)
206 {
207 }
208
209
210
211 void APIENTRY glutButtonBoxFunc (GLUTbuttonBoxCB func)
212 {
213 }
214
215
216
217 void APIENTRY glutTabletMotionFunc (GLUTtabletMotionCB func)
218 {
219 }
220
221
222
223 void APIENTRY glutTabletButtonFunc (GLUTtabletButtonCB func)
224 {
225 }
226
227
228
229 void APIENTRY glutJoystickFunc (GLUTjoystickCB func, int interval)
230 {
231 }