From 44e30b14a3a0301022de23f3ffbdae7295cba017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 4 Feb 2026 14:23:24 +0100 Subject: [PATCH] Split the screen between the two gesture input zones. --- UI/GamepadEmu.cpp | 11 +++++++++-- UI/GamepadEmu.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index e44c2703ff..cdb76b36de 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -1032,7 +1032,10 @@ GamepadEmuView::GamepadEmuView(const TouchControlConfig &config, float xres, flo // Add the two gesture zones. for (int i = 0; i < 2; i++) { if (g_Config.gestureControls[i].bGestureControlEnabled) { - Add(new GestureGamepad(controlMapper, i)); + // We have them both cover the whole surface, then limit in the touch handler. + // This is because there's no easy way to do "half the screen" in AnchorLayout. + // We can do more complex layout combinations, but meh. + Add(new GestureGamepad(controlMapper, i, new AnchorLayoutParams(FILL_PARENT, FILL_PARENT, 0.0f, 0.0f, 0.0f, 0.0f))); } } } @@ -1076,7 +1079,11 @@ bool GestureGamepad::Touch(const TouchInput &input) { } if (input.flags & TouchInputFlags::DOWN) { - if (dragPointerId_ == -1) { + // Handle the zones here, easier than with AnchorLayout. + const float minX = zoneIndex_ == 0 ? 0.0f : bounds_.w * 0.5f; + const float maxX = zoneIndex_ == 0 ? bounds_.w * 0.5f : bounds_.w; + + if (dragPointerId_ == -1 && input.x >= minX && input.x < maxX) { dragPointerId_ = input.id; lastX_ = input.x; lastY_ = input.y; diff --git a/UI/GamepadEmu.h b/UI/GamepadEmu.h index 33778e1812..7b305082b0 100644 --- a/UI/GamepadEmu.h +++ b/UI/GamepadEmu.h @@ -210,7 +210,7 @@ struct GestureControlConfig; class GestureGamepad : public UI::View { public: - explicit GestureGamepad(ControlMapper* controlMapper, int zoneIndex) : controlMapper_(controlMapper), zoneIndex_(zoneIndex) {} + explicit GestureGamepad(ControlMapper* controlMapper, int zoneIndex, UI::LayoutParams *layoutParams) : UI::View(layoutParams), controlMapper_(controlMapper), zoneIndex_(zoneIndex) {} bool Touch(const TouchInput &input) override; void Update() override;