mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 20:39:40 +00:00
Moved window resize messages to sdlinputwrapper
This commit is contained in:
parent
0880805559
commit
4fb32f7f05
4 changed files with 23 additions and 6 deletions
|
@ -136,6 +136,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
||||||
|
|
||||||
void OMW::Engine::handleSDLMessages()
|
void OMW::Engine::handleSDLMessages()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
//Pump messages since the last frame
|
//Pump messages since the last frame
|
||||||
const int max_events = 20;
|
const int max_events = 20;
|
||||||
SDL_Event events[max_events];
|
SDL_Event events[max_events];
|
||||||
|
@ -174,6 +175,7 @@ void OMW::Engine::handleSDLMessages()
|
||||||
//user requested a quit, break out.
|
//user requested a quit, break out.
|
||||||
mOgre->getRoot()->queueEndRendering();
|
mOgre->getRoot()->queueEndRendering();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
|
OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace MWInput
|
||||||
|
|
||||||
Ogre::RenderWindow* window = ogre.getWindow ();
|
Ogre::RenderWindow* window = ogre.getWindow ();
|
||||||
|
|
||||||
mInputManager = new SFO::InputWrapper(mOgre.getSDLWindow());
|
mInputManager = new SFO::InputWrapper(mOgre.getSDLWindow(), mOgre.getWindow());
|
||||||
mInputManager->setMouseEventCallback (this);
|
mInputManager->setMouseEventCallback (this);
|
||||||
mInputManager->setKeyboardEventCallback (this);
|
mInputManager->setKeyboardEventCallback (this);
|
||||||
mInputManager->setWindowEventCallback(this);
|
mInputManager->setWindowEventCallback(this);
|
||||||
|
@ -912,9 +912,9 @@ namespace MWInput
|
||||||
void InputManager::keyBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
void InputManager::keyBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||||
, SDL_Keycode key, ICS::Control::ControlChangingDirection direction)
|
, SDL_Keycode key, ICS::Control::ControlChangingDirection direction)
|
||||||
{
|
{
|
||||||
//Disallow binding escape key, and unassigned keys
|
//Disallow binding escape key
|
||||||
if(key==OIS::KC_ESCAPE || key==OIS::KC_UNASSIGNED)
|
if(key==SDLK_ESCAPE)
|
||||||
return
|
return;
|
||||||
|
|
||||||
clearAllBindings(control);
|
clearAllBindings(control);
|
||||||
ICS::DetectingBindingListener::keyBindingDetected (ICS, control, key, direction);
|
ICS::DetectingBindingListener::keyBindingDetected (ICS, control, key, direction);
|
||||||
|
|
16
extern/sdl4ogre/sdlinputwrapper.cpp
vendored
16
extern/sdl4ogre/sdlinputwrapper.cpp
vendored
|
@ -16,8 +16,9 @@ namespace SFO
|
||||||
{
|
{
|
||||||
/// \brief General purpose wrapper for OGRE applications around SDL's event
|
/// \brief General purpose wrapper for OGRE applications around SDL's event
|
||||||
/// queue, mostly used for handling input-related events.
|
/// queue, mostly used for handling input-related events.
|
||||||
InputWrapper::InputWrapper(SDL_Window* window) :
|
InputWrapper::InputWrapper(SDL_Window* window, Ogre::RenderWindow* ogreWindow) :
|
||||||
mSDLWindow(window),
|
mSDLWindow(window),
|
||||||
|
mOgreWindow(ogreWindow),
|
||||||
mOwnWindow(false),
|
mOwnWindow(false),
|
||||||
mWarpCompensate(false),
|
mWarpCompensate(false),
|
||||||
mMouseRelative(false),
|
mMouseRelative(false),
|
||||||
|
@ -98,6 +99,9 @@ namespace SFO
|
||||||
void InputWrapper::capture()
|
void InputWrapper::capture()
|
||||||
{
|
{
|
||||||
SDL_Event evt;
|
SDL_Event evt;
|
||||||
|
bool resize=false;
|
||||||
|
size_t size_x = 0;
|
||||||
|
size_t size_y = 0;
|
||||||
while(SDL_PollEvent(&evt))
|
while(SDL_PollEvent(&evt))
|
||||||
{
|
{
|
||||||
switch(evt.type)
|
switch(evt.type)
|
||||||
|
@ -128,8 +132,18 @@ namespace SFO
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
mKeyboardListener->keyReleased(evt.key);
|
mKeyboardListener->keyReleased(evt.key);
|
||||||
break;
|
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)
|
bool InputWrapper::isModifierHeld(int mod)
|
||||||
|
|
3
extern/sdl4ogre/sdlinputwrapper.hpp
vendored
3
extern/sdl4ogre/sdlinputwrapper.hpp
vendored
|
@ -16,7 +16,7 @@ namespace SFO
|
||||||
class InputWrapper
|
class InputWrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InputWrapper(SDL_Window *window=NULL);
|
InputWrapper(SDL_Window *window, Ogre::RenderWindow* ogreWindow);
|
||||||
~InputWrapper();
|
~InputWrapper();
|
||||||
|
|
||||||
//void initFromRenderWindow(Ogre::RenderWindow* win);
|
//void initFromRenderWindow(Ogre::RenderWindow* win);
|
||||||
|
@ -65,6 +65,7 @@ namespace SFO
|
||||||
Sint32 mMouseY;
|
Sint32 mMouseY;
|
||||||
|
|
||||||
SDL_Window* mSDLWindow;
|
SDL_Window* mSDLWindow;
|
||||||
|
Ogre::RenderWindow* mOgreWindow;
|
||||||
bool mOwnWindow;
|
bool mOwnWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue