#include #include #include "display.h" GMainLoop *mainloop; static void handle_active(SDL_Event *event) { if (event->active.state & SDL_APPACTIVE && event->active.gain == 1 && tetringo_display_is_fullscreen()) { tetringo_display_redraw(); } } static gboolean sdl_event_handler(gpointer user_data) { SDL_Event event; Uint32 pre_event_time = SDL_GetTicks(); gboolean ignoring_motion = FALSE; tetringo_display_redraw(); while (SDL_PollEvent(&event)) { Uint32 cur_event_time = SDL_GetTicks(); if (cur_event_time > pre_event_time + 250) ignoring_motion = TRUE; if (event.type == SDL_QUIT) { g_main_loop_quit(mainloop); } else if (event.type == SDL_ACTIVEEVENT) { handle_active(&event); } else if (event.type == SDL_KEYDOWN) { SDLKey key = event.key.keysym.sym; /* SDLMod mod = event.key.keysym.mod; */ if (key == SDLK_ESCAPE || key == SDLK_F5 // Nokia 770 home key ) { g_main_loop_quit(mainloop); } } tetringo_display_handle_event(&event); } return TRUE; } int main(int argc, char **argv) { TetringoGameEngine *game_engine; g_type_init(); mainloop = g_main_loop_new(NULL, FALSE); game_engine = tetringo_game_engine_local_new(); tetringo_set_game_engine(game_engine); tetringo_display_init(game_engine); tetringo_game_engine_start(game_engine); g_idle_add(sdl_event_handler, NULL); g_main_loop_run(mainloop); tetringo_game_engine_stop(game_engine); return 0; }