use PhysicsFS for saving levels
[btb/d2x.git] / arch / sdl / event.c
1 /* $Id: event.c,v 1.12 2003-06-06 19:04:27 btb Exp $ */
2 /*
3  *
4  * SDL Event related stuff
5  *
6  *
7  */
8
9 #ifdef HAVE_CONFIG_H
10 #include <conf.h>
11 #endif
12
13 #include <stdio.h>
14 #include <stdlib.h>
15
16 #include <SDL.h>
17
18 extern void key_handler(SDL_KeyboardEvent *event);
19 extern void mouse_button_handler(SDL_MouseButtonEvent *mbe);
20 extern void mouse_motion_handler(SDL_MouseMotionEvent *mme);
21 #ifndef USE_LINUX_JOY // stpohle - so we can choose at compile time..
22 extern void joy_button_handler(SDL_JoyButtonEvent *jbe);
23 extern void joy_hat_handler(SDL_JoyHatEvent *jhe);
24 extern void joy_axis_handler(SDL_JoyAxisEvent *jae);
25 #endif
26
27 static int initialised=0;
28
29 void event_poll()
30 {
31         SDL_Event event;
32
33         while (SDL_PollEvent(&event)) {
34                 switch(event.type) {
35                 case SDL_KEYDOWN:
36                 case SDL_KEYUP:
37                         key_handler((SDL_KeyboardEvent *)&event);
38                         break;
39                 case SDL_MOUSEBUTTONDOWN:
40                 case SDL_MOUSEBUTTONUP:
41                         mouse_button_handler((SDL_MouseButtonEvent *)&event);
42                         break;
43                 case SDL_MOUSEMOTION:
44                         mouse_motion_handler((SDL_MouseMotionEvent *)&event);
45                         break;
46 #ifndef USE_LINUX_JOY       // stpohle - so we can choose at compile time..
47                 case SDL_JOYBUTTONDOWN:
48                 case SDL_JOYBUTTONUP:
49                         joy_button_handler((SDL_JoyButtonEvent *)&event);
50                         break;
51                 case SDL_JOYAXISMOTION:
52                         joy_axis_handler((SDL_JoyAxisEvent *)&event);
53                         break;
54                 case SDL_JOYHATMOTION:
55                         joy_hat_handler((SDL_JoyHatEvent *)&event);
56                         break;
57                 case SDL_JOYBALLMOTION:
58                         break;
59 #endif
60                 case SDL_QUIT: {
61                         void quit_request();
62                         quit_request();
63                 } break;
64                 }
65         }
66 }
67
68 int event_init()
69 {
70         // We should now be active and responding to events.
71         initialised = 1;
72
73         return 0;
74 }