#include "globals.h"
std::string datadir;
JoystickKeymap::JoystickKeymap()
{
a_button = 0;
b_button = 1;
start_button = 2;
x_axis = 0;
y_axis = 1;
dead_zone = 4096;
}
JoystickKeymap joystick_keymap;
SDL_Surface * screen;
Text* black_text;
Text* gold_text;
Text* silver_text;
Text* blue_text;
Text* red_text;
Text* green_text;
Text* yellow_nums;
Text* white_text;
Text* white_small_text;
Text* white_big_text;
MouseCursor * mouse_cursor;
bool use_gl;
bool use_joystick;
bool use_fullscreen;
bool debug_mode;
bool show_fps;
float game_speed = 1.0f;
int joystick_num = 0;
char* level_startup_file = 0;
bool launch_leveleditor_mode = false;
char *st_dir, *st_save_dir;
SDL_Joystick * js;
int wait_for_event(SDL_Event& event,unsigned int min_delay, unsigned int max_delay, bool empty_events)
{
int i;
Timer maxdelay;
Timer mindelay;
maxdelay.init(false);
mindelay.init(false);
if(max_delay < min_delay)
max_delay = min_delay;
maxdelay.start(max_delay);
mindelay.start(min_delay);
if(empty_events)
while (SDL_PollEvent(&event))
{}
for(i = 0; maxdelay.check() || !i; ++i)
{
while (SDL_PollEvent(&event))
{
if(!mindelay.check())
{
if (event.type == SDL_QUIT)
{
return 2;
}
else if (event.type == SDL_KEYDOWN)
{
return 1;
}
else if (event.type == SDL_JOYBUTTONDOWN)
{
return 1;
}
else if (event.type == SDL_MOUSEBUTTONDOWN)
{
return 1;
}
}
}
SDL_Delay(10);
}
return 0;
}