]> icculus.org git repositories - btb/d2x.git/blob - arch/sdl/event.c
Sync with d1x
[btb/d2x.git] / arch / sdl / event.c
1 /*
2  * $Source: /cvs/cvsroot/d2x/arch/sdl/event.c,v $
3  * $Revision: 1.2 $
4  * $Author: bradleyb $
5  * $Date: 2001-10-31 07:41:54 $
6  *
7  * SDL Event related stuff
8  *
9  * $Log: not supported by cvs2svn $
10  * Revision 1.1  2001/10/24 09:25:05  bradleyb
11  * Moved input stuff to arch subdirs, as in d1x.
12  *
13  * Revision 1.2  2001/01/29 14:03:57  bradleyb
14  * Fixed build, minor fixes
15  *
16  */
17
18 #ifdef HAVE_CONFIG_H
19 #include <conf.h>
20 #endif
21
22 #include <stdio.h>
23 #include <stdlib.h>
24
25 #include <SDL/SDL.h>
26
27 extern void key_handler(SDL_KeyboardEvent *event);
28 //added on 10/17/98 by Hans de Goede for mouse functionality
29 extern void mouse_button_handler(SDL_MouseButtonEvent *mbe);
30 extern void mouse_motion_handler(SDL_MouseMotionEvent *mme);
31 //end this section addition - Hans
32
33 static int initialised=0;
34
35 void event_poll()
36 {
37  SDL_Event event;
38  while (SDL_PollEvent(&event))
39  {
40 // if( (event.type == SDL_KEYEVENT) {
41 //added/changed on 10/17/98 by Hans de Goede for mouse functionality
42 //-killed-   if( (event.type == SDL_KEYDOWN) || (event.type == SDL_KEYUP) ) {
43    switch(event.type)
44    {
45     case SDL_KEYDOWN:
46     case SDL_KEYUP:
47      key_handler((SDL_KeyboardEvent *)&event);
48      break;
49     case SDL_MOUSEBUTTONDOWN:
50     case SDL_MOUSEBUTTONUP:
51      mouse_button_handler((SDL_MouseButtonEvent *)&event);
52      break;
53     case SDL_MOUSEMOTION:
54      mouse_motion_handler((SDL_MouseMotionEvent *)&event);
55      break;
56 //-killed-     return;
57 //end this section addition/change - Hans
58     case SDL_QUIT: {
59         void quit_request();
60         quit_request();
61     } break;
62    }
63  }
64 }
65
66 int event_init()
67 {
68  // We should now be active and responding to events.
69  initialised = 1;
70
71  return 0;
72 }