From 2c207aedf8d6e6a4198b79a3a61dad00a89644df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 28 Feb 2026 11:11:17 +0100 Subject: [PATCH] Fix problem where the touch screen controls got reactivated by gamepad input --- UI/GamepadEmu.cpp | 22 +++++++++++++--------- UI/GamepadEmu.h | 20 ++++++++++---------- UI/ImDebugger/ImMemView.cpp | 2 +- UI/TouchControlLayoutScreen.cpp | 2 +- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index 0ce662d311..6189e4c82f 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -177,7 +177,7 @@ void MultiTouchButton::Draw(UIContext &dc) { return; float scale = scale_; - if (IsDown()) { + if (IsDownVisually()) { if (g_Config.iTouchButtonStyle == 2) { opacity *= 1.35f; } else { @@ -190,7 +190,7 @@ void MultiTouchButton::Draw(UIContext &dc) { uint32_t downBg = colorAlpha(0xFFFFFF, opacity * 0.5f); uint32_t color = colorAlpha(0xFFFFFF, opacity); - if (IsDown() && g_Config.iTouchButtonStyle == 2) { + if (IsDownVisually() && g_Config.iTouchButtonStyle == 2) { if (bgImg_ != bgDownImg_) dc.Draw()->DrawImageRotated(bgDownImg_, bounds_.centerX(), bounds_.centerY(), scale, bgAngle_ * (M_PI * 2 / 360.0f), downBg, flipImageH_); } @@ -237,19 +237,23 @@ bool PSPButton::Touch(const TouchInput &input) { return retval; } -bool CustomButton::IsDown() const { +bool CustomButton::IsDownVisually() const { return (toggle_ && on_) || (!toggle_ && pointerDownMask_ != 0); } -bool CustomButton::IsDownForFadeoutCheck() const { +bool CustomButton::IsDownByTouch() const { // This check is due to a stupid mistake, see the header. #ifdef MOBILE_DEVICE constexpr int bitNumber = 36; #else constexpr int bitNumber = 38; #endif - const bool down = IsDown() && !(pspButtonBit_ & (1ULL << bitNumber)); // VIRTKEY_TOGGLE_TOUCH_CONTROLS from g_customKeyList - return down; + if (pspButtonBit_ & (1ULL << bitNumber)) { + return false; + } + // VIRTKEY_TOGGLE_TOUCH_CONTROLS from g_customKeyList + + return !toggle_ && pointerDownMask_ != 0; } void CustomButton::GetContentDimensions(const UIContext &dc, float &w, float &h) const { @@ -322,7 +326,7 @@ void CustomButton::Update() { } } -bool PSPButton::IsDown() const { +bool PSPButton::IsDownVisually() const { return (__CtrlPeekButtonsVisual() & pspButtonBit_) != 0; } @@ -1110,8 +1114,8 @@ void GamepadEmuView::Update() { bool anyDown = false; for (auto view : views_) { GamepadComponent *component = dynamic_cast(view); - if (component && component->IsDownForFadeoutCheck()) { - // INFO_LOG(Log::System, "GamepadEmuView::Update: component is down for fadeout check: %s", component->DescribeText().c_str()); + if (component && component->IsDownByTouch()) { + // INFO_LOG(Log::System, "GamepadEmuView::Update: component is down by touch: %s", component->DescribeText().c_str()); anyDown = true; } } diff --git a/UI/GamepadEmu.h b/UI/GamepadEmu.h index fe29d6fd54..6a49ee07a4 100644 --- a/UI/GamepadEmu.h +++ b/UI/GamepadEmu.h @@ -43,9 +43,8 @@ public: return false; } std::string DescribeText() const override; - virtual bool IsDown() const = 0; - virtual bool IsDownForFadeoutCheck() const { - return IsDown(); + virtual bool IsDownByTouch() const { + return false; } protected: @@ -61,7 +60,8 @@ public: bool Touch(const TouchInput &input) override; void Draw(UIContext &dc) override; void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; - bool IsDown() const override { return pointerDownMask_ != 0; } + virtual bool IsDownVisually() const { return false; } + bool IsDownByTouch() const override { return pointerDownMask_ != 0; } // chainable MultiTouchButton *FlipImageH(bool flip) { flipImageH_ = flip; return this; } @@ -91,7 +91,7 @@ public: : MultiTouchButton(key, bgImg, bgDownImg, img, scale, layoutParams), value_(value) { } bool Touch(const TouchInput &input) override; - bool IsDown() const override { return *value_; } + bool IsDownVisually() const override { return *value_; } UI::Event OnChange; @@ -105,7 +105,7 @@ public: : MultiTouchButton(key, bgImg, bgDownImg, img, scale, layoutParams), pspButtonBit_(pspButtonBit) { } bool Touch(const TouchInput &input) override; - bool IsDown() const override; + bool IsDownVisually() const override; private: int pspButtonBit_; @@ -118,7 +118,7 @@ public: bool Touch(const TouchInput &input) override; void Draw(UIContext &dc) override; void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; - bool IsDown() const override { return down_ != 0; } + bool IsDownByTouch() const override { return down_ != 0; } private: void ProcessTouch(float x, float y, bool down, bool ignorePress); @@ -140,7 +140,7 @@ public: bool Touch(const TouchInput &input) override; void Draw(UIContext &dc) override; void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; - bool IsDown() const override { return dragPointerId_ != -1; } + bool IsDownByTouch() const override { return dragPointerId_ != -1; } protected: int dragPointerId_ = -1; @@ -191,8 +191,8 @@ public: bool Touch(const TouchInput &input) override; void Update() override; - bool IsDown() const override; // For visual purpose - bool IsDownForFadeoutCheck() const override; + bool IsDownVisually() const override; // For visual purpose + bool IsDownByTouch() const override; void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; private: diff --git a/UI/ImDebugger/ImMemView.cpp b/UI/ImDebugger/ImMemView.cpp index 5e5f4694a0..3d7d05d2ab 100644 --- a/UI/ImDebugger/ImMemView.cpp +++ b/UI/ImDebugger/ImMemView.cpp @@ -884,7 +884,7 @@ MemorySearchStatus ImMemView::search(bool continueSearch) { continue; int index = memSearch_.searchAddress - memSearch_.segmentStart; - int endIndex = memSearch_.segmentEnd - memSearch_.segmentStart - size; + int endIndex = memSearch_.segmentEnd - memSearch_.segmentStart - (int)size; while (index < endIndex) { if (memcmp(&dataPointer[index], data, size) == 0) { memSearch_.matchAddress = index + memSearch_.segmentStart; diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index c4d4a91bc9..c28982ec35 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -49,7 +49,7 @@ public: scale_ = theScale_; } - bool IsDown() const override { + bool IsDownVisually() const override { // Don't want the button to enlarge and throw the user's perspective // of button size off whack. Also, the other purpose of IsDown is to prevent auto-hide, // but it's not relevant here.