From 5e09d57b6c33c9c4a4c2342a2e3d694abf202cdf Mon Sep 17 00:00:00 2001 From: LunaMoo Date: Thu, 18 Jul 2019 03:16:46 +0200 Subject: [PATCH 1/2] Add right analog for touch controls. --- Core/Config.cpp | 2 ++ Core/Config.h | 1 + UI/GamepadEmu.cpp | 12 ++++++++++++ UI/TouchControlLayoutScreen.cpp | 3 +++ UI/TouchControlVisibilityScreen.cpp | 1 + 5 files changed, 19 insertions(+) diff --git a/Core/Config.cpp b/Core/Config.cpp index da0218a9ed1a..863980f063fb 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -859,6 +859,7 @@ static ConfigSetting controlSettings[] = { ConfigSetting("LKeyX", "LKeyY", "LKeyScale", "ShowTouchLTrigger", &g_Config.touchLKey, defaultTouchPosShow, true, true), ConfigSetting("RKeyX", "RKeyY", "RKeyScale", "ShowTouchRTrigger", &g_Config.touchRKey, defaultTouchPosShow, true, true), ConfigSetting("AnalogStickX", "AnalogStickY", "AnalogStickScale", "ShowAnalogStick", &g_Config.touchAnalogStick, defaultTouchPosShow, true, true), + ConfigSetting("RightAnalogStickX", "RightAnalogStickY", "RightAnalogStickScale", "ShowRightAnalogStick", &g_Config.touchRightAnalogStick, defaultTouchPosHide, true, true), ConfigSetting("fcombo0X", "fcombo0Y", "comboKeyScale0", "ShowComboKey0", &g_Config.touchCombo0, defaultTouchPosHide, true, true), ConfigSetting("fcombo1X", "fcombo1Y", "comboKeyScale1", "ShowComboKey1", &g_Config.touchCombo1, defaultTouchPosHide, true, true), @@ -1575,6 +1576,7 @@ void Config::ResetControlLayout() { reset(g_Config.touchLKey); reset(g_Config.touchRKey); reset(g_Config.touchAnalogStick); + reset(g_Config.touchRightAnalogStick); reset(g_Config.touchCombo0); reset(g_Config.touchCombo1); reset(g_Config.touchCombo2); diff --git a/Core/Config.h b/Core/Config.h index a81a7f05e86f..30b1b99359d2 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -287,6 +287,7 @@ struct Config { ConfigTouchPos touchLKey; ConfigTouchPos touchRKey; ConfigTouchPos touchAnalogStick; + ConfigTouchPos touchRightAnalogStick; ConfigTouchPos touchCombo0; ConfigTouchPos touchCombo1; diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index a7036161785b..9a4fc1ceea97 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -461,6 +461,9 @@ void InitPadLayout(float xres, float yres, float globalScale) { float Action_button_spacing = g_Config.fActionButtonSpacing * baseActionButtonSpacing; int Action_button_center_X = xres - Action_button_spacing * 2; int Action_button_center_Y = yres - Action_button_spacing * 2; + if (g_Config.touchRightAnalogStick.show) { + Action_button_center_Y -= 150 * scale; + } initTouchPos(g_Config.touchActionButtonCenter, Action_button_center_X, Action_button_center_Y); //D-PAD (up down left right) (aka PSP cross)---------------------------- @@ -480,6 +483,12 @@ void InitPadLayout(float xres, float yres, float globalScale) { int analog_stick_Y = yres - 80 * scale; initTouchPos(g_Config.touchAnalogStick, analog_stick_X, analog_stick_Y); + //right analog stick------------------------------------------------- + //keep the right analog stick right below the face buttons + int right_analog_stick_X = Action_button_center_X; + int right_analog_stick_Y = yres - 80 * scale; + initTouchPos(g_Config.touchRightAnalogStick, right_analog_stick_X, right_analog_stick_Y); + //select, start, throttle-------------------------------------------- //space between the bottom keys (space between select, start and un-throttle) float bottom_key_spacing = 100; @@ -642,6 +651,9 @@ UI::ViewGroup *CreatePadLayout(float xres, float yres, bool *pause) { if (g_Config.touchAnalogStick.show) root->Add(new PSPStick(stickBg, stickImage, I_STICK, 0, g_Config.touchAnalogStick.scale, buttonLayoutParams(g_Config.touchAnalogStick))); + if (g_Config.touchRightAnalogStick.show) + root->Add(new PSPStick(stickBg, stickImage, I_STICK, 1, g_Config.touchRightAnalogStick.scale, buttonLayoutParams(g_Config.touchRightAnalogStick))); + addComboKey(g_Config.iCombokey0, roundImage, I_ROUND, comboKeyImages[0], g_Config.touchCombo0); addComboKey(g_Config.iCombokey1, roundImage, I_ROUND, comboKeyImages[1], g_Config.touchCombo1); addComboKey(g_Config.iCombokey2, roundImage, I_ROUND, comboKeyImages[2], g_Config.touchCombo2); diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index f75332be819a..24574ed951fd 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -421,6 +421,9 @@ void TouchControlLayoutScreen::CreateViews() { if (g_Config.touchAnalogStick.show) { controls_.push_back(new DragDropButton(g_Config.touchAnalogStick, stickBg, stickImage)); } + if (g_Config.touchRightAnalogStick.show) { + controls_.push_back(new DragDropButton(g_Config.touchRightAnalogStick, stickBg, stickImage)); + } if (g_Config.touchCombo0.show) { controls_.push_back(new DragDropButton(g_Config.touchCombo0, roundImage, comboKeyImages[0])); } diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp index 20c0407c8bfb..5dad49c7d9f3 100644 --- a/UI/TouchControlVisibilityScreen.cpp +++ b/UI/TouchControlVisibilityScreen.cpp @@ -80,6 +80,7 @@ void TouchControlVisibilityScreen::CreateViews() { toggles_.push_back({ "Select", &g_Config.touchSelectKey.show, I_SELECT }); toggles_.push_back({ "Dpad", &g_Config.touchDpad.show, -1 }); toggles_.push_back({ "Analog Stick", &g_Config.touchAnalogStick.show, -1 }); + toggles_.push_back({ "Right Analog Stick", &g_Config.touchRightAnalogStick.show, -1 }); toggles_.push_back({ "Unthrottle", &g_Config.touchUnthrottleKey.show, -1 }); toggles_.push_back({ "Combo0", &g_Config.touchCombo0.show, I_1 }); toggles_.push_back({ "Combo1", &g_Config.touchCombo1.show, I_2 }); From 8bb267727e727b9c79eaea6d3a695a2c52951c98 Mon Sep 17 00:00:00 2001 From: LunaMoo Date: Thu, 18 Jul 2019 05:57:28 +0200 Subject: [PATCH 2/2] Make things clear for people that never saw real PSP. --- UI/TouchControlVisibilityScreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp index 5dad49c7d9f3..1c7f23af4e08 100644 --- a/UI/TouchControlVisibilityScreen.cpp +++ b/UI/TouchControlVisibilityScreen.cpp @@ -80,7 +80,7 @@ void TouchControlVisibilityScreen::CreateViews() { toggles_.push_back({ "Select", &g_Config.touchSelectKey.show, I_SELECT }); toggles_.push_back({ "Dpad", &g_Config.touchDpad.show, -1 }); toggles_.push_back({ "Analog Stick", &g_Config.touchAnalogStick.show, -1 }); - toggles_.push_back({ "Right Analog Stick", &g_Config.touchRightAnalogStick.show, -1 }); + toggles_.push_back({ "Right Analog Stick\n(not used by most games)", &g_Config.touchRightAnalogStick.show, -1 }); toggles_.push_back({ "Unthrottle", &g_Config.touchUnthrottleKey.show, -1 }); toggles_.push_back({ "Combo0", &g_Config.touchCombo0.show, I_1 }); toggles_.push_back({ "Combo1", &g_Config.touchCombo1.show, I_2 });