1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-10-25 18:56:37 +00:00

Remove old way of listening for gamepad mouse events

This commit is contained in:
Andrew Lanzone 2025-05-18 01:42:11 -07:00
parent 33a6189f7a
commit f15cc663ae
11 changed files with 19 additions and 123 deletions

View file

@ -27,19 +27,15 @@ namespace MWGui
{ {
getWidget(mCloseButton, "CloseButton"); getWidget(mCloseButton, "CloseButton");
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onCloseButtonClicked); mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onCloseButtonClicked);
trackFocusEvents(mCloseButton);
getWidget(mTakeButton, "TakeButton"); getWidget(mTakeButton, "TakeButton");
mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onTakeButtonClicked); mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onTakeButtonClicked);
trackFocusEvents(mTakeButton);
getWidget(mNextPageButton, "NextPageBTN"); getWidget(mNextPageButton, "NextPageBTN");
mNextPageButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onNextPageButtonClicked); mNextPageButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onNextPageButtonClicked);
trackFocusEvents(mNextPageButton);
getWidget(mPrevPageButton, "PrevPageBTN"); getWidget(mPrevPageButton, "PrevPageBTN");
mPrevPageButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onPrevPageButtonClicked); mPrevPageButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onPrevPageButtonClicked);
trackFocusEvents(mPrevPageButton);
getWidget(mLeftPageNumber, "LeftPageNumber"); getWidget(mLeftPageNumber, "LeftPageNumber");
getWidget(mRightPageNumber, "RightPageNumber"); getWidget(mRightPageNumber, "RightPageNumber");
@ -236,9 +232,6 @@ namespace MWGui
{ {
if (arg.button == SDL_CONTROLLER_BUTTON_A) if (arg.button == SDL_CONTROLLER_BUTTON_A)
{ {
if (mMouseFocus != nullptr)
return false;
if (mTakeButton->getVisible()) if (mTakeButton->getVisible())
onTakeButtonClicked(mTakeButton); onTakeButtonClicked(mTakeButton);
} }

View file

@ -59,8 +59,6 @@ namespace MWGui
{ {
mOkButton->setStateSelected(true); mOkButton->setStateSelected(true);
mDisableGamepadCursor = true; mDisableGamepadCursor = true;
trackFocusEvents(mBackButton);
trackFocusEvents(mOkButton);
mControllerButtons.a = "#{sSelect}"; mControllerButtons.a = "#{sSelect}";
mControllerButtons.b = "#{sBack}"; mControllerButtons.b = "#{sBack}";
} }
@ -84,9 +82,6 @@ namespace MWGui
{ {
if (arg.button == SDL_CONTROLLER_BUTTON_A) if (arg.button == SDL_CONTROLLER_BUTTON_A)
{ {
if (mMouseFocus != nullptr)
return false;
if (mOkButtonFocus) if (mOkButtonFocus)
onOkClicked(mOkButton); onOkClicked(mOkButton);
else else
@ -444,7 +439,6 @@ namespace MWGui
// First button is selected by default // First button is selected by default
button->setStateSelected(true); button->setStateSelected(true);
} }
trackFocusEvents(button);
this->mButtons.push_back(button); this->mButtons.push_back(button);
} }
@ -479,11 +473,7 @@ namespace MWGui
{ {
if (arg.button == SDL_CONTROLLER_BUTTON_A) if (arg.button == SDL_CONTROLLER_BUTTON_A)
{ {
if (mMouseFocus != nullptr)
return false;
onButtonClicked(mButtons[mControllerFocus]); onButtonClicked(mButtons[mControllerFocus]);
return true;
} }
else if (arg.button == SDL_CONTROLLER_BUTTON_B) else if (arg.button == SDL_CONTROLLER_BUTTON_B)
{ {

View file

@ -23,8 +23,6 @@ namespace MWGui
if (Settings::gui().mControllerMenus) if (Settings::gui().mControllerMenus)
{ {
mDisableGamepadCursor = true; mDisableGamepadCursor = true;
trackFocusEvents(mOkButton);
trackFocusEvents(mCancelButton);
mControllerButtons.a = "#{sOk}"; mControllerButtons.a = "#{sOk}";
mControllerButtons.b = "#{sCancel}"; mControllerButtons.b = "#{sCancel}";
} }
@ -79,9 +77,6 @@ namespace MWGui
{ {
if (arg.button == SDL_CONTROLLER_BUTTON_A) if (arg.button == SDL_CONTROLLER_BUTTON_A)
{ {
if (mMouseFocus != nullptr)
return false;
if (mOkButtonFocus) if (mOkButtonFocus)
onOkButtonClicked(mOkButton); onOkButtonClicked(mOkButton);
else else

View file

@ -210,37 +210,27 @@ namespace MWGui
bool MainMenu::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) bool MainMenu::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
{ {
// REMOVEME if (arg.button == SDL_CONTROLLER_BUTTON_A)
Log(Debug::Verbose) << "MainMenu::onControllerButtonEvent " << arg.button;
MyGUI::KeyCode key = MyGUI::KeyCode::None;
switch (arg.button)
{ {
case SDL_CONTROLLER_BUTTON_DPAD_UP: MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::Space, 0, false);
MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::LeftShift); }
MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::Tab, 0, false); else if (arg.button == SDL_CONTROLLER_BUTTON_B || arg.button == SDL_CONTROLLER_BUTTON_START)
MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::LeftShift); {
return true; if (mButtons["return"]->getVisible())
case SDL_CONTROLLER_BUTTON_DPAD_DOWN: onButtonClicked(mButtons["return"]);
key = MyGUI::KeyCode::Tab; else
break; MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::Escape, 0, false);
case SDL_CONTROLLER_BUTTON_A: }
if (mMouseFocus != nullptr) else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
return false; {
key = MyGUI::KeyCode::Space; MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::LeftShift);
break; MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::Tab, 0, false);
case SDL_CONTROLLER_BUTTON_B: MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::LeftShift);
case SDL_CONTROLLER_BUTTON_START: }
if (mButtons["return"]->getVisible()) else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
{ {
onButtonClicked(mButtons["return"]); MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::Tab, 0, false);
return true;
}
else
key = MyGUI::KeyCode::Escape;
break;
} }
MWBase::Environment::get().getWindowManager()->injectKeyPress(key, 0, false);
return true; return true;
} }
@ -344,7 +334,6 @@ namespace MWGui
button->setProperty("ImagePushed", "textures\\menu_" + buttonId + "_pressed.dds"); button->setProperty("ImagePushed", "textures\\menu_" + buttonId + "_pressed.dds");
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MainMenu::onButtonClicked); button->eventMouseButtonClick += MyGUI::newDelegate(this, &MainMenu::onButtonClicked);
button->setUserData(buttonId); button->setUserData(buttonId);
trackFocusEvents(button);
} }
} }

