enabled linux joystick
[btb/d2x.git] / arch / sdl / event.c
1 /* $Id: event.c,v 1.7 2003-01-01 00:55:03 btb Exp $ */
2
3 /*
4  *
5  * SDL Event related stuff
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/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_axis_handler(SDL_JoyAxisEvent *jae);
24 #endif
25
26 static int initialised=0;
27
28 void event_poll()
29 {
30         SDL_Event event;
31
32         while (SDL_PollEvent(&event)) {
33                 switch(event.type) {
34                 case SDL_KEYDOWN:
35                 case SDL_KEYUP:
36                         key_handler((SDL_KeyboardEvent *)&event);
37                         break;
38                 case SDL_MOUSEBUTTONDOWN:
39                 case SDL_MOUSEBUTTONUP:
40                         mouse_button_handler((SDL_MouseButtonEvent *)&event);
41                         break;
42                 case SDL_MOUSEMOTION:
43                         mouse_motion_handler((SDL_MouseMotionEvent *)&event);
44                         break;
45 #ifndef USE_LINUX_JOY       // stpohle - so we can choose at compile time..
46                 case SDL_JOYBUTTONDOWN:
47                 case SDL_JOYBUTTONUP:
48                         joy_button_handler((SDL_JoyButtonEvent *)&event);
49                         break;
50                 case SDL_JOYAXISMOTION:
51                         joy_axis_handler((SDL_JoyAxisEvent *)&event);
52                         break;
53                 case SDL_JOYBALLMOTION:
54                 case SDL_JOYHATMOTION:
55                         break;
56 #endif
57                 case SDL_QUIT: {
58                         void quit_request();
59                         quit_request();
60                 } break;
61                 }
62         }
63 }
64
65 int event_init()
66 {
67         // We should now be active and responding to events.
68         initialised = 1;
69
70         return 0;
71 }