From: Oliver O. <fr...@us...> - 2007-06-17 13:39:37
|
Update of /cvsroot/simspark/simspark/spark/plugin/inputsdl In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv21072/plugin/inputsdl Modified Files: inputsystemsdl.cpp Log Message: merge from projectx branch Index: inputsystemsdl.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/inputsdl/inputsystemsdl.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** inputsystemsdl.cpp 8 Jan 2006 14:06:59 -0000 1.3 --- inputsystemsdl.cpp 17 Jun 2007 13:38:33 -0000 1.4 *************** *** 26,29 **** --- 26,30 ---- #include <zeitgeist/logserver/logserver.h> #include <SDL/SDL_thread.h> + #include <SDL/SDL_syswm.h> #include "timersdl.h" *************** *** 80,89 **** // input is part of the video subsystem (because of event loops, etc..) if (!SDL_WasInit(SDL_INIT_VIDEO)) { ! GetLog()->Error() ! << "ERROR: (InputSystemSDL) SDL not initialized!" ! << std::endl; return false; } // we need a mutex object --- 81,107 ---- // input is part of the video subsystem (because of event loops, etc..) if (!SDL_WasInit(SDL_INIT_VIDEO)) + { + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) { ! GetLog()->Error() << "ERROR: (InputSystemSDL) SDL not initialized!\n"; return false; } + SDL_SetVideoMode(0,0,0,0); + static SDL_SysWMinfo pInfo; + SDL_VERSION(&pInfo.version); + SDL_GetWMInfo(&pInfo); + + // Also, SDL keeps an internal record of the window size + // and position. Because SDL does not own the window, it + // missed the WM_POSCHANGED message and has no record of + // either size or position. It defaults to {0, 0, 0, 0}, + // which is then used to trap the mouse "inside the + // window". We have to fake a window-move to allow SDL + // to catch up, after which we can safely grab input. + // RECT r; + // GetWindowRect(pInfo.window, &r); + // SetWindowPos(pInfo.window, 0, r.left, r.top, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + SDL_WM_GrabInput(SDL_GRAB_ON); + } // we need a mutex object *************** *** 177,181 **** bool ret = InputSystem::GetInput(input); SDL_UnlockMutex(mMutex); - return ret; } --- 195,198 ---- |