mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-04-27 10:45:42 -04:00
CommonHostInterface: Add swap memory cards hotkey
This commit is contained in:
parent
2f8150f357
commit
67f352339c
@ -293,6 +293,14 @@ void Pad::SetMemoryCard(u32 slot, std::unique_ptr<MemoryCard> dev)
|
|||||||
m_memory_cards[slot] = std::move(dev);
|
m_memory_cards[slot] = std::move(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<MemoryCard> Pad::RemoveMemoryCard(u32 slot)
|
||||||
|
{
|
||||||
|
std::unique_ptr<MemoryCard> ret = std::move(m_memory_cards[slot]);
|
||||||
|
if (ret)
|
||||||
|
ret->Reset();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
u32 Pad::ReadRegister(u32 offset)
|
u32 Pad::ReadRegister(u32 offset)
|
||||||
{
|
{
|
||||||
switch (offset)
|
switch (offset)
|
||||||
|
@ -28,6 +28,7 @@ public:
|
|||||||
|
|
||||||
MemoryCard* GetMemoryCard(u32 slot) { return m_memory_cards[slot].get(); }
|
MemoryCard* GetMemoryCard(u32 slot) { return m_memory_cards[slot].get(); }
|
||||||
void SetMemoryCard(u32 slot, std::unique_ptr<MemoryCard> dev);
|
void SetMemoryCard(u32 slot, std::unique_ptr<MemoryCard> dev);
|
||||||
|
std::unique_ptr<MemoryCard> RemoveMemoryCard(u32 slot);
|
||||||
|
|
||||||
Multitap* GetMultitap(u32 slot) { return &m_multitaps[slot]; };
|
Multitap* GetMultitap(u32 slot) { return &m_multitaps[slot]; };
|
||||||
|
|
||||||
|
@ -1836,6 +1836,19 @@ void UpdateMemoryCards()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HasMemoryCard(u32 slot)
|
||||||
|
{
|
||||||
|
return (g_pad.GetMemoryCard(slot) != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwapMemoryCards()
|
||||||
|
{
|
||||||
|
std::unique_ptr<MemoryCard> first = g_pad.RemoveMemoryCard(0);
|
||||||
|
std::unique_ptr<MemoryCard> second = g_pad.RemoveMemoryCard(1);
|
||||||
|
g_pad.SetMemoryCard(0, std::move(second));
|
||||||
|
g_pad.SetMemoryCard(1, std::move(first));
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateMultitaps()
|
void UpdateMultitaps()
|
||||||
{
|
{
|
||||||
switch (g_settings.multitap_mode)
|
switch (g_settings.multitap_mode)
|
||||||
|
@ -181,6 +181,8 @@ void UpdateControllers();
|
|||||||
void UpdateControllerSettings();
|
void UpdateControllerSettings();
|
||||||
void ResetControllers();
|
void ResetControllers();
|
||||||
void UpdateMemoryCards();
|
void UpdateMemoryCards();
|
||||||
|
bool HasMemoryCard(u32 slot);
|
||||||
|
void SwapMemoryCards();
|
||||||
void UpdateMultitaps();
|
void UpdateMultitaps();
|
||||||
|
|
||||||
/// Dumps RAM to a file.
|
/// Dumps RAM to a file.
|
||||||
|
@ -1999,6 +1999,12 @@ void CommonHostInterface::RegisterGeneralHotkeys()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("SwapMemoryCards"),
|
||||||
|
StaticString(TRANSLATABLE("Hotkeys", "Swap Memory Card Slots")), [this](bool pressed) {
|
||||||
|
if (pressed && System::IsValid())
|
||||||
|
SwapMemoryCards();
|
||||||
|
});
|
||||||
|
|
||||||
#ifndef __ANDROID__
|
#ifndef __ANDROID__
|
||||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("FrameStep"),
|
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("FrameStep"),
|
||||||
StaticString(TRANSLATABLE("Hotkeys", "Frame Step")), [this](bool pressed) {
|
StaticString(TRANSLATABLE("Hotkeys", "Frame Step")), [this](bool pressed) {
|
||||||
@ -3564,6 +3570,38 @@ void CommonHostInterface::ToggleWidescreen()
|
|||||||
GTE::UpdateAspectRatio();
|
GTE::UpdateAspectRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CommonHostInterface::SwapMemoryCards()
|
||||||
|
{
|
||||||
|
System::SwapMemoryCards();
|
||||||
|
|
||||||
|
if (System::HasMemoryCard(0) && System::HasMemoryCard(1))
|
||||||
|
{
|
||||||
|
g_host_interface->AddOSDMessage(
|
||||||
|
g_host_interface->TranslateStdString("OSDMessage", "Swapped memory card ports. Both ports have a memory card."),
|
||||||
|
10.0f);
|
||||||
|
}
|
||||||
|
else if (System::HasMemoryCard(1))
|
||||||
|
{
|
||||||
|
g_host_interface->AddOSDMessage(
|
||||||
|
g_host_interface->TranslateStdString("OSDMessage",
|
||||||
|
"Swapped memory card ports. Port 2 has a memory card, Port 1 is empty."),
|
||||||
|
10.0f);
|
||||||
|
}
|
||||||
|
else if (System::HasMemoryCard(0))
|
||||||
|
{
|
||||||
|
g_host_interface->AddOSDMessage(
|
||||||
|
g_host_interface->TranslateStdString("OSDMessage",
|
||||||
|
"Swapped memory card ports. Port 1 has a memory card, Port 2 is empty."),
|
||||||
|
10.0f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_host_interface->AddOSDMessage(
|
||||||
|
g_host_interface->TranslateStdString("OSDMessage", "Swapped memory card ports. Neither port has a memory card."),
|
||||||
|
10.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CommonHostInterface::ParseFullscreenMode(const std::string_view& mode, u32* width, u32* height,
|
bool CommonHostInterface::ParseFullscreenMode(const std::string_view& mode, u32* width, u32* height,
|
||||||
float* refresh_rate)
|
float* refresh_rate)
|
||||||
{
|
{
|
||||||
|
@ -274,6 +274,9 @@ public:
|
|||||||
/// Toggle Widescreen Hack and Aspect Ratio
|
/// Toggle Widescreen Hack and Aspect Ratio
|
||||||
void ToggleWidescreen();
|
void ToggleWidescreen();
|
||||||
|
|
||||||
|
/// Swaps memory cards in slot 1/2.
|
||||||
|
void SwapMemoryCards();
|
||||||
|
|
||||||
/// Parses a fullscreen mode into its components (width * height @ refresh hz)
|
/// Parses a fullscreen mode into its components (width * height @ refresh hz)
|
||||||
static bool ParseFullscreenMode(const std::string_view& mode, u32* width, u32* height, float* refresh_rate);
|
static bool ParseFullscreenMode(const std::string_view& mode, u32* width, u32* height, float* refresh_rate);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user