View file

@ -260,7 +260,6 @@ namespace MWGui
button->setCaptionWithReplacing(buttonId); button->setCaptionWithReplacing(buttonId);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed); button->eventMouseButtonClick += MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed);
trackFocusEvents(button);
mButtons.push_back(button); mButtons.push_back(button);
@ -447,11 +446,7 @@ namespace MWGui
{ {
if (arg.button == SDL_CONTROLLER_BUTTON_A) if (arg.button == SDL_CONTROLLER_BUTTON_A)
{ {
if (mMouseFocus != nullptr)
return false;
buttonActivated(mButtons[mControllerFocus]); buttonActivated(mButtons[mControllerFocus]);
return true;
} }
else if (arg.button == SDL_CONTROLLER_BUTTON_B) else if (arg.button == SDL_CONTROLLER_BUTTON_B)
{ {

View file

@ -46,28 +46,24 @@ namespace MWGui
getWidget(button, "NameButton"); getWidget(button, "NameButton");
adjustButtonSize(button); adjustButtonSize(button);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onNameClicked); button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onNameClicked);
trackFocusEvents(button);
mButtons.push_back(button); mButtons.push_back(button);
getWidget(mRaceWidget, "RaceText"); getWidget(mRaceWidget, "RaceText");
getWidget(button, "RaceButton"); getWidget(button, "RaceButton");
adjustButtonSize(button); adjustButtonSize(button);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked); button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked);
trackFocusEvents(button);
mButtons.push_back(button); mButtons.push_back(button);
getWidget(mClassWidget, "ClassText"); getWidget(mClassWidget, "ClassText");
getWidget(button, "ClassButton"); getWidget(button, "ClassButton");
adjustButtonSize(button); adjustButtonSize(button);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onClassClicked); button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onClassClicked);
trackFocusEvents(button);
mButtons.push_back(button); mButtons.push_back(button);
getWidget(mBirthSignWidget, "SignText"); getWidget(mBirthSignWidget, "SignText");
getWidget(button, "SignButton"); getWidget(button, "SignButton");
adjustButtonSize(button); adjustButtonSize(button);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked); button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked);
trackFocusEvents(button);
mButtons.push_back(button); mButtons.push_back(button);
// Setup dynamic stats // Setup dynamic stats
@ -116,13 +112,11 @@ namespace MWGui
MyGUI::Button* backButton; MyGUI::Button* backButton;
getWidget(backButton, "BackButton"); getWidget(backButton, "BackButton");
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBackClicked); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBackClicked);
trackFocusEvents(backButton);
mButtons.push_back(backButton); mButtons.push_back(backButton);
MyGUI::Button* okButton; MyGUI::Button* okButton;
getWidget(okButton, "OKButton"); getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onOkClicked); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onOkClicked);
trackFocusEvents(okButton);
mButtons.push_back(okButton); mButtons.push_back(okButton);
if (Settings::gui().mControllerMenus) if (Settings::gui().mControllerMenus)
@ -546,9 +540,6 @@ namespace MWGui
{ {
if (arg.button == SDL_CONTROLLER_BUTTON_A) if (arg.button == SDL_CONTROLLER_BUTTON_A)
{ {
if (mMouseFocus != nullptr)
return false;
switch(mControllerFocus) switch(mControllerFocus)
{ {
case 0: case 0:

View file

@ -64,8 +64,6 @@ namespace MWGui
// To avoid accidental deletions // To avoid accidental deletions
mDeleteButton->setNeedKeyFocus(false); mDeleteButton->setNeedKeyFocus(false);
trackFocusEvents(mCancelButton);
trackFocusEvents(mDeleteButton);
mControllerButtons.a = "#{sSelect}"; mControllerButtons.a = "#{sSelect}";
mControllerButtons.b = "#{sClose}"; mControllerButtons.b = "#{sClose}";
} }
@ -371,12 +369,6 @@ namespace MWGui
} }
else else
onSlotSelected(mSaveList, MyGUI::ITEM_NONE); onSlotSelected(mSaveList, MyGUI::ITEM_NONE);
if (Settings::gui().mControllerMenus)
{
for (int i = 0; i < mSaveList->getItemCount(); i++)
trackFocusEvents(mSaveList->getWidgetByIndex(i));
}
} }
std::string formatTimeplayed(const double timeInSeconds) std::string formatTimeplayed(const double timeInSeconds)

