]> icculus.org git repositories - btb/d2x.git/blob - event.c
15c72690853129b0a6d69beaa2e812f203250b6c
[btb/d2x.git] / event.c
1 // SDL Event related stuff
2
3 #include <conf.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6
7 #include <SDL/SDL.h>
8
9 extern void key_handler(SDL_KeyboardEvent *event);
10 //added on 10/17/98 by Hans de Goede for mouse functionality
11 extern void mouse_button_handler(SDL_MouseButtonEvent *mbe);
12 extern void mouse_motion_handler(SDL_MouseMotionEvent *mme);
13 //end this section addition - Hans
14
15 static int initialised=0;
16
17 void event_poll()
18 {
19  SDL_Event event;
20  while (SDL_PollEvent(&event))
21  {
22 // if( (event.type == SDL_KEYEVENT) {
23 //added/changed on 10/17/98 by Hans de Goede for mouse functionality
24 //-killed-   if( (event.type == SDL_KEYDOWN) || (event.type == SDL_KEYUP) ) {
25    switch(event.type)
26    {
27     case SDL_KEYDOWN:
28     case SDL_KEYUP:
29      key_handler((SDL_KeyboardEvent *)&event);
30      break;
31     case SDL_MOUSEBUTTONDOWN:
32     case SDL_MOUSEBUTTONUP:
33      mouse_button_handler((SDL_MouseButtonEvent *)&event);
34      break;
35     case SDL_MOUSEMOTION:
36      mouse_motion_handler((SDL_MouseMotionEvent *)&event);
37      break;
38 //-killed-     return;
39 //end this section addition/change - Hans
40     case SDL_QUIT: {
41 //      void quit_request();
42 //      quit_request();
43     } break;
44    }
45  }
46 }
47
48 int event_init()
49 {
50  // We should now be active and responding to events.
51  initialised = 1;
52
53  return 0;
54 }