2003-01-15 02:42:41 +00:00
|
|
|
/* $Id: event.c,v 1.8 2003-01-15 02:42:41 btb Exp $ */
|
2001-01-29 14:03:57 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* SDL Event related stuff
|
|
|
|
*
|
2003-01-15 02:42:41 +00:00
|
|
|
*
|
2001-01-29 14:03:57 +00:00
|
|
|
*/
|
2001-01-19 03:34:09 +00:00
|
|
|
|
2001-01-29 14:03:57 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2001-01-19 03:34:09 +00:00
|
|
|
#include <conf.h>
|
2001-01-29 14:03:57 +00:00
|
|
|
#endif
|
2001-01-19 03:34:09 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2003-01-15 02:42:41 +00:00
|
|
|
#include <SDL.h>
|
2001-01-19 03:34:09 +00:00
|
|
|
|
|
|
|
extern void key_handler(SDL_KeyboardEvent *event);
|
|
|
|
extern void mouse_button_handler(SDL_MouseButtonEvent *mbe);
|
|
|
|
extern void mouse_motion_handler(SDL_MouseMotionEvent *mme);
|
2003-01-01 00:55:03 +00:00
|
|
|
#ifndef USE_LINUX_JOY // stpohle - so we can choose at compile time..
|
2001-12-03 02:43:02 +00:00
|
|
|
extern void joy_button_handler(SDL_JoyButtonEvent *jbe);
|
|
|
|
extern void joy_axis_handler(SDL_JoyAxisEvent *jae);
|
2003-01-01 00:55:03 +00:00
|
|
|
#endif
|
2001-01-19 03:34:09 +00:00
|
|
|
|
|
|
|
static int initialised=0;
|
|
|
|
|
|
|
|
void event_poll()
|
|
|
|
{
|
2001-11-14 10:43:10 +00:00
|
|
|
SDL_Event event;
|
|
|
|
|
|
|
|
while (SDL_PollEvent(&event)) {
|
|
|
|
switch(event.type) {
|
|
|
|
case SDL_KEYDOWN:
|
|
|
|
case SDL_KEYUP:
|
|
|
|
key_handler((SDL_KeyboardEvent *)&event);
|
|
|
|
break;
|
|
|
|
case SDL_MOUSEBUTTONDOWN:
|
|
|
|
case SDL_MOUSEBUTTONUP:
|
|
|
|
mouse_button_handler((SDL_MouseButtonEvent *)&event);
|
|
|
|
break;
|
|
|
|
case SDL_MOUSEMOTION:
|
|
|
|
mouse_motion_handler((SDL_MouseMotionEvent *)&event);
|
|
|
|
break;
|
2003-01-01 00:55:03 +00:00
|
|
|
#ifndef USE_LINUX_JOY // stpohle - so we can choose at compile time..
|
2001-11-14 10:43:10 +00:00
|
|
|
case SDL_JOYBUTTONDOWN:
|
|
|
|
case SDL_JOYBUTTONUP:
|
|
|
|
joy_button_handler((SDL_JoyButtonEvent *)&event);
|
|
|
|
break;
|
|
|
|
case SDL_JOYAXISMOTION:
|
2001-12-03 02:43:02 +00:00
|
|
|
joy_axis_handler((SDL_JoyAxisEvent *)&event);
|
2001-11-14 10:43:10 +00:00
|
|
|
break;
|
|
|
|
case SDL_JOYBALLMOTION:
|
|
|
|
case SDL_JOYHATMOTION:
|
|
|
|
break;
|
2003-01-01 00:55:03 +00:00
|
|
|
#endif
|
2001-11-14 10:43:10 +00:00
|
|
|
case SDL_QUIT: {
|
|
|
|
void quit_request();
|
|
|
|
quit_request();
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
2001-01-19 03:34:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int event_init()
|
|
|
|
{
|
2001-11-14 10:43:10 +00:00
|
|
|
// We should now be active and responding to events.
|
|
|
|
initialised = 1;
|
2001-01-19 03:34:09 +00:00
|
|
|
|
2001-11-14 10:43:10 +00:00
|
|
|
return 0;
|
2001-01-19 03:34:09 +00:00
|
|
|
}
|