added timer_delay, faster timer_get_fixed_seconds
[btb/d2x.git] / arch / sdl / event.c
1 /*
2  * $Source: /cvs/cvsroot/d2x/arch/sdl/event.c,v $
3  * $Revision: 1.6 $
4  * $Author: bradleyb $
5  * $Date: 2002-07-16 22:37:14 $
6  *
7  * SDL Event related stuff
8  *
9  * $Log: not supported by cvs2svn $
10  * Revision 1.5  2002/02/16 02:08:30  bradleyb
11  * allow older sdl versions
12  *
13  * Revision 1.4  2001/12/03 02:43:02  bradleyb
14  * lots of makefile fixes, and sdl joystick stuff
15  *
16  * Revision 1.3  2001/11/14 10:43:10  bradleyb
17  * remove cruft, fix formatting, begin joystick stuff
18  *
19  * Revision 1.2  2001/10/31 07:41:54  bradleyb
20  * Sync with d1x
21  *
22  * Revision 1.1  2001/10/24 09:25:05  bradleyb
23  * Moved input stuff to arch subdirs, as in d1x.
24  *
25  * Revision 1.2  2001/01/29 14:03:57  bradleyb
26  * Fixed build, minor fixes
27  *
28  */
29
30 #ifdef HAVE_CONFIG_H
31 #include <conf.h>
32 #endif
33
34 #include <stdio.h>
35 #include <stdlib.h>
36
37 #include <SDL/SDL.h>
38
39 extern void key_handler(SDL_KeyboardEvent *event);
40 extern void mouse_button_handler(SDL_MouseButtonEvent *mbe);
41 extern void mouse_motion_handler(SDL_MouseMotionEvent *mme);
42 extern void joy_button_handler(SDL_JoyButtonEvent *jbe);
43 extern void joy_axis_handler(SDL_JoyAxisEvent *jae);
44
45 static int initialised=0;
46
47 void event_poll()
48 {
49         SDL_Event event;
50
51         while (SDL_PollEvent(&event)) {
52                 switch(event.type) {
53                 case SDL_KEYDOWN:
54                 case SDL_KEYUP:
55                         key_handler((SDL_KeyboardEvent *)&event);
56                         break;
57                 case SDL_MOUSEBUTTONDOWN:
58                 case SDL_MOUSEBUTTONUP:
59                         mouse_button_handler((SDL_MouseButtonEvent *)&event);
60                         break;
61                 case SDL_MOUSEMOTION:
62                         mouse_motion_handler((SDL_MouseMotionEvent *)&event);
63                         break;
64                 case SDL_JOYBUTTONDOWN:
65                 case SDL_JOYBUTTONUP:
66                         joy_button_handler((SDL_JoyButtonEvent *)&event);
67                         break;
68                 case SDL_JOYAXISMOTION:
69                         joy_axis_handler((SDL_JoyAxisEvent *)&event);
70                         break;
71                 case SDL_JOYBALLMOTION:
72                 case SDL_JOYHATMOTION:
73                         break;
74                 case SDL_QUIT: {
75                         void quit_request();
76                         quit_request();
77                 } break;
78                 }
79         }
80 }
81
82 int event_init()
83 {
84         // We should now be active and responding to events.
85         initialised = 1;
86
87         return 0;
88 }