View file

@ -29,11 +29,9 @@ namespace MWGui
getWidget(mCloseButton, "CloseButton"); getWidget(mCloseButton, "CloseButton");
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ScrollWindow::onCloseButtonClicked); mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ScrollWindow::onCloseButtonClicked);
trackFocusEvents(mCloseButton);
getWidget(mTakeButton, "TakeButton"); getWidget(mTakeButton, "TakeButton");
mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ScrollWindow::onTakeButtonClicked); mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ScrollWindow::onTakeButtonClicked);
trackFocusEvents(mTakeButton);
adjustButton("CloseButton"); adjustButton("CloseButton");
adjustButton("TakeButton"); adjustButton("TakeButton");
@ -139,9 +137,6 @@ namespace MWGui
{ {
if (arg.button == SDL_CONTROLLER_BUTTON_A) if (arg.button == SDL_CONTROLLER_BUTTON_A)
{ {
if (mMouseFocus != nullptr)
return false;
if (mTakeButton->getVisible()) if (mTakeButton->getVisible())
onTakeButtonClicked(mTakeButton); onTakeButtonClicked(mTakeButton);
} }

View file

@ -81,12 +81,6 @@ namespace MWGui
mTimeAdvancer.eventInterrupted += MyGUI::newDelegate(this, &WaitDialog::onWaitingInterrupted); mTimeAdvancer.eventInterrupted += MyGUI::newDelegate(this, &WaitDialog::onWaitingInterrupted);
mTimeAdvancer.eventFinished += MyGUI::newDelegate(this, &WaitDialog::onWaitingFinished); mTimeAdvancer.eventFinished += MyGUI::newDelegate(this, &WaitDialog::onWaitingFinished);
trackFocusEvents(mUntilHealedButton);
trackFocusEvents(mWaitButton);
trackFocusEvents(mCancelButton);
for (MyGUI::Widget* widget : mHourSlider->getAllWidgets())
trackFocusEvents(widget);
mControllerButtons.b = "#{sCancel}"; mControllerButtons.b = "#{sCancel}";
mDisableGamepadCursor = Settings::gui().mControllerMenus; mDisableGamepadCursor = Settings::gui().mControllerMenus;
} }
@ -345,12 +339,7 @@ namespace MWGui
bool WaitDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) bool WaitDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
{ {
if (arg.button == SDL_CONTROLLER_BUTTON_A) if (arg.button == SDL_CONTROLLER_BUTTON_A)
{
if (mMouseFocus != nullptr)
return false;
onWaitButtonClicked(mWaitButton); onWaitButtonClicked(mWaitButton);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_B) else if (arg.button == SDL_CONTROLLER_BUTTON_B)
onCancelButtonClicked(mCancelButton); onCancelButtonClicked(mCancelButton);
else if (arg.button == SDL_CONTROLLER_BUTTON_X && mUntilHealedButton->getVisible()) else if (arg.button == SDL_CONTROLLER_BUTTON_X && mUntilHealedButton->getVisible())

View file

@ -106,30 +106,6 @@ void WindowBase::clampWindowCoordinates(MyGUI::Window* window)
window->setPosition(left, top); window->setPosition(left, top);
} }
void WindowBase::focusGain(MyGUI::Widget* _new, MyGUI::Widget* _old)
{
// REMOVEME
//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;
}
void WindowBase::trackFocusEvents(MyGUI::Widget* widget)
{
// if (!Settings::gui().mControllerMenus)
// return;
// widget->eventMouseSetFocus += MyGUI::newDelegate(this, &WindowBase::focusGain);
// widget->eventMouseLostFocus += MyGUI::newDelegate(this, &WindowBase::focusLoss);
}
WindowModal::WindowModal(const std::string& parLayout) WindowModal::WindowModal(const std::string& parLayout)
: WindowBase(parLayout) : WindowBase(parLayout)
{ {

View file

@ -87,19 +87,10 @@ namespace MWGui
bool mActiveControllerWindow = false; bool mActiveControllerWindow = false;
bool mDisableGamepadCursor = false; bool mDisableGamepadCursor = false;
// REMOVEME
void trackFocusEvents(MyGUI::Widget* widget);
// REMOVEME
MyGUI::Widget* mMouseFocus = nullptr;
private: private:
void onDoubleClick(MyGUI::Widget* _sender); void onDoubleClick(MyGUI::Widget* _sender);
bool mDisabledByLua = false; bool mDisabledByLua = false;
// REMOVEME
void focusGain(MyGUI::Widget* _new, MyGUI::Widget* _old);
void focusLoss(MyGUI::Widget* _old, MyGUI::Widget* _new);
}; };
/* /*