mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-08-03 15:27:13 -04:00
Better dead zone handling
This commit is contained in:
parent
2e5836a748
commit
3147aea0ed
@ -511,8 +511,7 @@ namespace MWGui
|
||||
{
|
||||
if (arg.axis == SDL_CONTROLLER_AXIS_RIGHTX)
|
||||
{
|
||||
if (arg.value < -1000 || arg.value > 1000)
|
||||
onPreviewScroll(nullptr, arg.value < 0 ? 1 : -1);
|
||||
onPreviewScroll(nullptr, arg.value < 0 ? 1 : -1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -355,22 +355,25 @@ namespace MWInput
|
||||
MWGui::WindowBase* topWin = winMgr->getActiveControllerWindow();
|
||||
if (topWin)
|
||||
{
|
||||
bool isPastDeadzone = std::abs(arg.value) > 2000;
|
||||
// Update cursor state
|
||||
mGamepadGuiCursorEnabled = topWin->isGamepadCursorAllowed();
|
||||
if (!mGamepadGuiCursorEnabled)
|
||||
winMgr->setCursorActive(false);
|
||||
|
||||
// Deadzone check
|
||||
if (std::abs(arg.value) < 2000)
|
||||
return !mGamepadGuiCursorEnabled;
|
||||
|
||||
if (mGamepadGuiCursorEnabled
|
||||
&& (arg.axis == SDL_CONTROLLER_AXIS_LEFTX || arg.axis == SDL_CONTROLLER_AXIS_LEFTY))
|
||||
{
|
||||
// Treat the left stick like a cursor, which is the default behavior.
|
||||
if (isPastDeadzone && winMgr->getControllerTooltip())
|
||||
if (winMgr->getControllerTooltip())
|
||||
{
|
||||
winMgr->setControllerTooltip(false);
|
||||
winMgr->setCursorVisible(true);
|
||||
}
|
||||
else if (isPastDeadzone && mGamepadGuiCursorEnabled)
|
||||
else if (mGamepadGuiCursorEnabled)
|
||||
{
|
||||
winMgr->setCursorVisible(true);
|
||||
}
|
||||
@ -378,8 +381,7 @@ namespace MWInput
|
||||
}
|
||||
|
||||
// Some windows have a specific widget to scroll with the right stick. Move the mouse there.
|
||||
if (arg.axis == SDL_CONTROLLER_AXIS_RIGHTY && isPastDeadzone
|
||||
&& topWin->getControllerScrollWidget() != nullptr)
|
||||
if (arg.axis == SDL_CONTROLLER_AXIS_RIGHTY && topWin->getControllerScrollWidget() != nullptr)
|
||||
{
|
||||
mMouseManager->warpMouseToWidget(topWin->getControllerScrollWidget());
|
||||
winMgr->setCursorVisible(false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user