forked from teamnwah/openmw-tes3coop
Mouse grab and relative input need to be disabled when the mouse leaves the window; Disabled resolution switching / window resizing for now due to several glitches
This commit is contained in:
parent
9331a6380c
commit
f1ff9b69b3
7 changed files with 57 additions and 28 deletions
|
@ -269,12 +269,15 @@ namespace MWGui
|
||||||
if (index == MyGUI::ITEM_NONE)
|
if (index == MyGUI::ITEM_NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
ConfirmationDialog* dialog = MWBase::Environment::get().getWindowManager()->getConfirmationDialog();
|
ConfirmationDialog* dialog = MWBase::Environment::get().getWindowManager()->getConfirmationDialog();
|
||||||
dialog->open("#{sNotifyMessage67}");
|
dialog->open("#{sNotifyMessage67}");
|
||||||
dialog->eventOkClicked.clear();
|
dialog->eventOkClicked.clear();
|
||||||
dialog->eventOkClicked += MyGUI::newDelegate(this, &SettingsWindow::onResolutionAccept);
|
dialog->eventOkClicked += MyGUI::newDelegate(this, &SettingsWindow::onResolutionAccept);
|
||||||
dialog->eventCancelClicked.clear();
|
dialog->eventCancelClicked.clear();
|
||||||
dialog->eventCancelClicked += MyGUI::newDelegate(this, &SettingsWindow::onResolutionCancel);
|
dialog->eventCancelClicked += MyGUI::newDelegate(this, &SettingsWindow::onResolutionCancel);
|
||||||
|
*/
|
||||||
|
onResolutionAccept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsWindow::onResolutionAccept()
|
void SettingsWindow::onResolutionAccept()
|
||||||
|
@ -287,7 +290,9 @@ namespace MWGui
|
||||||
Settings::Manager::setInt("resolution y", "Video", resY);
|
Settings::Manager::setInt("resolution y", "Video", resY);
|
||||||
|
|
||||||
apply();
|
apply();
|
||||||
mResolutionList->setIndexSelected(MyGUI::ITEM_NONE);
|
|
||||||
|
MWBase::Environment::get().getWindowManager()->
|
||||||
|
messageBox("New resolution will be applied after a restart", std::vector<std::string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsWindow::onResolutionCancel()
|
void SettingsWindow::onResolutionCancel()
|
||||||
|
@ -356,6 +361,8 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
Settings::Manager::setBool("fullscreen", "Video", newState);
|
Settings::Manager::setBool("fullscreen", "Video", newState);
|
||||||
apply();
|
apply();
|
||||||
|
MWBase::Environment::get().getWindowManager()->
|
||||||
|
messageBox("Fullscreen will be applied after a restart", std::vector<std::string>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_sender == mVSyncButton)
|
else if (_sender == mVSyncButton)
|
||||||
|
|
|
@ -876,18 +876,18 @@ namespace MWGui
|
||||||
|
|
||||||
setUseHardwareCursors(Settings::Manager::getBool("hardware cursors", "GUI"));
|
setUseHardwareCursors(Settings::Manager::getBool("hardware cursors", "GUI"));
|
||||||
|
|
||||||
bool changeRes = false;
|
//bool changeRes = false;
|
||||||
bool windowRecreated = false;
|
bool windowRecreated = false;
|
||||||
for (Settings::CategorySettingVector::const_iterator it = changed.begin();
|
for (Settings::CategorySettingVector::const_iterator it = changed.begin();
|
||||||
it != changed.end(); ++it)
|
it != changed.end(); ++it)
|
||||||
{
|
{
|
||||||
if (it->first == "Video" && (
|
/*if (it->first == "Video" && (
|
||||||
it->second == "resolution x"
|
it->second == "resolution x"
|
||||||
|| it->second == "resolution y"))
|
|| it->second == "resolution y"))
|
||||||
{
|
{
|
||||||
changeRes = true;
|
changeRes = true;
|
||||||
}
|
}*/
|
||||||
else if (it->first == "Video" && it->second == "vsync")
|
if (it->first == "Video" && it->second == "vsync")
|
||||||
windowRecreated = true;
|
windowRecreated = true;
|
||||||
else if (it->first == "HUD" && it->second == "crosshair")
|
else if (it->first == "HUD" && it->second == "crosshair")
|
||||||
mCrosshairEnabled = Settings::Manager::getBool ("crosshair", "HUD");
|
mCrosshairEnabled = Settings::Manager::getBool ("crosshair", "HUD");
|
||||||
|
@ -895,6 +895,7 @@ namespace MWGui
|
||||||
mSubtitlesEnabled = Settings::Manager::getBool ("subtitles", "GUI");
|
mSubtitlesEnabled = Settings::Manager::getBool ("subtitles", "GUI");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (changeRes)
|
if (changeRes)
|
||||||
{
|
{
|
||||||
int x = Settings::Manager::getInt("resolution x", "Video");
|
int x = Settings::Manager::getInt("resolution x", "Video");
|
||||||
|
@ -912,6 +913,7 @@ namespace MWGui
|
||||||
mDragAndDrop->mDragAndDropWidget->setSize(MyGUI::IntSize(x, y));
|
mDragAndDrop->mDragAndDropWidget->setSize(MyGUI::IntSize(x, y));
|
||||||
mInputBlocker->setSize(MyGUI::IntSize(x,y));
|
mInputBlocker->setSize(MyGUI::IntSize(x,y));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
if (windowRecreated)
|
if (windowRecreated)
|
||||||
{
|
{
|
||||||
mGuiManager->updateWindow (mRendering->getWindow ());
|
mGuiManager->updateWindow (mRendering->getWindow ());
|
||||||
|
|
|
@ -220,13 +220,13 @@ namespace MWInput
|
||||||
bool was_relative = mInputManager->getMouseRelative();
|
bool was_relative = mInputManager->getMouseRelative();
|
||||||
bool is_relative = !mWindows.isGuiMode();
|
bool is_relative = !mWindows.isGuiMode();
|
||||||
|
|
||||||
//we let the mouse escape in the main menu
|
|
||||||
mInputManager->setGrabPointer(!main_menu);
|
|
||||||
|
|
||||||
// don't keep the pointer away from the window edge in gui mode
|
// don't keep the pointer away from the window edge in gui mode
|
||||||
// stop using raw mouse motions and switch to system cursor movements
|
// stop using raw mouse motions and switch to system cursor movements
|
||||||
mInputManager->setMouseRelative(is_relative);
|
mInputManager->setMouseRelative(is_relative);
|
||||||
|
|
||||||
|
//we let the mouse escape in the main menu
|
||||||
|
mInputManager->setGrabPointer(!main_menu);
|
||||||
|
|
||||||
//we switched to non-relative mode, move our cursor to where the in-game
|
//we switched to non-relative mode, move our cursor to where the in-game
|
||||||
//cursor is
|
//cursor is
|
||||||
if( !is_relative && was_relative != is_relative )
|
if( !is_relative && was_relative != is_relative )
|
||||||
|
|
|
@ -719,7 +719,7 @@ Compositors* RenderingManager::getCompositors()
|
||||||
|
|
||||||
void RenderingManager::processChangedSettings(const Settings::CategorySettingVector& settings)
|
void RenderingManager::processChangedSettings(const Settings::CategorySettingVector& settings)
|
||||||
{
|
{
|
||||||
bool changeRes = false;
|
//bool changeRes = false;
|
||||||
bool rebuild = false; // rebuild static geometry (necessary after any material changes)
|
bool rebuild = false; // rebuild static geometry (necessary after any material changes)
|
||||||
for (Settings::CategorySettingVector::const_iterator it=settings.begin();
|
for (Settings::CategorySettingVector::const_iterator it=settings.begin();
|
||||||
it != settings.end(); ++it)
|
it != settings.end(); ++it)
|
||||||
|
@ -733,11 +733,11 @@ void RenderingManager::processChangedSettings(const Settings::CategorySettingVec
|
||||||
if (!MWBase::Environment::get().getWorld()->isCellExterior() && !MWBase::Environment::get().getWorld()->isCellQuasiExterior())
|
if (!MWBase::Environment::get().getWorld()->isCellExterior() && !MWBase::Environment::get().getWorld()->isCellQuasiExterior())
|
||||||
configureFog(*MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell());
|
configureFog(*MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell());
|
||||||
}
|
}
|
||||||
else if (it->first == "Video" && (
|
/*else if (it->first == "Video" && (
|
||||||
it->second == "resolution x"
|
it->second == "resolution x"
|
||||||
|| it->second == "resolution y"
|
|| it->second == "resolution y"
|
||||||
|| it->second == "fullscreen"))
|
|| it->second == "fullscreen"))
|
||||||
changeRes = true;
|
changeRes = true;*/
|
||||||
else if (it->second == "field of view" && it->first == "General")
|
else if (it->second == "field of view" && it->first == "General")
|
||||||
mRendering.setFov(Settings::Manager::getFloat("field of view", "General"));
|
mRendering.setFov(Settings::Manager::getFloat("field of view", "General"));
|
||||||
else if ((it->second == "texture filtering" && it->first == "General")
|
else if ((it->second == "texture filtering" && it->first == "General")
|
||||||
|
@ -791,6 +791,7 @@ void RenderingManager::processChangedSettings(const Settings::CategorySettingVec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (changeRes)
|
if (changeRes)
|
||||||
{
|
{
|
||||||
unsigned int x = Settings::Manager::getInt("resolution x", "Video");
|
unsigned int x = Settings::Manager::getInt("resolution x", "Video");
|
||||||
|
@ -807,6 +808,7 @@ void RenderingManager::processChangedSettings(const Settings::CategorySettingVec
|
||||||
SDL_SetWindowFullscreen(mRendering.getSDLWindow(), Settings::Manager::getBool("fullscreen", "Video") ? SDL_WINDOW_FULLSCREEN : 0);
|
SDL_SetWindowFullscreen(mRendering.getSDLWindow(), Settings::Manager::getBool("fullscreen", "Video") ? SDL_WINDOW_FULLSCREEN : 0);
|
||||||
//mRendering.getWindow()->setFullscreen(Settings::Manager::getBool("fullscreen", "Video"), x, y);
|
//mRendering.getWindow()->setFullscreen(Settings::Manager::getBool("fullscreen", "Video"), x, y);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
mWater->processChangedSettings(settings);
|
mWater->processChangedSettings(settings);
|
||||||
|
|
||||||
|
|
46
extern/sdl4ogre/sdlinputwrapper.cpp
vendored
46
extern/sdl4ogre/sdlinputwrapper.cpp
vendored
|
@ -99,9 +99,6 @@ 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)
|
||||||
|
@ -125,25 +122,42 @@ namespace SFO
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_MOUSEBUTTONUP:
|
||||||
mMouseListener->mouseReleased(evt.button, evt.button.button);
|
mMouseListener->mouseReleased(evt.button, evt.button.button);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
_handleKeyPress(evt.key);
|
_handleKeyPress(evt.key);
|
||||||
break;
|
break;
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
mKeyboardListener->keyReleased(evt.key);
|
mKeyboardListener->keyReleased(evt.key);
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_RESIZED:
|
case SDL_WINDOWEVENT:
|
||||||
resize = true;
|
handleWindowEvent(evt);
|
||||||
size_x = evt.window.data1;
|
|
||||||
size_y = evt.window.data2;
|
|
||||||
break;
|
break;
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
Ogre::Root::getSingleton().queueEndRendering();
|
Ogre::Root::getSingleton().queueEndRendering();
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
std::cerr << "Unhandled SDL event of type " << evt.type << std::endl;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (resize)
|
}
|
||||||
mOgreWindow->resize(size_x, size_y);
|
|
||||||
|
void InputWrapper::handleWindowEvent(const SDL_Event& evt)
|
||||||
|
{
|
||||||
|
switch (evt.window.event) {
|
||||||
|
case SDL_WINDOWEVENT_ENTER:
|
||||||
|
mMouseInWindow = true;
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_LEAVE:
|
||||||
|
mMouseInWindow = false;
|
||||||
|
SDL_SetWindowGrab(mSDLWindow, SDL_FALSE);
|
||||||
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_RESIZED:
|
||||||
|
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||||
|
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||||
|
case SDL_WINDOWEVENT_CLOSE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputWrapper::isModifierHeld(int mod)
|
bool InputWrapper::isModifierHeld(int mod)
|
||||||
|
@ -163,25 +177,25 @@ namespace SFO
|
||||||
/// \brief Locks the pointer to the window
|
/// \brief Locks the pointer to the window
|
||||||
void InputWrapper::setGrabPointer(bool grab)
|
void InputWrapper::setGrabPointer(bool grab)
|
||||||
{
|
{
|
||||||
mGrabPointer = grab;
|
mGrabPointer = grab && mMouseInWindow;
|
||||||
SDL_SetWindowGrab(mSDLWindow, grab ? SDL_TRUE : SDL_FALSE);
|
SDL_SetWindowGrab(mSDLWindow, grab && mMouseInWindow ? SDL_TRUE : SDL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Set the mouse to relative positioning. Doesn't move the cursor
|
/// \brief Set the mouse to relative positioning. Doesn't move the cursor
|
||||||
/// and disables mouse acceleration.
|
/// and disables mouse acceleration.
|
||||||
void InputWrapper::setMouseRelative(bool relative)
|
void InputWrapper::setMouseRelative(bool relative)
|
||||||
{
|
{
|
||||||
if(mMouseRelative == relative)
|
if(mMouseRelative == relative && mMouseInWindow)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mMouseRelative = relative;
|
mMouseRelative = relative && mMouseInWindow;
|
||||||
|
|
||||||
mWrapPointer = false;
|
mWrapPointer = false;
|
||||||
|
|
||||||
//eep, wrap the pointer manually if the input driver doesn't support
|
//eep, wrap the pointer manually if the input driver doesn't support
|
||||||
//relative positioning natively
|
//relative positioning natively
|
||||||
int success = SDL_SetRelativeMouseMode(relative ? SDL_TRUE : SDL_FALSE);
|
int success = SDL_SetRelativeMouseMode(relative && mMouseInWindow ? SDL_TRUE : SDL_FALSE);
|
||||||
if(relative && success != 0)
|
if(relative && mMouseInWindow && success != 0)
|
||||||
mWrapPointer = true;
|
mWrapPointer = true;
|
||||||
|
|
||||||
//now remove all mouse events using the old setting from the queue
|
//now remove all mouse events using the old setting from the queue
|
||||||
|
|
4
extern/sdl4ogre/sdlinputwrapper.hpp
vendored
4
extern/sdl4ogre/sdlinputwrapper.hpp
vendored
|
@ -38,6 +38,8 @@ namespace SFO
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void handleWindowEvent(const SDL_Event& evt);
|
||||||
|
|
||||||
bool _handleWarpMotion(const SDL_MouseMotionEvent& evt);
|
bool _handleWarpMotion(const SDL_MouseMotionEvent& evt);
|
||||||
void _wrapMousePointer(const SDL_MouseMotionEvent &evt);
|
void _wrapMousePointer(const SDL_MouseMotionEvent &evt);
|
||||||
MouseMotionEvent _packageMouseMotion(const SDL_Event& evt);
|
MouseMotionEvent _packageMouseMotion(const SDL_Event& evt);
|
||||||
|
@ -64,6 +66,8 @@ namespace SFO
|
||||||
Sint32 mMouseX;
|
Sint32 mMouseX;
|
||||||
Sint32 mMouseY;
|
Sint32 mMouseY;
|
||||||
|
|
||||||
|
bool mMouseInWindow;
|
||||||
|
|
||||||
SDL_Window* mSDLWindow;
|
SDL_Window* mSDLWindow;
|
||||||
Ogre::RenderWindow* mOgreWindow;
|
Ogre::RenderWindow* mOgreWindow;
|
||||||
bool mOwnWindow;
|
bool mOwnWindow;
|
||||||
|
|
|
@ -241,7 +241,7 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings&
|
||||||
SDL_WINDOWPOS_UNDEFINED, // initial y position
|
SDL_WINDOWPOS_UNDEFINED, // initial y position
|
||||||
settings.window_x, // width, in pixels
|
settings.window_x, // width, in pixels
|
||||||
settings.window_y, // height, in pixels
|
settings.window_y, // height, in pixels
|
||||||
SDL_WINDOW_SHOWN|SDL_WINDOW_RESIZABLE
|
SDL_WINDOW_SHOWN
|
||||||
| (settings.fullscreen ? SDL_WINDOW_FULLSCREEN : 0)
|
| (settings.fullscreen ? SDL_WINDOW_FULLSCREEN : 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue