Skip to content

Commit d9e0cd5

Browse files
chaoticgdF0bes
authored andcommitted
Hotkeys: Check if the memory card is busy before resetting
1 parent 9c64627 commit d9e0cd5

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

pcsx2/Hotkeys.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ DEFINE_HOTKEY("ShutdownVM", TRANSLATE_NOOP("Hotkeys", "System"), TRANSLATE_NOOP(
238238
DEFINE_HOTKEY("ResetVM", TRANSLATE_NOOP("Hotkeys", "System"), TRANSLATE_NOOP("Hotkeys", "Reset Virtual Machine"),
239239
[](s32 pressed) {
240240
if (!pressed && VMManager::HasValidVM())
241-
VMManager::Reset();
241+
VMManager::RequestReset();
242242
})
243243
DEFINE_HOTKEY("ReloadPatches", TRANSLATE_NOOP("Hotkeys", "System"), TRANSLATE_NOOP("Hotkeys", "Reload Patches"),
244244
[](s32 pressed) {

pcsx2/VMManager.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,6 +1743,22 @@ void VMManager::Shutdown(bool save_resume_state)
17431743
LoadSettings();
17441744
}
17451745

1746+
bool VMManager::RequestReset()
1747+
{
1748+
if (MemcardBusy::IsBusy())
1749+
{
1750+
Host::AddIconOSDMessage("RequestReset", ICON_FA_TRIANGLE_EXCLAMATION,
1751+
TRANSLATE_STR("VMManager",
1752+
"The memory card is busy, so the reset operation has been cancelled to prevent data loss."),
1753+
Host::OSD_WARNING_DURATION);
1754+
return false;
1755+
}
1756+
1757+
VMManager::Reset();
1758+
1759+
return true;
1760+
}
1761+
17461762
void VMManager::Reset()
17471763
{
17481764
pxAssert(HasValidVM());

pcsx2/VMManager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ namespace VMManager
124124
/// Destroys all system components.
125125
void Shutdown(bool save_resume_state);
126126

127+
/// Resets all subsystems to a cold boot if it's safe to do so.
128+
bool RequestReset();
129+
127130
/// Resets all subsystems to a cold boot.
128131
void Reset();
129132

0 commit comments

Comments
 (0)