mirror of
https://github.com/OpenMW/openmw.git
synced 2025-11-08 17:46:40 +00:00
Consolidate all gamepad cursor listening in controllermanager
This commit is contained in:
parent
e01291ec4a
commit
33a6189f7a
19 changed files with 76 additions and 155 deletions
|
|
@ -282,10 +282,6 @@ namespace MWGui
|
|||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
// Have A button do nothing so mouse controller still works.
|
||||
if (mUsingGamepadGuiCursor)
|
||||
return false;
|
||||
|
||||
if (mOkButtonFocus)
|
||||
onOkClicked(mOkButton);
|
||||
else
|
||||
|
|
@ -304,14 +300,12 @@ namespace MWGui
|
|||
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
|
||||
winMgr->setKeyFocusWidget(mBirthList);
|
||||
winMgr->injectKeyPress(MyGUI::KeyCode::ArrowUp, 0, false);
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
|
||||
{
|
||||
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
|
||||
winMgr->setKeyFocusWidget(mBirthList);
|
||||
winMgr->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false);
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
else if ((arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT && mOkButtonFocus) ||
|
||||
(arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT && !mOkButtonFocus))
|
||||
|
|
@ -319,18 +313,8 @@ namespace MWGui
|
|||
mOkButtonFocus = !mOkButtonFocus;
|
||||
mOkButton->setStateSelected(mOkButtonFocus);
|
||||
mBackButton->setStateSelected(!mOkButtonFocus);
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BirthDialog::onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg)
|
||||
{
|
||||
if (arg.axis == SDL_CONTROLLER_AXIS_LEFTX || arg.axis == SDL_CONTROLLER_AXIS_LEFTY)
|
||||
{
|
||||
mUsingGamepadGuiCursor = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,9 +59,7 @@ namespace MWGui
|
|||
ESM::RefId mCurrentBirthId;
|
||||
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
bool onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg) override;
|
||||
bool mOkButtonFocus = true;
|
||||
bool mUsingGamepadGuiCursor = false;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ namespace MWGui
|
|||
if (Settings::gui().mControllerMenus)
|
||||
{
|
||||
mOkButton->setStateSelected(true);
|
||||
mDisableGamepadCursor = true;
|
||||
trackFocusEvents(mBackButton);
|
||||
trackFocusEvents(mOkButton);
|
||||
mControllerButtons.a = "#{sSelect}";
|
||||
|
|
@ -323,10 +324,6 @@ namespace MWGui
|
|||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
// Have A button do nothing so mouse controller still works.
|
||||
if (mUsingGamepadGuiCursor)
|
||||
return false;
|
||||
|
||||
if (mOkButtonFocus)
|
||||
onOkClicked(mOkButton);
|
||||
else
|
||||
|
|
@ -345,14 +342,12 @@ namespace MWGui
|
|||
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
|
||||
winMgr->setKeyFocusWidget(mClassList);
|
||||
winMgr->injectKeyPress(MyGUI::KeyCode::ArrowUp, 0, false);
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
|
||||
{
|
||||
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
|
||||
winMgr->setKeyFocusWidget(mClassList);
|
||||
winMgr->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false);
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
else if ((arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT && mOkButtonFocus) ||
|
||||
(arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT && !mOkButtonFocus))
|
||||
|
|
@ -360,21 +355,11 @@ namespace MWGui
|
|||
mOkButtonFocus = !mOkButtonFocus;
|
||||
mOkButton->setStateSelected(mOkButtonFocus);
|
||||
mBackButton->setStateSelected(!mOkButtonFocus);
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PickClassDialog::onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg)
|
||||
{
|
||||
if (arg.axis == SDL_CONTROLLER_AXIS_LEFTX || arg.axis == SDL_CONTROLLER_AXIS_LEFTY)
|
||||
{
|
||||
mUsingGamepadGuiCursor = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* InfoBoxDialog */
|
||||
|
||||
void InfoBoxDialog::fitToText(MyGUI::TextBox* widget)
|
||||
|
|
@ -417,6 +402,7 @@ namespace MWGui
|
|||
|
||||
center();
|
||||
|
||||
mDisableGamepadCursor = Settings::gui().mControllerMenus;
|
||||
mControllerButtons.a = "#{sSelect}";
|
||||
}
|
||||
|
||||
|
|
@ -721,10 +707,6 @@ namespace MWGui
|
|||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
// Have A button do nothing so mouse controller still works.
|
||||
if (mUsingGamepadGuiCursor)
|
||||
return false;
|
||||
|
||||
if (mControllerFocus == 0)
|
||||
onDescriptionClicked(mButtons[0]);
|
||||
else if (mControllerFocus == 1)
|
||||
|
|
@ -740,11 +722,6 @@ namespace MWGui
|
|||
{
|
||||
onOkClicked(mButtons[2]);
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP ||
|
||||
arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
|
||||
{
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT)
|
||||
{
|
||||
mButtons[mControllerFocus]->setStateSelected(false);
|
||||
|
|
@ -753,7 +730,6 @@ namespace MWGui
|
|||
else
|
||||
mControllerFocus--;
|
||||
mButtons[mControllerFocus]->setStateSelected(true);
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
|
||||
{
|
||||
|
|
@ -763,20 +739,10 @@ namespace MWGui
|
|||
else
|
||||
mControllerFocus++;
|
||||
mButtons[mControllerFocus]->setStateSelected(true);
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CreateClassDialog::onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg)
|
||||
{
|
||||
if (arg.axis == SDL_CONTROLLER_AXIS_LEFTX || arg.axis == SDL_CONTROLLER_AXIS_LEFTY)
|
||||
{
|
||||
mUsingGamepadGuiCursor = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// widget controls
|
||||
|
||||
void CreateClassDialog::onDialogCancel()
|
||||
|
|
|
|||
|
|
@ -155,9 +155,7 @@ namespace MWGui
|
|||
ESM::RefId mCurrentClassId;
|
||||
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
bool onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg) override;
|
||||
bool mOkButtonFocus = true;
|
||||
bool mUsingGamepadGuiCursor = false;
|
||||
};
|
||||
|
||||
class SelectSpecializationDialog : public WindowModal
|
||||
|
|
@ -349,9 +347,7 @@ namespace MWGui
|
|||
Widgets::MWSkillPtr mAffectedSkill;
|
||||
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
bool onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg) override;
|
||||
int mControllerFocus = 2;
|
||||
bool mUsingGamepadGuiCursor = false;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ namespace MWGui
|
|||
|
||||
if (Settings::gui().mControllerMenus)
|
||||
{
|
||||
mDisableGamepadCursor = true;
|
||||
trackFocusEvents(mOkButton);
|
||||
trackFocusEvents(mCancelButton);
|
||||
mControllerButtons.a = "#{sOk}";
|
||||
|
|
|
|||
|
|
@ -96,12 +96,12 @@ namespace MWGui
|
|||
name += MWGui::ToolTips::getSoulString(object.getCellRef());
|
||||
dialog->openCountDialog(name, "#{sTake}", count);
|
||||
dialog->eventOkClicked.clear();
|
||||
if (Settings::gui().mControllerMenus && !mUsingGamepadGuiCursor)
|
||||
if (Settings::gui().mControllerMenus)
|
||||
dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerWindow::takeItem);
|
||||
else
|
||||
dialog->eventOkClicked += MyGUI::newDelegate(this, &ContainerWindow::dragItem);
|
||||
}
|
||||
else if (Settings::gui().mControllerMenus && !mUsingGamepadGuiCursor)
|
||||
else if (Settings::gui().mControllerMenus)
|
||||
takeItem(nullptr, count);
|
||||
else
|
||||
dragItem(nullptr, count);
|
||||
|
|
@ -368,14 +368,9 @@ namespace MWGui
|
|||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
if (mUsingGamepadGuiCursor)
|
||||
return false;
|
||||
|
||||
int index = mItemView->getControllerFocus();
|
||||
if (index >= 0 && index < mItemView->getItemCount())
|
||||
{
|
||||
onItemSelected(index);
|
||||
}
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
||||
{
|
||||
|
|
@ -396,21 +391,11 @@ namespace MWGui
|
|||
arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
|
||||
{
|
||||
mItemView->onControllerButtonEvent(arg);
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContainerWindow::onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg)
|
||||
{
|
||||
if (arg.axis == SDL_CONTROLLER_AXIS_LEFTX || arg.axis == SDL_CONTROLLER_AXIS_LEFTY)
|
||||
{
|
||||
mUsingGamepadGuiCursor = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ContainerWindow::setActiveControllerWindow(bool active)
|
||||
{
|
||||
mItemView->setActiveControllerWindow(active);
|
||||
|
|
|
|||
|
|
@ -70,8 +70,6 @@ namespace MWGui
|
|||
void onReferenceUnavailable() override;
|
||||
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
bool onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg) override;
|
||||
bool mUsingGamepadGuiCursor = false;
|
||||
};
|
||||
}
|
||||
#endif // CONTAINER_H
|
||||
|
|
|
|||
|
|
@ -685,10 +685,6 @@ namespace
|
|||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A) // A: Mouse click or Select
|
||||
{
|
||||
// Fall through to mouse click
|
||||
if (mUsingGamepadGuiCursor)
|
||||
return false;
|
||||
|
||||
if (mOptionsMode && mQuestMode)
|
||||
{
|
||||
// Choose a quest
|
||||
|
|
@ -773,7 +769,6 @@ namespace
|
|||
mSelectedQuest = mButtons.size() - 1;
|
||||
mButtons[mSelectedQuest]->setStateSelected(true);
|
||||
}
|
||||
mUsingGamepadGuiCursor = false;
|
||||
return true;
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
|
||||
|
|
@ -787,21 +782,18 @@ namespace
|
|||
mSelectedQuest = 0;
|
||||
mButtons[mSelectedQuest]->setStateSelected(true);
|
||||
}
|
||||
mUsingGamepadGuiCursor = false;
|
||||
return true;
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT)
|
||||
{
|
||||
if (!mOptionsMode)
|
||||
notifyPrevPage(getWidget<MyGUI::Widget>(PrevPageBTN));
|
||||
mUsingGamepadGuiCursor = false;
|
||||
return true;
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
|
||||
{
|
||||
if (!mOptionsMode)
|
||||
notifyNextPage(getWidget<MyGUI::Widget>(NextPageBTN));
|
||||
mUsingGamepadGuiCursor = false;
|
||||
return true;
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER) // LB: Previous Page
|
||||
|
|
@ -819,13 +811,6 @@ namespace
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg) override
|
||||
{
|
||||
if (arg.axis == SDL_CONTROLLER_AXIS_LEFTX || arg.axis == SDL_CONTROLLER_AXIS_LEFTY)
|
||||
mUsingGamepadGuiCursor = true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ namespace MWGui
|
|||
|
||||
std::vector<MyGUI::Button*> mButtons;
|
||||
int mSelectedQuest = 0;
|
||||
bool mUsingGamepadGuiCursor = false;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ namespace MWGui
|
|||
constexpr VFS::Path::NormalizedView menuBackgroundVideo("video/menu_background.bik");
|
||||
|
||||
mHasAnimatedMenu = mVFS->exists(menuBackgroundVideo);
|
||||
mDisableGamepadCursor = Settings::gui().mControllerMenus;
|
||||
|
||||
updateMenu();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -284,6 +284,7 @@ namespace MWGui
|
|||
|
||||
if (Settings::gui().mControllerMenus)
|
||||
{
|
||||
mDisableGamepadCursor = true;
|
||||
mControllerButtons.a = "#{sOk}";
|
||||
|
||||
// If we have more than one button, we need to set the focus to the first one.
|
||||
|
|
|
|||
|
|
@ -475,10 +475,6 @@ namespace MWGui
|
|||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
// Have A button do nothing so mouse controller still works.
|
||||
if (mUsingGamepadGuiCursor)
|
||||
return false;
|
||||
|
||||
if (mOkButtonFocus)
|
||||
onOkClicked(mOkButton);
|
||||
else
|
||||
|
|
@ -509,14 +505,12 @@ namespace MWGui
|
|||
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
|
||||
winMgr->setKeyFocusWidget(mRaceList);
|
||||
winMgr->injectKeyPress(MyGUI::KeyCode::ArrowUp, 0, false);
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
|
||||
{
|
||||
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
|
||||
winMgr->setKeyFocusWidget(mRaceList);
|
||||
winMgr->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false);
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
else if ((arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT && mOkButtonFocus) ||
|
||||
(arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT && !mOkButtonFocus))
|
||||
|
|
@ -524,7 +518,6 @@ namespace MWGui
|
|||
mOkButtonFocus = !mOkButtonFocus;
|
||||
mOkButton->setStateSelected(mOkButtonFocus);
|
||||
mBackButton->setStateSelected(!mOkButtonFocus);
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -532,11 +525,7 @@ namespace MWGui
|
|||
|
||||
bool RaceDialog::onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg)
|
||||
{
|
||||
if (arg.axis == SDL_CONTROLLER_AXIS_LEFTX || arg.axis == SDL_CONTROLLER_AXIS_LEFTY)
|
||||
{
|
||||
mUsingGamepadGuiCursor = true;
|
||||
}
|
||||
else 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);
|
||||
|
|
|
|||
|
|
@ -125,7 +125,6 @@ namespace MWGui
|
|||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
bool onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg) override;
|
||||
bool mOkButtonFocus = true;
|
||||
bool mUsingGamepadGuiCursor = false;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -516,10 +516,6 @@ namespace MWGui
|
|||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
// Have A button do nothing so mouse controller still works.
|
||||
if (mUsingGamepadGuiCursor)
|
||||
return false;
|
||||
|
||||
if (mOkButtonFocus)
|
||||
onOkButtonClicked(mOkButton);
|
||||
else
|
||||
|
|
@ -537,21 +533,18 @@ namespace MWGui
|
|||
else
|
||||
index++;
|
||||
mCharacterSelection->setIndexSelected(index);
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
|
||||
{
|
||||
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
|
||||
winMgr->setKeyFocusWidget(mSaveList);
|
||||
winMgr->injectKeyPress(MyGUI::KeyCode::ArrowUp, 0, false);
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
|
||||
{
|
||||
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
|
||||
winMgr->setKeyFocusWidget(mSaveList);
|
||||
winMgr->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false);
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
else if ((arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT && !mOkButtonFocus) ||
|
||||
(arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT && mOkButtonFocus))
|
||||
|
|
@ -559,18 +552,8 @@ namespace MWGui
|
|||
mOkButtonFocus = !mOkButtonFocus;
|
||||
mOkButton->setStateSelected(mOkButtonFocus);
|
||||
mCancelButton->setStateSelected(!mOkButtonFocus);
|
||||
mUsingGamepadGuiCursor = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SaveGameDialog::onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg)
|
||||
{
|
||||
if (arg.axis == SDL_CONTROLLER_AXIS_LEFTX || arg.axis == SDL_CONTROLLER_AXIS_LEFTY)
|
||||
{
|
||||
mUsingGamepadGuiCursor = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,9 +70,7 @@ namespace MWGui
|
|||
const MWState::Slot* mCurrentSlot;
|
||||
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
bool onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg) override;
|
||||
bool mOkButtonFocus = true;
|
||||
bool mUsingGamepadGuiCursor = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ namespace MWGui
|
|||
trackFocusEvents(widget);
|
||||
|
||||
mControllerButtons.b = "#{sCancel}";
|
||||
mDisableGamepadCursor = Settings::gui().mControllerMenus;
|
||||
}
|
||||
|
||||
void WaitDialog::setPtr(const MWWorld::Ptr& ptr)
|
||||
|
|
|
|||
|
|
@ -109,25 +109,25 @@ void WindowBase::clampWindowCoordinates(MyGUI::Window* window)
|
|||
void WindowBase::focusGain(MyGUI::Widget* _new, MyGUI::Widget* _old)
|
||||
{
|
||||
// REMOVEME
|
||||
Log(Debug::Verbose) << "WindowBase::focusGain new=" << _new << ", old=" << _old;
|
||||
mMouseFocus = _new;
|
||||
//Log(Debug::Verbose) << "WindowBase::focusGain new=" << _new << ", old=" << _old;
|
||||
//mMouseFocus = _new;
|
||||
}
|
||||
|
||||
void WindowBase::focusLoss(MyGUI::Widget* _old, MyGUI::Widget* _new)
|
||||
{
|
||||
// REMOVEME
|
||||
Log(Debug::Verbose) << "WindowBase::focusLoss old=" << _old << ", new=" << _new;
|
||||
if (mMouseFocus == _old)
|
||||
mMouseFocus = nullptr;
|
||||
//Log(Debug::Verbose) << "WindowBase::focusLoss old=" << _old << ", new=" << _new;
|
||||
//if (mMouseFocus == _old)
|
||||
// mMouseFocus = nullptr;
|
||||
}
|
||||
|
||||
void WindowBase::trackFocusEvents(MyGUI::Widget* widget)
|
||||
{
|
||||
if (!Settings::gui().mControllerMenus)
|
||||
return;
|
||||
// if (!Settings::gui().mControllerMenus)
|
||||
// return;
|
||||
|
||||
widget->eventMouseSetFocus += MyGUI::newDelegate(this, &WindowBase::focusGain);
|
||||
widget->eventMouseLostFocus += MyGUI::newDelegate(this, &WindowBase::focusLoss);
|
||||
// widget->eventMouseSetFocus += MyGUI::newDelegate(this, &WindowBase::focusGain);
|
||||
// widget->eventMouseLostFocus += MyGUI::newDelegate(this, &WindowBase::focusLoss);
|
||||
}
|
||||
|
||||
WindowModal::WindowModal(const std::string& parLayout)
|
||||
|
|
|
|||
|
|
@ -74,28 +74,30 @@ namespace MWGui
|
|||
|
||||
static void clampWindowCoordinates(MyGUI::Window* window);
|
||||
|
||||
/// Called by controllermanager to handle controller events
|
||||
virtual ControllerButtonStr* getControllerButtons() { return &mControllerButtons; }
|
||||
bool isGamepadCursorAllowed() { return !mDisableGamepadCursor; }
|
||||
virtual bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) { return true; };
|
||||
virtual bool onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg) { return true; };
|
||||
// REMOVEME
|
||||
// virtual bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) = 0;
|
||||
// virtual bool onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg) = 0;
|
||||
virtual ControllerButtonStr* getControllerButtons() { return &mControllerButtons; }
|
||||
virtual void setActiveControllerWindow(bool active) { mActiveControllerWindow = active; }
|
||||
|
||||
protected:
|
||||
virtual void onTitleDoubleClicked();
|
||||
|
||||
ControllerButtonStr mControllerButtons;
|
||||
MyGUI::Widget* mMouseFocus = nullptr;
|
||||
bool mActiveControllerWindow = false;
|
||||
bool mDisableGamepadCursor = false;
|
||||
|
||||
// REMOVEME
|
||||
void trackFocusEvents(MyGUI::Widget* widget);
|
||||
// REMOVEME
|
||||
MyGUI::Widget* mMouseFocus = nullptr;
|
||||
|
||||
private:
|
||||
void onDoubleClick(MyGUI::Widget* _sender);
|
||||
|
||||
bool mDisabledByLua = false;
|
||||
|
||||
// REMOVEME
|
||||
void focusGain(MyGUI::Widget* _new, MyGUI::Widget* _old);
|
||||
void focusLoss(MyGUI::Widget* _old, MyGUI::Widget* _new);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -241,11 +241,26 @@ namespace MWInput
|
|||
|
||||
bool ControllerManager::gamepadToGuiControl(const SDL_ControllerButtonEvent& arg)
|
||||
{
|
||||
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
|
||||
|
||||
if (Settings::gui().mControllerMenus)
|
||||
{
|
||||
MWGui::WindowBase* topWin = MWBase::Environment::get().getWindowManager()->getActiveControllerWindow();
|
||||
if (topWin && topWin->onControllerButtonEvent(arg))
|
||||
return true;
|
||||
// Update cursor state.
|
||||
bool treatAsMouse = winMgr->getCursorVisible();
|
||||
winMgr->setCursorActive(false);
|
||||
|
||||
MWGui::WindowBase* topWin = winMgr->getActiveControllerWindow();
|
||||
if (topWin)
|
||||
{
|
||||
mGamepadGuiCursorEnabled = topWin->isGamepadCursorAllowed();
|
||||
|
||||
// Fall through to mouse click
|
||||
if (mGamepadGuiCursorEnabled && treatAsMouse && arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
return false;
|
||||
|
||||
if (topWin->onControllerButtonEvent(arg))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Presumption of GUI mode will be removed in the future.
|
||||
|
|
@ -273,9 +288,9 @@ namespace MWInput
|
|||
break;
|
||||
case SDL_CONTROLLER_BUTTON_B:
|
||||
if (MyGUI::InputManager::getInstance().isModalAny())
|
||||
MWBase::Environment::get().getWindowManager()->exitCurrentModal();
|
||||
winMgr->exitCurrentModal();
|
||||
else
|
||||
MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode();
|
||||
winMgr->exitCurrentGuiMode();
|
||||
return true;
|
||||
case SDL_CONTROLLER_BUTTON_X:
|
||||
key = MyGUI::KeyCode::Semicolon;
|
||||
|
|
@ -285,7 +300,7 @@ namespace MWInput
|
|||
break;
|
||||
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER:
|
||||
MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::LeftShift);
|
||||
MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::Tab, 0, false);
|
||||
winMgr->injectKeyPress(MyGUI::KeyCode::Tab, 0, false);
|
||||
MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::LeftShift);
|
||||
return true;
|
||||
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER:
|
||||
|
|
@ -293,7 +308,7 @@ namespace MWInput
|
|||
return true;
|
||||
case SDL_CONTROLLER_BUTTON_LEFTSTICK:
|
||||
mGamepadGuiCursorEnabled = !mGamepadGuiCursorEnabled;
|
||||
MWBase::Environment::get().getWindowManager()->setCursorActive(mGamepadGuiCursorEnabled);
|
||||
winMgr->setCursorActive(mGamepadGuiCursorEnabled);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
|
@ -303,41 +318,61 @@ namespace MWInput
|
|||
if (SDL_IsTextInputActive())
|
||||
return false;
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->injectKeyPress(key, 0, false);
|
||||
winMgr->injectKeyPress(key, 0, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ControllerManager::gamepadToGuiControl(const SDL_ControllerAxisEvent& arg)
|
||||
{
|
||||
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
|
||||
|
||||
if (Settings::gui().mControllerMenus)
|
||||
{
|
||||
// Left and right triggers toggle through open GUI windows.
|
||||
if (arg.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT)
|
||||
{
|
||||
if (arg.value == 32767) // Treat like a button.
|
||||
MWBase::Environment::get().getWindowManager()->cycleActiveControllerWindow(true);
|
||||
winMgr->cycleActiveControllerWindow(true);
|
||||
return true;
|
||||
}
|
||||
else if (arg.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT)
|
||||
{
|
||||
if (arg.value == 32767) // Treat like a button.
|
||||
MWBase::Environment::get().getWindowManager()->cycleActiveControllerWindow(false);
|
||||
winMgr->cycleActiveControllerWindow(false);
|
||||
return true;
|
||||
}
|
||||
MWGui::WindowBase* topWin = MWBase::Environment::get().getWindowManager()->getActiveControllerWindow();
|
||||
if (topWin && topWin->onControllerThumbstickEvent(arg))
|
||||
return true;
|
||||
|
||||
MWGui::WindowBase* topWin = winMgr->getActiveControllerWindow();
|
||||
if (topWin)
|
||||
{
|
||||
// Update cursor state
|
||||
mGamepadGuiCursorEnabled = topWin->isGamepadCursorAllowed();
|
||||
if (!mGamepadGuiCursorEnabled)
|
||||
winMgr->setCursorActive(false);
|
||||
|
||||
if (mGamepadGuiCursorEnabled
|
||||
&& (arg.axis == SDL_CONTROLLER_AXIS_LEFTX || arg.axis == SDL_CONTROLLER_AXIS_LEFTY))
|
||||
{
|
||||
// Treat the left stick like a cursor. Fall through.
|
||||
return false;
|
||||
}
|
||||
else if (topWin->onControllerThumbstickEvent(arg))
|
||||
{
|
||||
// Window handled the event.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (arg.axis)
|
||||
{
|
||||
case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
|
||||
if (arg.value == 32767) // Treat like a button.
|
||||
MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::Minus, 0, false);
|
||||
winMgr->injectKeyPress(MyGUI::KeyCode::Minus, 0, false);
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
|
||||
if (arg.value == 32767) // Treat like a button.
|
||||
MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::Equals, 0, false);
|
||||
winMgr->injectKeyPress(MyGUI::KeyCode::Equals, 0, false);
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_LEFTX:
|
||||
case SDL_CONTROLLER_AXIS_LEFTY:
|
||||
|
|
|
|||
Loading…
Reference in a new issue