diff --git a/Core/Config.cpp b/Core/Config.cpp index c03217a517..77dd667677 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -682,16 +682,16 @@ bool GestureControlConfig::ResetToDefault(std::string_view blockName) { // These were previously mostly part of General (which was wrong). static const ConfigSetting gestureControlSettings[] = { - ConfigSetting("SwipeUp", SETTING(g_Config.gestureControlsZone1, iSwipeUp), 0, CfgFlag::PER_GAME), - ConfigSetting("SwipeDown", SETTING(g_Config.gestureControlsZone1, iSwipeDown), 0, CfgFlag::PER_GAME), - ConfigSetting("SwipeLeft", SETTING(g_Config.gestureControlsZone1, iSwipeLeft), 0, CfgFlag::PER_GAME), - ConfigSetting("SwipeRight", SETTING(g_Config.gestureControlsZone1, iSwipeRight), 0, CfgFlag::PER_GAME), - ConfigSetting("SwipeSensitivity", SETTING(g_Config.gestureControlsZone1, fSwipeSensitivity), 1.0f, CfgFlag::PER_GAME), - ConfigSetting("SwipeSmoothing", SETTING(g_Config.gestureControlsZone1, fSwipeSmoothing), 0.3f, CfgFlag::PER_GAME), - ConfigSetting("DoubleTapGesture", SETTING(g_Config.gestureControlsZone1, iDoubleTapGesture), 0, CfgFlag::PER_GAME), - ConfigSetting("GestureControlEnabled", SETTING(g_Config.gestureControlsZone1, bGestureControlEnabled), false, CfgFlag::PER_GAME), - ConfigSetting("AnalogGesture", SETTING(g_Config.gestureControlsZone1, bAnalogGesture), false, CfgFlag::PER_GAME), - ConfigSetting("AnalogGestureSensibility", SETTING(g_Config.gestureControlsZone1, fAnalogGestureSensibility), 1.0f, CfgFlag::PER_GAME), + ConfigSetting("SwipeUp", SETTING(g_Config.gestureControls[0], iSwipeUp), 0, CfgFlag::PER_GAME), + ConfigSetting("SwipeDown", SETTING(g_Config.gestureControls[0], iSwipeDown), 0, CfgFlag::PER_GAME), + ConfigSetting("SwipeLeft", SETTING(g_Config.gestureControls[0], iSwipeLeft), 0, CfgFlag::PER_GAME), + ConfigSetting("SwipeRight", SETTING(g_Config.gestureControls[0], iSwipeRight), 0, CfgFlag::PER_GAME), + ConfigSetting("SwipeSensitivity", SETTING(g_Config.gestureControls[0], fSwipeSensitivity), 1.0f, CfgFlag::PER_GAME), + ConfigSetting("SwipeSmoothing", SETTING(g_Config.gestureControls[0], fSwipeSmoothing), 0.3f, CfgFlag::PER_GAME), + ConfigSetting("DoubleTapGesture", SETTING(g_Config.gestureControls[0], iDoubleTapGesture), 0, CfgFlag::PER_GAME), + ConfigSetting("GestureControlEnabled", SETTING(g_Config.gestureControls[0], bGestureControlEnabled), false, CfgFlag::PER_GAME), + ConfigSetting("AnalogGesture", SETTING(g_Config.gestureControls[0], bAnalogGesture), false, CfgFlag::PER_GAME), + ConfigSetting("AnalogGestureSensibility", SETTING(g_Config.gestureControls[0], fAnalogGestureSensibility), 1.0f, CfgFlag::PER_GAME), }; static const ConfigSetting graphicsSettings[] = { @@ -1150,7 +1150,8 @@ static const ConfigSectionMeta g_sectionMeta[] = { { &g_Config.displayLayoutPortrait, displayLayoutSettings, ARRAY_SIZE(displayLayoutSettings), "DisplayLayout.Portrait"}, // These we don't want to read from the old settings, since for most people, those settings will be bad. { &g_Config.touchControlsLandscape, touchControlSettings, ARRAY_SIZE(touchControlSettings), "TouchControls.Landscape", "Control" }, // We read the old settings from [Control], since most people played in landscape before. { &g_Config.touchControlsPortrait, touchControlSettings, ARRAY_SIZE(touchControlSettings), "TouchControls.Portrait"}, // These we don't want to read from the old settings, since for most people, those settings will be bad. - { &g_Config.gestureControlsZone1, gestureControlSettings, ARRAY_SIZE(gestureControlSettings), "GestureControls.Zone1", "General"}, // We read the old settings from [General], since most of them used to be there (except the analog stuff). + { &g_Config.gestureControls[0], gestureControlSettings, ARRAY_SIZE(gestureControlSettings), "GestureControls.Left", "General"}, // We read the old settings from [General], since most of them used to be there (except the analog stuff). + { &g_Config.gestureControls[1], gestureControlSettings, ARRAY_SIZE(gestureControlSettings), "GestureControls.Right", "General"}, // We read the old settings from [General], since most of them used to be there (except the analog stuff). }; ConfigBlock *GetConfigBlockForSection(std::string_view sectionName) { diff --git a/Core/Config.h b/Core/Config.h index 6ac3158976..a7c19532c1 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -462,8 +462,8 @@ public: bool bRightAnalogCustom; bool bRightAnalogDisableDiagonal; - // Currently only one zone, but we will split this into left/right probably. - GestureControlConfig gestureControlsZone1; + // 0 for left, 1 for right + GestureControlConfig gestureControls[2]; // Controls Visibility bool bShowTouchControls = false; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 99ca53f3ad..b259fd8a22 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -2010,13 +2010,13 @@ void HostnameSelectScreen::OnCompleted(DialogResult result) { } void GestureMappingScreen::CreateTabs() { - auto co = GetI18NCategory(I18NCat::CONTROLS); - AddTab("Gesture", co->T("Gesture"), [this](UI::LinearLayout *parent) { CreateGestureTab(parent); }); + auto di = GetI18NCategory(I18NCat::DIALOG); + AddTab("Gesture", di->T("Left side"), [this](UI::LinearLayout *parent) { CreateGestureTab(parent, 0, GetDeviceOrientation() == DeviceOrientation::Portrait); }); + AddTab("Gesture", di->T("Right side"), [this](UI::LinearLayout *parent) { CreateGestureTab(parent, 1, GetDeviceOrientation() == DeviceOrientation::Portrait); }); } -void GestureMappingScreen::CreateGestureTab(UI::LinearLayout *vert) { +void GestureMappingScreen::CreateGestureTab(UI::LinearLayout *vert, int zoneIndex, bool portrait) { using namespace UI; - auto di = GetI18NCategory(I18NCat::DIALOG); auto co = GetI18NCategory(I18NCat::CONTROLS); auto mc = GetI18NCategory(I18NCat::MAPPABLECONTROLS); @@ -2027,8 +2027,13 @@ void GestureMappingScreen::CreateGestureTab(UI::LinearLayout *vert) { gestureButton[i] = KeyMap::GetPspButtonNameCharPointer(GestureKey::keyList[i - 1]); } - GestureControlConfig &zone = g_Config.gestureControlsZone1; + GestureControlConfig &zone = g_Config.gestureControls[zoneIndex]; + TopBarFlags flags = TopBarFlags::NoBackButton; + if (portrait) { + flags |= TopBarFlags::Portrait; + } + vert->Add(new TopBar(*screenManager()->getUIContext(), flags, ApplySafeSubstitutions("%1: %2", co->T("Gesture"), di->T(zoneIndex == 0 ? "Left side" : "Right side")))); vert->Add(new CheckBox(&zone.bGestureControlEnabled, co->T("Enable gesture control"))); vert->Add(new ItemHeader(co->T("Swipe"))); diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 47c248cb79..9dd1c9d617 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -181,7 +181,7 @@ public: const char *tag() const override { return "GestureMapping"; } bool ShowSearchControls() const override { return false; } protected: - void CreateGestureTab(UI::LinearLayout *parent); + void CreateGestureTab(UI::LinearLayout *parent, int zoneIndex, bool portrait); }; class RestoreSettingsScreen : public UI::PopupScreen { diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index 943b0a9de4..e44c2703ff 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -1029,8 +1029,11 @@ GamepadEmuView::GamepadEmuView(const TouchControlConfig &config, float xres, flo addCustomButton(g_Config.CustomButton[i], temp, config.touchCustom[i]); } - if (g_Config.gestureControlsZone1.bGestureControlEnabled) { - Add(new GestureGamepad(controlMapper)); + // Add the two gesture zones. + for (int i = 0; i < 2; i++) { + if (g_Config.gestureControls[i].bGestureControlEnabled) { + Add(new GestureGamepad(controlMapper, i)); + } } } @@ -1055,7 +1058,7 @@ void GamepadEmuView::Update() { const GestureControlConfig &GestureGamepad::GetZone() { // TODO: Add support for multiple zones. - return g_Config.gestureControlsZone1; + return g_Config.gestureControls[zoneIndex_]; } bool GestureGamepad::Touch(const TouchInput &input) { diff --git a/UI/GamepadEmu.h b/UI/GamepadEmu.h index e00c6835a0..33778e1812 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) : controlMapper_(controlMapper) {} + explicit GestureGamepad(ControlMapper* controlMapper, int zoneIndex) : controlMapper_(controlMapper), zoneIndex_(zoneIndex) {} bool Touch(const TouchInput &input) override; void Update() override; @@ -219,6 +219,7 @@ public: private: const GestureControlConfig &GetZone(); + int zoneIndex_; float lastX_ = 0.0f; float lastY_ = 0.0f; float deltaX_ = 0.0f; diff --git a/UI/MiscViews.cpp b/UI/MiscViews.cpp index 0afdfca848..fa66571c0e 100644 --- a/UI/MiscViews.cpp +++ b/UI/MiscViews.cpp @@ -51,11 +51,15 @@ TopBar::TopBar(const UIContext &ctx, TopBarFlags flags, std::string_view title, layoutParams_->height = 64.0f; } - auto dlg = GetI18NCategory(I18NCat::DIALOG); - backButton_ = Add(new Choice(ImageID("I_NAVIGATE_BACK"), new LinearLayoutParams(ITEM_HEIGHT, ITEM_HEIGHT))); - backButton_->OnClick.Add([](UI::EventParams &e) { - e.bubbleResult = DR_BACK; - }); + if (!(flags & TopBarFlags::NoBackButton)) { + auto dlg = GetI18NCategory(I18NCat::DIALOG); + backButton_ = Add(new Choice(ImageID("I_NAVIGATE_BACK"), new LinearLayoutParams(ITEM_HEIGHT, ITEM_HEIGHT))); + backButton_->OnClick.Add([](UI::EventParams &e) { + e.bubbleResult = DR_BACK; + }); + } else { + Add(new Spacer(4.0f)); + } if (!title.empty()) { TextView *titleView = Add(new TextView(title, ALIGN_VCENTER, false, new LinearLayoutParams(1.0f, Gravity::G_VCENTER))); diff --git a/UI/MiscViews.h b/UI/MiscViews.h index 20775a6f73..cc852e8516 100644 --- a/UI/MiscViews.h +++ b/UI/MiscViews.h @@ -21,6 +21,7 @@ enum class TopBarFlags { Default = 0, Portrait = 1, ContextMenuButton = 2, + NoBackButton = 4, }; ENUM_CLASS_BITOPS(TopBarFlags);