mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-19 01:16:45 -04:00
Fix right stick from causing mouse to appear in controller mode
This commit is contained in:
parent
5d5d14a5a6
commit
582b409f7f
@ -82,7 +82,7 @@ namespace MWGui
|
|||||||
MyGUI::Widget* getControllerScrollWidget() { return mControllerScrollWidget; }
|
MyGUI::Widget* getControllerScrollWidget() { return mControllerScrollWidget; }
|
||||||
bool isGamepadCursorAllowed() { return !mDisableGamepadCursor; }
|
bool isGamepadCursorAllowed() { return !mDisableGamepadCursor; }
|
||||||
virtual bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) { return true; }
|
virtual bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) { return true; }
|
||||||
virtual bool onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg) { return true; }
|
virtual bool onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg) { return false; }
|
||||||
virtual void setActiveControllerWindow(bool active) { mActiveControllerWindow = active; }
|
virtual void setActiveControllerWindow(bool active) { mActiveControllerWindow = active; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -221,7 +221,8 @@ namespace MWInput
|
|||||||
mJoystickLastUsed = true;
|
mJoystickLastUsed = true;
|
||||||
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||||
{
|
{
|
||||||
gamepadToGuiControl(arg);
|
if (gamepadToGuiControl(arg))
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (mBindingsManager->actionIsActive(A_TogglePOV)
|
else if (mBindingsManager->actionIsActive(A_TogglePOV)
|
||||||
&& (arg.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT || arg.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT))
|
&& (arg.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT || arg.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT))
|
||||||
@ -354,6 +355,7 @@ namespace MWInput
|
|||||||
MWGui::WindowBase* topWin = winMgr->getActiveControllerWindow();
|
MWGui::WindowBase* topWin = winMgr->getActiveControllerWindow();
|
||||||
if (topWin)
|
if (topWin)
|
||||||
{
|
{
|
||||||
|
bool isPastDeadzone = std::abs(arg.value) > 2000;
|
||||||
// Update cursor state
|
// Update cursor state
|
||||||
mGamepadGuiCursorEnabled = topWin->isGamepadCursorAllowed();
|
mGamepadGuiCursorEnabled = topWin->isGamepadCursorAllowed();
|
||||||
if (!mGamepadGuiCursorEnabled)
|
if (!mGamepadGuiCursorEnabled)
|
||||||
@ -363,23 +365,36 @@ namespace MWInput
|
|||||||
&& (arg.axis == SDL_CONTROLLER_AXIS_LEFTX || arg.axis == SDL_CONTROLLER_AXIS_LEFTY))
|
&& (arg.axis == SDL_CONTROLLER_AXIS_LEFTX || arg.axis == SDL_CONTROLLER_AXIS_LEFTY))
|
||||||
{
|
{
|
||||||
// Treat the left stick like a cursor, which is the default behavior.
|
// Treat the left stick like a cursor, which is the default behavior.
|
||||||
if (winMgr->getControllerTooltip() && std::abs(arg.value) > 2000)
|
if (isPastDeadzone && winMgr->getControllerTooltip())
|
||||||
{
|
{
|
||||||
winMgr->setControllerTooltip(false);
|
winMgr->setControllerTooltip(false);
|
||||||
winMgr->setCursorVisible(true);
|
winMgr->setCursorVisible(true);
|
||||||
}
|
}
|
||||||
|
else if (isPastDeadzone && mGamepadGuiCursorEnabled)
|
||||||
|
{
|
||||||
|
winMgr->setCursorVisible(true);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On some windows, treat right stick like a scroll wheel.
|
// Some windows have a specific widget to scroll with the right stick. Move the mouse there.
|
||||||
if (arg.axis == SDL_CONTROLLER_AXIS_RIGHTY && topWin->getControllerScrollWidget() != nullptr)
|
if (arg.axis == SDL_CONTROLLER_AXIS_RIGHTY && isPastDeadzone
|
||||||
|
&& topWin->getControllerScrollWidget() != nullptr)
|
||||||
|
{
|
||||||
mMouseManager->warpMouseToWidget(topWin->getControllerScrollWidget());
|
mMouseManager->warpMouseToWidget(topWin->getControllerScrollWidget());
|
||||||
|
winMgr->setCursorVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (topWin->onControllerThumbstickEvent(arg))
|
if (topWin->onControllerThumbstickEvent(arg))
|
||||||
{
|
{
|
||||||
// Window handled the event.
|
// Window handled the event.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (arg.axis == SDL_CONTROLLER_AXIS_RIGHTX || arg.axis == SDL_CONTROLLER_AXIS_RIGHTY)
|
||||||
|
{
|
||||||
|
// Only right-stick scroll if mouse is visible or there's a widget to scroll.
|
||||||
|
return !winMgr->getCursorVisible() && topWin->getControllerScrollWidget() == nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user