mirror of
https://github.com/OpenMW/openmw.git
synced 2026-01-05 08:43:10 +00:00
Make right stick scroll dialog history
This commit is contained in:
parent
ba0a579371
commit
5e3a49ade5
6 changed files with 26 additions and 2 deletions
|
|
@ -380,8 +380,10 @@ namespace MWGui
|
|||
mMainWidget->castType<MyGUI::Window>()->eventWindowChangeCoord
|
||||
+= MyGUI::newDelegate(this, &DialogueWindow::onWindowResize);
|
||||
|
||||
mControllerScrollWidget = mHistory->getParent();
|
||||
mControllerButtons.a = "#{sAsk}";
|
||||
mControllerButtons.b = "#{sGoodbye}";
|
||||
mControllerButtons.rStick = "#{sScrollup}";
|
||||
}
|
||||
|
||||
void DialogueWindow::onTradeComplete()
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ namespace MWGui
|
|||
mCloseButton->eventKeyButtonPressed += MyGUI::newDelegate(this, &ScrollWindow::onKeyButtonPressed);
|
||||
mTakeButton->eventKeyButtonPressed += MyGUI::newDelegate(this, &ScrollWindow::onKeyButtonPressed);
|
||||
|
||||
mControllerScrollWidget = mTextView;
|
||||
mControllerButtons.b = "#{sClose}";
|
||||
mControllerButtons.rStick = "#{sScrolldown}";
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ namespace MWGui
|
|||
static void clampWindowCoordinates(MyGUI::Window* window);
|
||||
|
||||
virtual ControllerButtonStr* getControllerButtons() { return &mControllerButtons; }
|
||||
MyGUI::Widget* getControllerScrollWidget() { return mControllerScrollWidget; }
|
||||
bool isGamepadCursorAllowed() { return !mDisableGamepadCursor; }
|
||||
virtual bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) { return true; };
|
||||
virtual bool onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg) { return true; };
|
||||
|
|
@ -88,6 +89,7 @@ namespace MWGui
|
|||
ControllerButtonStr mControllerButtons;
|
||||
bool mActiveControllerWindow = false;
|
||||
bool mDisableGamepadCursor = false;
|
||||
MyGUI::Widget* mControllerScrollWidget = nullptr;
|
||||
|
||||
private:
|
||||
void onDoubleClick(MyGUI::Widget* _sender);
|
||||
|
|
|
|||
|
|
@ -353,10 +353,15 @@ namespace MWInput
|
|||
if (mGamepadGuiCursorEnabled
|
||||
&& (arg.axis == SDL_CONTROLLER_AXIS_LEFTX || arg.axis == SDL_CONTROLLER_AXIS_LEFTY))
|
||||
{
|
||||
// Treat the left stick like a cursor. Fall through.
|
||||
// Treat the left stick like a cursor, which is the default behavior.
|
||||
return false;
|
||||
}
|
||||
else if (topWin->onControllerThumbstickEvent(arg))
|
||||
|
||||
// On some windows, treat right stick like a scroll wheel.
|
||||
if (arg.axis == SDL_CONTROLLER_AXIS_RIGHTY && topWin->getControllerScrollWidget() != nullptr)
|
||||
mMouseManager->warpMouseToWidget(topWin->getControllerScrollWidget());
|
||||
|
||||
if (topWin->onControllerThumbstickEvent(arg))
|
||||
{
|
||||
// Window handled the event.
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -263,4 +263,17 @@ namespace MWInput
|
|||
mInputWrapper->warpMouse(
|
||||
static_cast<int>(mGuiCursorX * guiUiScale), static_cast<int>(mGuiCursorY * guiUiScale));
|
||||
}
|
||||
|
||||
void MouseManager::warpMouseToWidget(MyGUI::Widget* widget)
|
||||
{
|
||||
float widgetX = widget->getAbsoluteCoord().left + 4;
|
||||
float widgetY = widget->getAbsoluteCoord().top + 4;
|
||||
if (std::abs(mGuiCursorX - widgetX) > 1 || std::abs(mGuiCursorY - widgetY) > 1)
|
||||
{
|
||||
mGuiCursorX = widgetX;
|
||||
mGuiCursorY = widgetY;
|
||||
warpMouse();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ namespace MWInput
|
|||
bool injectMouseButtonRelease(Uint8 button);
|
||||
void injectMouseMove(float xMove, float yMove, float mouseWheelMove);
|
||||
void warpMouse();
|
||||
void warpMouseToWidget(MyGUI::Widget* widget);
|
||||
|
||||
void setMouseLookEnabled(bool enabled) { mMouseLookEnabled = enabled; }
|
||||
void setGuiCursorEnabled(bool enabled) { mGuiCursorEnabled = enabled; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue