From cbb8340d3b139596e94f2caa3ca51577d8fa3d0e Mon Sep 17 00:00:00 2001 From: pixel Date: Tue, 21 Jan 2003 01:50:58 +0000 Subject: Fixed a bit the SDL code... --- lib/engine.cc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'lib/engine.cc') diff --git a/lib/engine.cc b/lib/engine.cc index 84014c7..d065346 100644 --- a/lib/engine.cc +++ b/lib/engine.cc @@ -13,6 +13,8 @@ int mogltk::engine::setup() throw(GeneralException) { throw GeneralException(_("Unable to start SDL base system")); } atexit(SDL_Quit); + + SDL_ShowCursor(0); inited = 1; @@ -87,3 +89,39 @@ SDL_RWops * mogltk::engine::RWFromHandle(Handle * h) throw (GeneralException) { } return r; } + +void mogltk::engine::pollevents() { + SDL_Event event; + + while(true) { + SDL_WaitEvent(&event); + switch(event.type) { + case SDL_VIDEOEXPOSE: + printm(M_INFO, "Needs to redraw\n"); + return; + case SDL_MOUSEMOTION: + printm(M_INFO, "Mouse has gone over the screen - (%i, %i)\n", event.motion.x, event.motion.y); + break; + case SDL_QUIT: + printm(M_INFO, "Quit requested\n"); + exit(0); + break; + case SDL_ACTIVEEVENT: + switch (event.active.state) { + case SDL_APPMOUSEFOCUS: + printm(M_INFO, String("Application ") + (event.active.gain ? "gained" : "loosed") + " mouse focus\n"); + break; + case SDL_APPINPUTFOCUS: + printm(M_INFO, String("Application ") + (event.active.gain ? "gained" : "loosed") + " input focus\n"); + break; + case SDL_APPACTIVE: + printm(M_INFO, String("Application was ") + (event.active.gain ? "restored" : "iconified")); + break; + } + break; + default: + printm(M_INFO, "Unknow event: %i\n", event.type); + break; + } + } +} -- cgit v1.2.3