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