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