diff --git a/apps/openmw/mwgui/enchantingdialog.cpp b/apps/openmw/mwgui/enchantingdialog.cpp index af4a3e8ce3..d0d9fb7401 100644 --- a/apps/openmw/mwgui/enchantingdialog.cpp +++ b/apps/openmw/mwgui/enchantingdialog.cpp @@ -59,6 +59,12 @@ namespace MWGui mBuyButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onBuyButtonClicked); mTypeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onTypeButtonClicked); mName->eventEditSelectAccept += MyGUI::newDelegate(this, &EnchantingDialog::onAccept); + + mControllerButtons.a = "#{sSelect}"; + mControllerButtons.b = "#{sBack}"; + mControllerButtons.y = "Cast Type"; + mControllerButtons.l1 = "#{sItem}"; + mControllerButtons.r1 = "#{sSoulGem}"; } void EnchantingDialog::onOpen() @@ -152,6 +158,7 @@ namespace MWGui mEnchanting.setSelfEnchanting(false); mEnchanting.setEnchanter(ptr); mBuyButton->setCaptionWithReplacing("#{sBuy}"); + mControllerButtons.x = "#{sBuy}"; mChanceLayout->setVisible(false); mPtr = ptr; setSoulGem(MWWorld::Ptr()); @@ -163,6 +170,7 @@ namespace MWGui mEnchanting.setSelfEnchanting(true); mEnchanting.setEnchanter(MWMechanics::getPlayer()); mBuyButton->setCaptionWithReplacing("#{sCreate}"); + mControllerButtons.x = "#{sCreate}"; mChanceLayout->setVisible(Settings::game().mShowEnchantChance); mPtr = MWMechanics::getPlayer(); setSoulGem(ptr); @@ -382,4 +390,22 @@ namespace MWGui } } } + + bool EnchantingDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) + { + if (arg.button == SDL_CONTROLLER_BUTTON_B) + onCancelButtonClicked(mCancelButton); + else if (arg.button == SDL_CONTROLLER_BUTTON_X) + onBuyButtonClicked(mBuyButton); + else if (arg.button == SDL_CONTROLLER_BUTTON_Y) + onTypeButtonClicked(mTypeButton); + else if (arg.button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER) + onSelectItem(mItemBox); + else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) + onSelectSoul(mSoulBox); + else + return EffectEditorBase::onControllerButtonEvent(arg); + + return true; + } } diff --git a/apps/openmw/mwgui/enchantingdialog.hpp b/apps/openmw/mwgui/enchantingdialog.hpp index 4c720a11fc..3cda350152 100644 --- a/apps/openmw/mwgui/enchantingdialog.hpp +++ b/apps/openmw/mwgui/enchantingdialog.hpp @@ -73,6 +73,8 @@ namespace MWGui MWMechanics::Enchanting mEnchanting; ESM::EffectList mEffectList; + + bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override; }; } diff --git a/apps/openmw/mwgui/itemselection.cpp b/apps/openmw/mwgui/itemselection.cpp index 4fe40ce693..86d584f24d 100644 --- a/apps/openmw/mwgui/itemselection.cpp +++ b/apps/openmw/mwgui/itemselection.cpp @@ -3,6 +3,8 @@ #include #include +#include + #include "inventoryitemmodel.hpp" #include "itemview.hpp" #include "sortfilteritemmodel.hpp" @@ -26,6 +28,9 @@ namespace MWGui cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemSelectionDialog::onCancelButtonClicked); center(); + + mControllerButtons.a = "#{sSelect}"; + mControllerButtons.b = "#{sBack}"; } bool ItemSelectionDialog::exit() @@ -40,6 +45,8 @@ namespace MWGui mSortModel = sortModel.get(); mItemView->setModel(std::move(sortModel)); mItemView->resetScrollBars(); + if (Settings::gui().mControllerMenus) + mItemView->setActiveControllerWindow(true); } void ItemSelectionDialog::setCategory(int category) @@ -65,4 +72,13 @@ namespace MWGui exit(); } + bool ItemSelectionDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) + { + if (arg.button == SDL_CONTROLLER_BUTTON_B) + onCancelButtonClicked(nullptr); + else + mItemView->onControllerButtonEvent(arg.button); + + return true; + } } diff --git a/apps/openmw/mwgui/itemselection.hpp b/apps/openmw/mwgui/itemselection.hpp index fe87d7e38a..83af6d4840 100644 --- a/apps/openmw/mwgui/itemselection.hpp +++ b/apps/openmw/mwgui/itemselection.hpp @@ -41,6 +41,7 @@ namespace MWGui void onSelectedItem(int index); void onCancelButtonClicked(MyGUI::Widget* sender); + bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override; }; }