1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-10-22 15:26: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");
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onCloseButtonClicked);
trackFocusEvents(mCloseButton);
getWidget(mTakeButton, "TakeButton");
mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onTakeButtonClicked);
trackFocusEvents(mTakeButton);
getWidget(mNextPageButton, "NextPageBTN");
mNextPageButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onNextPageButtonClicked);
trackFocusEvents(mNextPageButton);
getWidget(mPrevPageButton, "PrevPageBTN");
mPrevPageButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onPrevPageButtonClicked);
trackFocusEvents(mPrevPageButton);
getWidget(mLeftPageNumber, "LeftPageNumber");
getWidget(mRightPageNumber, "RightPageNumber");
@ -236,9 +232,6 @@ namespace MWGui
{
if (arg.button == SDL_CONTROLLER_BUTTON_A)
{
if (mMouseFocus != nullptr)
return false;
if (mTakeButton->getVisible())
onTakeButtonClicked(mTakeButton);
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -64,8 +64,6 @@ namespace MWGui
// To avoid accidental deletions
mDeleteButton->setNeedKeyFocus(false);
trackFocusEvents(mCancelButton);
trackFocusEvents(mDeleteButton);
mControllerButtons.a = "#{sSelect}";
mControllerButtons.b = "#{sClose}";
}
@ -371,12 +369,6 @@ namespace MWGui
}
else
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)

View file

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

View file

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

View file

@ -87,19 +87,10 @@ namespace MWGui
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);
};
/*