2 * Copyright (C) 2006 Claudio Ciccani <klan@users.sf.net>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 glutGetModifiers( void )
31 return g_current
->modifiers
;
37 glutIgnoreKeyRepeat( int ignore
)
43 glutSetKeyRepeat( int mode
)
49 glutForceJoystickFunc( void )
51 if (g_game
&& joystick
&& joystick_func
) {
52 joystick_func( g_game
->buttons
,
53 g_game
->cx
, g_game
->cy
, g_game
->cz
);
59 __glutSpecialKey( DFBInputDeviceKeySymbol key
)
86 case DIKS_CURSOR_LEFT
:
90 case DIKS_CURSOR_RIGHT
:
91 return GLUT_KEY_RIGHT
;
92 case DIKS_CURSOR_DOWN
:
95 return GLUT_KEY_PAGE_UP
;
97 return GLUT_KEY_PAGE_DOWN
;
103 return GLUT_KEY_INSERT
;
113 __glutButton( DFBInputDeviceButtonIdentifier button
)
117 return GLUT_LEFT_BUTTON
;
119 return GLUT_MIDDLE_BUTTON
;
121 return GLUT_RIGHT_BUTTON
;
131 __glutModifiers( DFBInputDeviceModifierMask mask
)
133 return ((mask
& DIMM_SHIFT
) ? GLUT_ACTIVE_SHIFT
: 0) |
134 ((mask
& DIMM_CONTROL
) ? GLUT_ACTIVE_CTRL
: 0) |
135 ((mask
& DIMM_ALT
) ? GLUT_ACTIVE_ALT
: 0);
140 __glutWindowEvent( DFBWindowEvent
*e
)
142 __GlutWindow
*window
;
144 window
= __glutFindWindow( e
->window_id
);
145 if (!window
) /* window was destroyed */
150 window
->modifiers
= __glutModifiers( e
->modifiers
);
151 if (DFB_KEY_IS_ASCII( e
->key_symbol
)) {
153 __glutSetWindow( window
);
154 keyboard_func( e
->key_symbol
, e
->x
, e
->y
);
158 int key
= __glutSpecialKey( e
->key_symbol
);
159 if (key
&& special_func
) {
160 __glutSetWindow( window
);
161 special_func( key
, e
->x
, e
->y
);
166 window
->modifiers
= __glutModifiers( e
->modifiers
);
167 if (DFB_KEY_IS_ASCII( e
->key_symbol
)) {
168 if (keyboard_up_func
) {
169 __glutSetWindow( window
);
170 keyboard_up_func( e
->key_symbol
, e
->x
, e
->y
);
174 int key
= __glutSpecialKey( e
->key_symbol
);
175 if (key
&& special_up_func
) {
176 __glutSetWindow( window
);
177 special_up_func( key
, e
->x
, e
->y
);
181 case DWET_BUTTONDOWN
:
183 __glutSetWindow( window
);
184 mouse_func( __glutButton( e
->button
), GLUT_DOWN
, e
->x
, e
->y
);
189 __glutSetWindow( window
);
190 mouse_func( __glutButton( e
->button
), GLUT_UP
, e
->x
, e
->y
);
196 __glutSetWindow( window
);
197 motion_func( e
->cx
, e
->cy
);
201 if (passive_motion_func
) {
202 __glutSetWindow( window
);
203 passive_motion_func( e
->cx
, e
->cy
);
209 __glutSetWindow( window
);
210 entry_func( GLUT_ENTERED
);
215 __glutSetWindow( window
);
216 entry_func( GLUT_LEFT
);
220 window
->reshape
= GL_TRUE
;
221 window
->redisplay
= GL_TRUE
;
230 __glutInputEvent( DFBInputEvent
*e
)
232 __glutAssert( g_game
!= NULL
);
236 g_game
->modifiers
= __glutModifiers( e
->modifiers
);
237 if (DFB_KEY_IS_ASCII( e
->key_symbol
)) {
239 __glutSetWindow( g_game
);
240 keyboard_func( e
->key_symbol
, g_game
->cx
, g_game
->cy
);
244 int key
= __glutSpecialKey( e
->key_symbol
);
245 if (key
&& special_func
) {
246 __glutSetWindow( g_game
);
247 special_func( key
, g_game
->cx
, g_game
->cy
);
251 case DIET_KEYRELEASE
:
252 g_game
->modifiers
= __glutModifiers( e
->modifiers
);
253 if (DFB_KEY_IS_ASCII( e
->key_symbol
)) {
254 if (keyboard_up_func
) {
255 __glutSetWindow( g_game
);
256 keyboard_up_func( e
->key_symbol
, g_game
->cx
, g_game
->cy
);
260 int key
= __glutSpecialKey( e
->key_symbol
);
261 if (key
&& special_up_func
) {
262 __glutSetWindow( g_game
);
263 special_up_func( key
, g_game
->cx
, g_game
->cy
);
267 case DIET_BUTTONPRESS
:
268 if (e
->device_id
== DIDID_JOYSTICK
) {
269 g_game
->buttons
= e
->buttons
;
271 __glutSetWindow( g_game
);
272 joystick_func( g_game
->buttons
,
273 g_game
->cx
, g_game
->cy
, g_game
->cz
);
278 __glutSetWindow( g_game
);
279 mouse_func( __glutButton( e
->button
),
280 GLUT_DOWN
, g_game
->cx
, g_game
->cy
);
284 case DIET_BUTTONRELEASE
:
285 if (e
->device_id
== DIDID_JOYSTICK
) {
286 g_game
->buttons
= e
->buttons
;
288 __glutSetWindow( g_game
);
289 joystick_func( g_game
->buttons
,
290 g_game
->cx
, g_game
->cy
, g_game
->cz
);
295 __glutSetWindow( g_game
);
296 mouse_func( __glutButton( e
->button
),
297 GLUT_UP
, g_game
->cx
, g_game
->cy
);
301 case DIET_AXISMOTION
:
304 if (e
->flags
& DIEF_AXISABS
)
305 g_game
->cx
= e
->axisabs
;
306 else if (e
->flags
& DIEF_AXISREL
)
307 g_game
->cx
+= e
->axisrel
;
310 if (e
->flags
& DIEF_AXISABS
)
311 g_game
->cy
= e
->axisabs
;
312 else if (e
->flags
& DIEF_AXISREL
)
313 g_game
->cy
+= e
->axisrel
;
316 if (e
->flags
& DIEF_AXISABS
)
317 g_game
->cz
= e
->axisabs
;
318 else if (e
->flags
& DIEF_AXISREL
)
319 g_game
->cz
+= e
->axisrel
;
324 if (e
->device_id
== DIDID_JOYSTICK
) {
326 __glutSetWindow( g_game
);
327 joystick_func( g_game
->buttons
,
328 g_game
->cx
, g_game
->cy
, g_game
->cz
);
331 else if (e
->axis
!= DIAI_Z
) {
332 if (e
->buttons
&& motion_func
) {
333 __glutSetWindow( g_game
);
334 motion_func( g_game
->cx
, g_game
->cy
);
336 else if (!e
->buttons
&& passive_motion_func
) {
337 __glutSetWindow( g_game
);
338 passive_motion_func( g_game
->cx
, g_game
->cy
);
351 __glutAssert( events
!= NULL
);
358 __glutHandleTimers();
359 __glutHandleWindows();
361 while (events
->GetEvent( events
, &evt
) == DFB_OK
) {
364 if (evt
.clazz
== DFEC_WINDOW
)
365 __glutWindowEvent( &evt
.window
);
367 __glutInputEvent( &evt
.input
);
369 __glutHandleTimers();
377 __glutSetWindow( NULL
);