diff --git a/include/video.h b/include/video.h index 9caa2bef..c586b796 100644 --- a/include/video.h +++ b/include/video.h @@ -62,5 +62,9 @@ void GFX_SwitchFullScreen(void); bool GFX_StartUpdate(Bit8u * & pixels,Bitu & pitch); void GFX_EndUpdate(void); +/* Mouse related */ +void GFX_CaptureMouse(void); +extern bool mouselocked; //true if mouse is confined to window + #endif diff --git a/src/gui/sdl_mapper.cpp b/src/gui/sdl_mapper.cpp index c5204be3..e6444e56 100644 --- a/src/gui/sdl_mapper.cpp +++ b/src/gui/sdl_mapper.cpp @@ -44,7 +44,7 @@ enum { enum BB_Types { BB_Next,BB_Prev,BB_Add,BB_Del, - BB_Save,BB_Reset + BB_Save,BB_Reset,BB_Exit }; enum BC_Types { @@ -554,6 +554,7 @@ public: switch (type) { case BB_Add: mapper.addbind=true; + SetActiveBind(0); break; case BB_Del: if (mapper.abindit!=mapper.aevent->bindlist.end()) { @@ -568,13 +569,16 @@ public: case BB_Next: if (mapper.abindit!=mapper.aevent->bindlist.end()) mapper.abindit++; - if (mapper.abindit==mapper.aevent->bindlist.end()) + if (mapper.abindit==mapper.aevent->bindlist.end()) mapper.abindit=mapper.aevent->bindlist.begin(); SetActiveBind(*(mapper.abindit)); break; case BB_Save: MAPPER_SaveBinds(); break; + case BB_Exit: + mapper.exit=true; + break; } } protected: @@ -735,6 +739,7 @@ struct { CCaptionButton * selected; CCaptionButton * action; CBindButton * save; + CBindButton * exit; CBindButton * add; CBindButton * del; CBindButton * next; @@ -977,6 +982,7 @@ static void CreateLayout(void) { bind_but.del=new CBindButton(300,380,50,20,"Del",BB_Del); bind_but.save=new CBindButton(400,450,50,20,"Save",BB_Save); + bind_but.exit=new CBindButton(450,450,50,20,"Exit",BB_Exit); bind_but.bind_title->Change("Bind Title"); } @@ -1156,6 +1162,13 @@ void MAPPER_Run(void) { for (CEventVector_it evit=events.begin();evit!=events.end();evit++) { (*evit)->DeActivateAll(); } + + bool mousetoggle=false; + if(mouselocked) { + mousetoggle=true; + GFX_CaptureMouse(); + } + mapper.surface=SDL_SetVideoMode(640,480,8,0); /* Set some palette entries */ SDL_SetPalette(mapper.surface, SDL_LOGPAL|SDL_PHYSPAL, map_pal, 0, 4); @@ -1171,6 +1184,7 @@ void MAPPER_Run(void) { BIND_MappingEvents(); SDL_Delay(1); } + if(mousetoggle) GFX_CaptureMouse(); GFX_ResetScreen(); } diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index e02e4525..9ed5448c 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: sdlmain.cpp,v 1.66 2004-06-10 07:18:19 harekiet Exp $ */ +/* $Id: sdlmain.cpp,v 1.67 2004-06-13 12:10:08 qbix79 Exp $ */ #ifndef _GNU_SOURCE #define _GNU_SOURCE @@ -440,7 +440,7 @@ dosurface: return sdl.draw.mode; } - +bool mouselocked; //Global variable for mapper static void CaptureMouse(void) { sdl.mouse.locked=!sdl.mouse.locked; if (sdl.mouse.locked) { @@ -450,6 +450,11 @@ static void CaptureMouse(void) { SDL_WM_GrabInput(SDL_GRAB_OFF); SDL_ShowCursor(SDL_ENABLE); } + mouselocked=sdl.mouse.locked; +} + +void GFX_CaptureMouse(void) { + CaptureMouse(); } static void SwitchFullScreen(void) { @@ -590,6 +595,7 @@ static void GUI_StartUp(Section * sec) { sdl.desktop.fullscreen=section->Get_bool("fullscreen"); sdl.wait_on_error=section->Get_bool("waitonerror"); sdl.mouse.locked=false; + mouselocked=false; //Global for mapper sdl.mouse.requestlock=false; sdl.desktop.fixed=section->Get_bool("fullfixed"); sdl.desktop.width=section->Get_int("fullwidth");