mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-11 21:36:40 -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.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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,22 +355,25 @@ 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)
|
||||||
winMgr->setCursorActive(false);
|
winMgr->setCursorActive(false);
|
||||||
|
|
||||||
|
// Deadzone check
|
||||||
|
if (std::abs(arg.value) < 2000)
|
||||||
|
return !mGamepadGuiCursorEnabled;
|
||||||
|
|
||||||
if (mGamepadGuiCursorEnabled
|
if (mGamepadGuiCursorEnabled
|
||||||
&& (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 (isPastDeadzone && winMgr->getControllerTooltip())
|
if (winMgr->getControllerTooltip())
|
||||||
{
|
{
|
||||||
winMgr->setControllerTooltip(false);
|
winMgr->setControllerTooltip(false);
|
||||||
winMgr->setCursorVisible(true);
|
winMgr->setCursorVisible(true);
|
||||||
}
|
}
|
||||||
else if (isPastDeadzone && mGamepadGuiCursorEnabled)
|
else if (mGamepadGuiCursorEnabled)
|
||||||
{
|
{
|
||||||
winMgr->setCursorVisible(true);
|
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.
|
// Some windows have a specific widget to scroll with the right stick. Move the mouse there.
|
||||||
if (arg.axis == SDL_CONTROLLER_AXIS_RIGHTY && isPastDeadzone
|
if (arg.axis == SDL_CONTROLLER_AXIS_RIGHTY && topWin->getControllerScrollWidget() != nullptr)
|
||||||
&& topWin->getControllerScrollWidget() != nullptr)
|
|
||||||
{
|
{
|
||||||
mMouseManager->warpMouseToWidget(topWin->getControllerScrollWidget());
|
mMouseManager->warpMouseToWidget(topWin->getControllerScrollWidget());
|
||||||
winMgr->setCursorVisible(false);
|
winMgr->setCursorVisible(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user