From 22b07849cf85a1bdf0890a4cb22c8c6ad3240938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 13 Mar 2026 11:35:10 +0100 Subject: [PATCH 1/4] Add a missing lock --- Core/CwCheat.cpp | 2 ++ Core/HW/Display.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/Core/CwCheat.cpp b/Core/CwCheat.cpp index 6b04c46b82..81beacd036 100644 --- a/Core/CwCheat.cpp +++ b/Core/CwCheat.cpp @@ -1064,6 +1064,8 @@ void CWCheatEngine::ExecuteOp(const CheatOperation &op, const CheatCode &cheat, if ((line.part1 >> 28) == 0x3) { walkOffset = -walkOffset; } + // TODO: I've seen crashes here. Presumably an unaligned pointer just off the edge of memory. + // We should probably check pointer validity and invalidate the cheat if this happens. base = Memory::Read_U32(base + walkOffset); switch (line.part2 >> 28) { case 0x2: diff --git a/Core/HW/Display.cpp b/Core/HW/Display.cpp index 1a4911ec68..888f4a2df0 100644 --- a/Core/HW/Display.cpp +++ b/Core/HW/Display.cpp @@ -299,6 +299,7 @@ void __DisplayForgetFlip(FlipCallback callback, void *userdata) { // This is called when launching a new executable. We do clear vblankListeners here, they will get // set up again if needed. However we can't clear fliplisteners, that is used for RetroAchievements updates. void DisplayHWReset() { + std::lock_guard guard(listenersLock); vblankListeners.clear(); } From 5e44495b5f1fa218d652341711379b318177bdd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 13 Mar 2026 16:02:32 +0100 Subject: [PATCH 2/4] control map defaults: Don't map thumbstick click to pause. It's .. not good. --- Core/KeyMapDefaults.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Core/KeyMapDefaults.cpp b/Core/KeyMapDefaults.cpp index 52c6afaa01..288ec7c679 100644 --- a/Core/KeyMapDefaults.cpp +++ b/Core/KeyMapDefaults.cpp @@ -277,7 +277,6 @@ static const DefMappingStruct defaultPadMap[] = { {VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1}, {VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1}, {VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1}, - {VIRTKEY_PAUSE , NKCODE_BUTTON_THUMBL}, {VIRTKEY_PAUSE , NKCODE_BUTTON_SELECT }, {VIRTKEY_PAUSE , NKCODE_BUTTON_L2 }, {VIRTKEY_PAUSE , JOYSTICK_AXIS_LTRIGGER, +1}, From b8d793daf909cf1eda62fe33a33920ac4e9b4293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 13 Mar 2026 16:31:02 +0100 Subject: [PATCH 3/4] Repeat key handling: Clear held keys when turning off focus movement --- Common/UI/Root.cpp | 57 ++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/Common/UI/Root.cpp b/Common/UI/Root.cpp index e2d4e9016b..12c81db67c 100644 --- a/Common/UI/Root.cpp +++ b/Common/UI/Root.cpp @@ -19,6 +19,34 @@ bool focusForced; static std::function soundCallback; +// Repeat key handling below. +// TODO: Figure out where this should really live. +// Simple simulation of key repeat on platforms and for gamepads where we don't +// automatically get it. + +static int frameCount; + +// Ignore deviceId when checking for matches. Turns out that Ouya for example sends +// completely broken input where the original keypresses have deviceId = 10 and the repeats +// have deviceId = 0. +struct HeldKey { + InputKeyCode key; + InputDeviceID deviceId; + double triggerTime; + + // Ignores startTime + bool operator <(const HeldKey &other) const { + if (key < other.key) return true; + return false; + } + bool operator ==(const HeldKey &other) const { return key == other.key; } +}; + +static std::set heldKeys; + +const double repeatDelay = 15 * (1.0 / 60.0f); // 15 frames like before. +const double repeatInterval = 5 * (1.0 / 60.0f); // 5 frames like before. + struct DispatchQueueItem { Event *e; EventParams params; @@ -93,6 +121,8 @@ void EnableFocusMovement(bool enable) { if (focusedView) { focusedView->FocusChanged(FF_LOSTFOCUS); } + focusMoves.clear(); + heldKeys.clear(); focusedView = nullptr; } } @@ -145,33 +175,6 @@ void PlayUISound(UISound sound) { } } -// TODO: Figure out where this should really live. -// Simple simulation of key repeat on platforms and for gamepads where we don't -// automatically get it. - -static int frameCount; - -// Ignore deviceId when checking for matches. Turns out that Ouya for example sends -// completely broken input where the original keypresses have deviceId = 10 and the repeats -// have deviceId = 0. -struct HeldKey { - InputKeyCode key; - InputDeviceID deviceId; - double triggerTime; - - // Ignores startTime - bool operator <(const HeldKey &other) const { - if (key < other.key) return true; - return false; - } - bool operator ==(const HeldKey &other) const { return key == other.key; } -}; - -static std::set heldKeys; - -const double repeatDelay = 15 * (1.0 / 60.0f); // 15 frames like before. -const double repeatInterval = 5 * (1.0 / 60.0f); // 5 frames like before. - bool IsScrollKey(const KeyInput &input) { switch (input.keyCode) { case NKCODE_PAGE_UP: From fba616a2598e3ed2dc78ed4b1f73d3979b7e75b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 13 Mar 2026 16:39:40 +0100 Subject: [PATCH 4/4] Show setting hints as disabled if the setting is disabled See #21423 --- UI/GameSettingsScreen.cpp | 40 +++++++++++++++++++-------------------- UI/MiscViews.cpp | 7 ++++--- UI/MiscViews.h | 4 +++- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 737d324d89..e746cd132a 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -481,7 +481,7 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings) graphicsSettings->Add(new ItemHeader(gr->T("Speed Hacks", "Speed Hacks (can cause rendering errors!)"))); CheckBox *skipBufferEffects = graphicsSettings->Add(new CheckBox(&g_Config.bSkipBufferEffects, gr->T("Skip Buffer Effects"))); - graphicsSettings->Add(new SettingHint(gr->T("RenderingMode NonBuffered Tip", "Faster, but graphics may be missing in some games"))); + graphicsSettings->Add(new SettingHint(gr->T("RenderingMode NonBuffered Tip", "Faster, but graphics may be missing in some games"), skipBufferEffects)); skipBufferEffects->OnClick.Add([=](EventParams &e) { if (g_Config.bSkipBufferEffects) { g_Config.bAutoFrameSkip = false; @@ -511,32 +511,32 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings) CheckBox *texBackoff = graphicsSettings->Add(new CheckBox(&g_Config.bTextureBackoffCache, gr->T("Lazy texture caching", "Lazy texture caching (speedup)"))); texBackoff->SetDisabledPtr(&g_Config.bSoftwareRendering); - graphicsSettings->Add(new SettingHint(gr->T("Lazy texture caching Tip", "Faster, but can cause text problems in a few games"))); + graphicsSettings->Add(new SettingHint(gr->T("Lazy texture caching Tip", "Faster, but can cause text problems in a few games"), texBackoff)); static const char *quality[] = { "Low", "Medium", "High" }; PopupMultiChoice *bezierQuality = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iSplineBezierQuality, gr->T("LowCurves", "Spline/Bezier curves quality"), quality, 0, ARRAY_SIZE(quality), I18NCat::GRAPHICS, screenManager())); bezierQuality->SetDefault(2); - graphicsSettings->Add(new SettingHint(gr->T("LowCurves Tip", "Only used by some games, controls smoothness of curves"))); + graphicsSettings->Add(new SettingHint(gr->T("LowCurves Tip", "Only used by some games, controls smoothness of curves"), bezierQuality)); static const char *bloomHackOptions[] = {"Off", "Safe", "Balanced", "Aggressive"}; PopupMultiChoice *bloomHack = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iBloomHack, gr->T("Lower resolution for effects"), bloomHackOptions, 0, ARRAY_SIZE(bloomHackOptions), I18NCat::GRAPHICS, screenManager())); bloomHack->SetEnabledFunc([] { return !g_Config.bSoftwareRendering && g_Config.iInternalResolution != 1; }); - graphicsSettings->Add(new SettingHint(gr->T("Reduces artifacts"))); + graphicsSettings->Add(new SettingHint(gr->T("Reduces artifacts"), bloomHack)); graphicsSettings->Add(new ItemHeader(gr->T("Performance"))); CheckBox *frameDuplication = graphicsSettings->Add(new CheckBox(&g_Config.bRenderDuplicateFrames, gr->T("Render duplicate frames to 60hz"))); frameDuplication->SetEnabledFunc([] { return !g_Config.bSkipBufferEffects && g_Config.iFrameSkip == 0; }); - graphicsSettings->Add(new SettingHint(gr->T("RenderDuplicateFrames Tip", "Can make framerate smoother in games that run at lower framerates"))); + graphicsSettings->Add(new SettingHint(gr->T("RenderDuplicateFrames Tip", "Can make framerate smoother in games that run at lower framerates"), frameDuplication)); if (draw->GetDeviceCaps().setMaxFrameLatencySupported) { static const char *bufferOptions[] = { "No buffer", "Up to 1", "Up to 2" }; PopupMultiChoice *inflightChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iInflightFrames, gr->T("Buffer graphics commands"), bufferOptions, 1, ARRAY_SIZE(bufferOptions), I18NCat::GRAPHICS, screenManager())); inflightChoice->OnChoice.Handle(this, &GameSettingsScreen::OnInflightFramesChoice); - graphicsSettings->Add(new SettingHint(gr->T("Faster, input lag"))); // TODO: This hint could use improvement. + graphicsSettings->Add(new SettingHint(gr->T("Faster, input lag"), inflightChoice)); // TODO: This hint could use improvement. } if (GetGPUBackend() == GPUBackend::VULKAN) { @@ -555,14 +555,14 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings) CheckBox *swSkin = graphicsSettings->Add(new CheckBox(&g_Config.bSoftwareSkinning, gr->T("Software Skinning"))); swSkin->SetDisabledPtr(&g_Config.bSoftwareRendering); - graphicsSettings->Add(new SettingHint(gr->T("SoftwareSkinning Tip", "Combine skinned model draws on the CPU, faster in most games"))); + graphicsSettings->Add(new SettingHint(gr->T("SoftwareSkinning Tip", "Combine skinned model draws on the CPU, faster in most games"), swSkin)); if (DoesBackendSupportHWTess()) { CheckBox *tessellationHW = graphicsSettings->Add(new CheckBox(&g_Config.bHardwareTessellation, gr->T("Hardware Tessellation"))); tessellationHW->SetEnabledFunc([]() { return !g_Config.bSoftwareRendering && g_Config.bHardwareTransform; }); - graphicsSettings->Add(new SettingHint(gr->T("HardwareTessellation Tip", "Uses hardware to make curves"))); + graphicsSettings->Add(new SettingHint(gr->T("HardwareTessellation Tip", "Uses hardware to make curves"), tessellationHW)); } graphicsSettings->Add(new ItemHeader(gr->T("Texture upscaling"))); @@ -601,7 +601,7 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings) texScalingChoice->HideChoice(3); // 3x texScalingChoice->HideChoice(5); // 5x } - graphicsSettings->Add(new SettingHint(gr->T("UpscaleLevel Tip", "CPU heavy - some scaling may be delayed to avoid stutter"))); + graphicsSettings->Add(new SettingHint(gr->T("UpscaleLevel Tip", "CPU heavy - some scaling may be delayed to avoid stutter"), texScalingChoice)); texScalingChoice->SetEnabledFunc([]() { return !g_Config.bSoftwareRendering && !UsingHardwareTextureScaling(); @@ -611,7 +611,7 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings) deposterize->SetEnabledFunc([]() { return !g_Config.bSoftwareRendering && !UsingHardwareTextureScaling(); }); - graphicsSettings->Add(new SettingHint(gr->T("Deposterize Tip", "Fixes visual banding glitches in upscaled textures"))); + graphicsSettings->Add(new SettingHint(gr->T("Deposterize Tip", "Fixes visual banding glitches in upscaled textures"), deposterize)); graphicsSettings->Add(new ItemHeader(gr->T("Texture Filtering"))); static const char *anisoLevels[] = { "Off", "2x", "4x", "8x", "16x" }; @@ -747,7 +747,7 @@ void GameSettingsScreen::CreateAudioSettings(UI::ViewGroup *audioSettings) { static const int bufferSizes[] = {128, 256, 512, 1024, 2048}; PopupSliderChoice *bufferSize = audioSettings->Add(new PopupSliderChoice(&g_Config.iSDLAudioBufferSize, 0, 2048, 256, a->T("Buffer size"), screenManager())); bufferSize->RestrictChoices(bufferSizes, ARRAY_SIZE(bufferSizes)); - audioSettings->Add(new SettingHint(di->T("This change will not take effect until PPSSPP is restarted."))); + audioSettings->Add(new SettingHint(di->T("This change will not take effect until PPSSPP is restarted."), bufferSize)); #endif #if PPSSPP_PLATFORM(WINDOWS) @@ -901,7 +901,7 @@ void GameSettingsScreen::CreateControlsSettings(UI::ViewGroup *controlsSettings) // Sticky D-pad. CheckBox *stickyDpad = controlsSettings->Add(new CheckBox(&g_Config.bStickyTouchDPad, co->T("Sticky D-Pad"))); stickyDpad->SetEnabledPtr(&g_Config.bShowTouchControls); - controlsSettings->Add(new SettingHint(co->T("Easier sweeping movements"))); + controlsSettings->Add(new SettingHint(co->T("Easier sweeping movements"), stickyDpad)); // Re-centers itself to the touch location on touch-down. CheckBox *floatingAnalog = controlsSettings->Add(new CheckBox(&g_Config.bAutoCenterTouchAnalog, co->T("Auto-centering analog stick"))); @@ -922,9 +922,9 @@ void GameSettingsScreen::CreateControlsSettings(UI::ViewGroup *controlsSettings) #if defined(USING_WIN_UI) controlsSettings->Add(new CheckBox(&g_Config.bIgnoreWindowsKey, co->T("Ignore Windows Key"))); #endif // #if defined(USING_WIN_UI) - auto analogLimiter = new PopupSliderChoiceFloat(&g_Config.fAnalogLimiterDeadzone, 0.0f, 1.0f, 0.6f, co->T("Analog Limiter"), 0.10f, screenManager(), "/ 1.0"); + PopupSliderChoiceFloat *analogLimiter = new PopupSliderChoiceFloat(&g_Config.fAnalogLimiterDeadzone, 0.0f, 1.0f, 0.6f, co->T("Analog Limiter"), 0.10f, screenManager(), "/ 1.0"); controlsSettings->Add(analogLimiter); - controlsSettings->Add(new SettingHint(co->T("AnalogLimiter Tip", "When the analog limiter button is pressed"))); + controlsSettings->Add(new SettingHint(co->T("AnalogLimiter Tip", "When the analog limiter button is pressed"), analogLimiter)); controlsSettings->Add(new PopupSliderChoice(&g_Config.iRapidFireInterval, 1, 10, 5, co->T("Rapid fire interval"), screenManager(), "frames")); #if defined(USING_WIN_UI) || defined(SDL) || PPSSPP_PLATFORM(ANDROID) bool enableMouseSettings = true; @@ -943,7 +943,7 @@ void GameSettingsScreen::CreateControlsSettings(UI::ViewGroup *controlsSettings) wheelUpDelaySlider->SetFormat(di->T("%d ms")); CheckBox *mouseControl = controlsSettings->Add(new CheckBox(&g_Config.bMouseControl, co->T("Use Mouse Control"))); - controlsSettings->Add(new SettingHint(co->T("MouseControl Tip", "You can now map mouse in control mapping screen by pressing the 'M' icon."))); + controlsSettings->Add(new SettingHint(co->T("MouseControl Tip", "You can now map mouse in control mapping screen by pressing the 'M' icon."), mouseControl)); #if !PPSSPP_PLATFORM(ANDROID) controlsSettings->Add(new CheckBox(&g_Config.bMouseConfine, co->T("Confine Mouse", "Trap mouse within window/display area")))->SetEnabledPtr(&g_Config.bMouseControl); @@ -1030,7 +1030,7 @@ void GameSettingsScreen::CreateNetworkingSettings(UI::ViewGroup *networkingSetti static const char *relayModes[] = {"Auto", "Yes", "No"}; PopupMultiChoice *relayModePopup = networkingSettings->Add(new PopupMultiChoice(&g_Config.iAdhocServerRelayMode, n->T("Try to use server-provided packet relay"), relayModes, 0, ARRAY_SIZE(relayModes), I18NCat::DIALOG, screenManager())); relayModePopup->SetEnabled(!PSP_IsInited()); - networkingSettings->Add(new SettingHint(n->T("PacketRelayHint", "Available on servers that provide 'aemu_postoffice' packet relay, like socom.cc. Disable this for LAN or VPN play. Can be more reliable, but sometimes slower."))); + networkingSettings->Add(new SettingHint(n->T("PacketRelayHint", "Available on servers that provide 'aemu_postoffice' packet relay, like socom.cc. Disable this for LAN or VPN play. Can be more reliable, but sometimes slower."), relayModePopup)); networkingSettings->Add(new PopupTextInputChoice(GetRequesterToken(), &g_Config.sNickName, sy->T("Change Nickname"), "", 32, screenManager())); @@ -1052,8 +1052,8 @@ void GameSettingsScreen::CreateNetworkingSettings(UI::ViewGroup *networkingSetti networkingSettings->Add(new ItemHeader(n->T("UPnP (port-forwarding)"))); networkingSettings->Add(new CheckBox(&g_Config.bEnableUPnP, n->T("Enable UPnP", "Enable UPnP (need a few seconds to detect)"))); - auto useOriPort = networkingSettings->Add(new CheckBox(&g_Config.bUPnPUseOriginalPort, n->T("UPnP use original port", "UPnP use original port (Enabled = PSP compatibility)"))); - networkingSettings->Add(new SettingHint(n->T("UseOriginalPort Tip", "May not work for all devices or games, see wiki."))); + auto *useOriPort = networkingSettings->Add(new CheckBox(&g_Config.bUPnPUseOriginalPort, n->T("UPnP use original port", "UPnP use original port (Enabled = PSP compatibility)"))); + networkingSettings->Add(new SettingHint(n->T("UseOriginalPort Tip", "May not work for all devices or games, see wiki."), useOriPort)); useOriPort->SetEnabledPtr(&g_Config.bEnableUPnP); @@ -1121,8 +1121,8 @@ void GameSettingsScreen::CreateNetworkingSettings(UI::ViewGroup *networkingSetti wlanChannelChoice->HideChoice(i + 2); wlanChannelChoice->HideChoice(i + 7); } - networkingSettings->Add(new PopupSliderChoice(&g_Config.iPortOffset, 0, 60000, 10000, n->T("Port offset"), 100, screenManager())); - networkingSettings->Add(new SettingHint(n->T("PortOffsetHint"))); + PopupSliderChoice *portOffset = networkingSettings->Add(new PopupSliderChoice(&g_Config.iPortOffset, 0, 60000, 10000, n->T("Port offset"), 100, screenManager())); + networkingSettings->Add(new SettingHint(n->T("PortOffsetHint"), portOffset)); networkingSettings->Add(new PopupSliderChoice(&g_Config.iMinTimeout, 0, 15000, 0, n->T("Minimum Timeout", "Minimum Timeout (override in ms, 0 = default)"), 50, screenManager()))->SetFormat(di->T("%d ms")); networkingSettings->Add(new CheckBox(&g_Config.bForcedFirstConnect, n->T("Forced First Connect", "Forced First Connect (faster Connect)"))); networkingSettings->Add(new CheckBox(&g_Config.bAllowSpeedControlWhileConnected, n->T("Allow speed control while connected (not recommended)"))); diff --git a/UI/MiscViews.cpp b/UI/MiscViews.cpp index c5b8d3e6c4..34e2b17051 100644 --- a/UI/MiscViews.cpp +++ b/UI/MiscViews.cpp @@ -292,15 +292,16 @@ void GameInfoBGView::Draw(UIContext &dc) { } } -SettingHint::SettingHint(std::string_view text) - : UI::TextView(text, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::WRAP_CONTENT)) { +SettingHint::SettingHint(std::string_view text, UI::View *setting) + : UI::TextView(text, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::WRAP_CONTENT)), setting_(setting) { SetTextSize(UI::TextSize::Tiny); SetPadding(UI::Margins(14, 0, 12, 8)); SetAlign(FLAG_WRAP_TEXT); } void SettingHint::Draw(UIContext &dc) { - UI::Style style = dc.GetTheme().itemStyle; + const bool enabled = setting_ ? setting_->IsEnabled() : true; + const UI::Style &style = enabled ? dc.GetTheme().itemStyle : dc.GetTheme().itemDisabledStyle; SetTextColor(style.fgColor); // bit hacky but works dc.FillRect(style.background, bounds_); UI::TextView::Draw(dc); diff --git a/UI/MiscViews.h b/UI/MiscViews.h index 7730a5786b..f0b813f69e 100644 --- a/UI/MiscViews.h +++ b/UI/MiscViews.h @@ -92,8 +92,10 @@ protected: class SettingHint : public UI::TextView { public: - SettingHint(std::string_view text); + SettingHint(std::string_view text, UI::View *setting); void Draw(UIContext &dc) override; +private: + UI::View *setting_; }; void AddRotationPicker(ScreenManager *screenManager, UI::ViewGroup *parent, bool text);