diff --git a/Core/Config.cpp b/Core/Config.cpp index 4458042234..4b914e608c 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -881,6 +881,7 @@ static ConfigSetting controlSettings[] = { ConfigSetting("fcombo4X", "fcombo4Y", "comboKeyScale4", "ShowComboKey4", &g_Config.touchCombo4, defaultTouchPosHide, true, true), ConfigSetting("Speed1KeyX", "Speed1KeyY", "Speed1KeyScale", "ShowSpeed1Key", &g_Config.touchSpeed1Key, defaultTouchPosHide, true, true), ConfigSetting("Speed2KeyX", "Speed2KeyY", "Speed2KeyScale", "ShowSpeed2Key", &g_Config.touchSpeed2Key, defaultTouchPosHide, true, true), + ConfigSetting("RapidFireKeyX", "RapidFireKeyY", "RapidFireKeyScale", "ShowRapidFireKey", &g_Config.touchRapidFireKey, defaultTouchPosHide, true, true), #ifdef _WIN32 ConfigSetting("DInputAnalogDeadzone", &g_Config.fDInputAnalogDeadzone, 0.1f, true, true), @@ -1599,6 +1600,7 @@ void Config::ResetControlLayout() { reset(g_Config.touchCombo4); reset(g_Config.touchSpeed1Key); reset(g_Config.touchSpeed2Key); + reset(g_Config.touchRapidFireKey); } void Config::GetReportingInfo(UrlEncoder &data) { diff --git a/Core/Config.h b/Core/Config.h index 88be654ea3..e60e0224ef 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -308,6 +308,7 @@ public: ConfigTouchPos touchCombo4; ConfigTouchPos touchSpeed1Key; ConfigTouchPos touchSpeed2Key; + ConfigTouchPos touchRapidFireKey; // Controls Visibility bool bShowTouchControls; diff --git a/Core/HLE/sceCtrl.cpp b/Core/HLE/sceCtrl.cpp index 6074b1601f..79888ebea5 100644 --- a/Core/HLE/sceCtrl.cpp +++ b/Core/HLE/sceCtrl.cpp @@ -200,6 +200,11 @@ void __CtrlSetRapidFire(bool state) emuRapidFire = state; } +bool __CtrlGetRapidFire() +{ + return emuRapidFire; +} + static int __CtrlReadSingleBuffer(PSPPointer data, bool negative) { if (data.IsValid()) diff --git a/Core/HLE/sceCtrl.h b/Core/HLE/sceCtrl.h index db7c09b582..0c2d757dde 100644 --- a/Core/HLE/sceCtrl.h +++ b/Core/HLE/sceCtrl.h @@ -79,6 +79,7 @@ void __CtrlSetAnalogY(float value, int stick = CTRL_STICK_LEFT); // Call this to enable rapid-fire. This will cause buttons other than arrows to alternate. void __CtrlSetRapidFire(bool state); +bool __CtrlGetRapidFire(); // For use by internal UI like MsgDialog u32 __CtrlPeekButtons(); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 6c062d6a52..d72ca4ee7f 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -628,6 +628,9 @@ void EmuScreen::onVKeyDown(int virtualKeyCode) { osm.Show(sc->T("replaceTextures_false", "Textures no longer are being replaced"), 2.0); NativeMessageReceived("gpu_clearCache", ""); break; + case VIRTKEY_RAPID_FIRE: + __CtrlSetRapidFire(true); + break; } } @@ -677,6 +680,10 @@ void EmuScreen::onVKeyUp(int virtualKeyCode) { setVKeyAnalogY(CTRL_STICK_RIGHT, VIRTKEY_AXIS_RIGHT_Y_MIN, VIRTKEY_AXIS_RIGHT_Y_MAX); break; + case VIRTKEY_RAPID_FIRE: + __CtrlSetRapidFire(false); + break; + default: break; } @@ -1080,9 +1087,6 @@ void EmuScreen::update() { if (invalid_) return; - // Virtual keys. - __CtrlSetRapidFire(virtKeys[VIRTKEY_RAPID_FIRE - VIRTKEY_FIRST]); - // This is here to support the iOS on screen back button. if (pauseTrigger_) { pauseTrigger_ = false; diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index 9a4fc1ceea..126cfa28c6 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -157,6 +157,19 @@ void FPSLimitButton::Touch(const TouchInput &input) { } } +void RapidFireButton::Touch(const TouchInput &input) { + bool lastDown = pointerDownMask_ != 0; + MultiTouchButton::Touch(input); + bool down = pointerDownMask_ != 0; + if (down && !lastDown) { + __CtrlSetRapidFire(!__CtrlGetRapidFire()); + } +} + +bool RapidFireButton::IsDown() { + return __CtrlGetRapidFire(); +} + bool FPSLimitButton::IsDown() { return PSP_CoreParameter().fpsLimit == limit_; } @@ -510,6 +523,7 @@ void InitPadLayout(float xres, float yres, float globalScale) { initTouchPos(g_Config.touchSpeed1Key, unthrottle_key_X, unthrottle_key_Y - 60 * scale); initTouchPos(g_Config.touchSpeed2Key, unthrottle_key_X + bottom_key_spacing * scale, unthrottle_key_Y - 60 * scale); + initTouchPos(g_Config.touchRapidFireKey, unthrottle_key_X + 2*bottom_key_spacing * scale, unthrottle_key_Y - 60 * scale); // L and R------------------------------------------------------------ // Put them above the analog stick / above the buttons to the right. @@ -633,6 +647,11 @@ UI::ViewGroup *CreatePadLayout(float xres, float yres, bool *pause) { }); } + if (g_Config.touchRapidFireKey.show) { + auto rapidFire = root->Add(new RapidFireButton(rectImage, I_RECT, I_ARROW, g_Config.touchRapidFireKey.scale, buttonLayoutParams(g_Config.touchRapidFireKey))); + rapidFire->SetAngle(90.0f, 180.0f); + } + FPSLimitButton *speed1 = addFPSLimitButton(FPSLimit::CUSTOM1, rectImage, I_RECT, I_ARROW, g_Config.touchSpeed1Key); if (speed1) speed1->SetAngle(170.0f, 180.0f); diff --git a/UI/GamepadEmu.h b/UI/GamepadEmu.h index ec52ac575b..70ad2fd56b 100644 --- a/UI/GamepadEmu.h +++ b/UI/GamepadEmu.h @@ -97,6 +97,15 @@ private: FPSLimit limit_; }; +class RapidFireButton : public MultiTouchButton { +public: + RapidFireButton(int bgImg, int bgDownImg, int img, float scale, UI::LayoutParams *layoutParams) + : MultiTouchButton(bgImg, bgDownImg, img, scale, layoutParams) { + } + void Touch(const TouchInput &input) override; + bool IsDown() override; +}; + class PSPButton : public MultiTouchButton { public: PSPButton(int pspButtonBit, int bgImg, int bgDownImg, int img, float scale, UI::LayoutParams *layoutParams) diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 6c7917f79a..1e54323dcf 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -453,6 +453,12 @@ void TouchControlLayoutScreen::CreateViews() { controls_.push_back(speed2); } + if (g_Config.touchRapidFireKey.show) { + DragDropButton *rapidFire = new DragDropButton(g_Config.touchRapidFireKey, rectImage, I_ARROW); + rapidFire->SetAngle(90.0f, 180.0f); + controls_.push_back(rapidFire); + } + if (g_Config.touchLKey.show) { controls_.push_back(new DragDropButton(g_Config.touchLKey, shoulderImage, I_L)); } diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp index 1c7f23af4e..b7320816c9 100644 --- a/UI/TouchControlVisibilityScreen.cpp +++ b/UI/TouchControlVisibilityScreen.cpp @@ -89,6 +89,7 @@ void TouchControlVisibilityScreen::CreateViews() { toggles_.push_back({ "Combo4", &g_Config.touchCombo4.show, I_5 }); toggles_.push_back({ "Alt speed 1", &g_Config.touchSpeed1Key.show, -1 }); toggles_.push_back({ "Alt speed 2", &g_Config.touchSpeed2Key.show, -1 }); + toggles_.push_back({ "Rapid Fire", &g_Config.touchRapidFireKey.show, -1 }); I18NCategory *mc = GetI18NCategory("MappableControls");