From 4fb32f7f056bd38e83ea9cb7d6c69468bea6843b Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 15 Jun 2013 13:22:29 +0200 Subject: [PATCH] Moved window resize messages to sdlinputwrapper --- apps/openmw/engine.cpp | 2 ++ apps/openmw/mwinput/inputmanagerimp.cpp | 8 ++++---- extern/sdl4ogre/sdlinputwrapper.cpp | 16 +++++++++++++++- extern/sdl4ogre/sdlinputwrapper.hpp | 3 ++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 95f6e6e92..e78162c29 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -136,6 +136,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) void OMW::Engine::handleSDLMessages() { + /* //Pump messages since the last frame const int max_events = 20; SDL_Event events[max_events]; @@ -174,6 +175,7 @@ void OMW::Engine::handleSDLMessages() //user requested a quit, break out. mOgre->getRoot()->queueEndRendering(); } + */ } OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 203123d5b..b9d0afe72 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -65,7 +65,7 @@ namespace MWInput Ogre::RenderWindow* window = ogre.getWindow (); - mInputManager = new SFO::InputWrapper(mOgre.getSDLWindow()); + mInputManager = new SFO::InputWrapper(mOgre.getSDLWindow(), mOgre.getWindow()); mInputManager->setMouseEventCallback (this); mInputManager->setKeyboardEventCallback (this); mInputManager->setWindowEventCallback(this); @@ -912,9 +912,9 @@ namespace MWInput void InputManager::keyBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control , SDL_Keycode key, ICS::Control::ControlChangingDirection direction) { - //Disallow binding escape key, and unassigned keys - if(key==OIS::KC_ESCAPE || key==OIS::KC_UNASSIGNED) - return + //Disallow binding escape key + if(key==SDLK_ESCAPE) + return; clearAllBindings(control); ICS::DetectingBindingListener::keyBindingDetected (ICS, control, key, direction); diff --git a/extern/sdl4ogre/sdlinputwrapper.cpp b/extern/sdl4ogre/sdlinputwrapper.cpp index 70a775113..7cc7820f9 100644 --- a/extern/sdl4ogre/sdlinputwrapper.cpp +++ b/extern/sdl4ogre/sdlinputwrapper.cpp @@ -16,8 +16,9 @@ namespace SFO { /// \brief General purpose wrapper for OGRE applications around SDL's event /// queue, mostly used for handling input-related events. - InputWrapper::InputWrapper(SDL_Window* window) : + InputWrapper::InputWrapper(SDL_Window* window, Ogre::RenderWindow* ogreWindow) : mSDLWindow(window), + mOgreWindow(ogreWindow), mOwnWindow(false), mWarpCompensate(false), mMouseRelative(false), @@ -98,6 +99,9 @@ namespace SFO void InputWrapper::capture() { SDL_Event evt; + bool resize=false; + size_t size_x = 0; + size_t size_y = 0; while(SDL_PollEvent(&evt)) { switch(evt.type) @@ -128,8 +132,18 @@ namespace SFO case SDL_KEYUP: mKeyboardListener->keyReleased(evt.key); break; + case SDL_WINDOWEVENT_RESIZED: + resize = true; + size_x = evt.window.data1; + size_y = evt.window.data2; + break; + case SDL_QUIT: + Ogre::Root::getSingleton().queueEndRendering(); + break; } } + if (resize) + mOgreWindow->resize(size_x, size_y); } bool InputWrapper::isModifierHeld(int mod) diff --git a/extern/sdl4ogre/sdlinputwrapper.hpp b/extern/sdl4ogre/sdlinputwrapper.hpp index 257699a64..f84ebcacc 100644 --- a/extern/sdl4ogre/sdlinputwrapper.hpp +++ b/extern/sdl4ogre/sdlinputwrapper.hpp @@ -16,7 +16,7 @@ namespace SFO class InputWrapper { public: - InputWrapper(SDL_Window *window=NULL); + InputWrapper(SDL_Window *window, Ogre::RenderWindow* ogreWindow); ~InputWrapper(); //void initFromRenderWindow(Ogre::RenderWindow* win); @@ -65,6 +65,7 @@ namespace SFO Sint32 mMouseY; SDL_Window* mSDLWindow; + Ogre::RenderWindow* mOgreWindow; bool mOwnWindow; };