mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-10 20:05:47 -04:00
Frontend: Add controller settings
This commit is contained in:
@ -33,11 +33,11 @@ void Settings::SetDefaults()
|
||||
bios_patch_tty_enable = false;
|
||||
bios_patch_fast_boot = false;
|
||||
|
||||
controller_a_type = ControllerType::DigitalController;
|
||||
controller_b_type = ControllerType::None;
|
||||
controller_1_type = ControllerType::DigitalController;
|
||||
controller_2_type = ControllerType::None;
|
||||
|
||||
memory_card_a_path = "memory_card_a.mcd";
|
||||
memory_card_b_path.clear();
|
||||
memory_card_1_path = "memory_card_1.mcd";
|
||||
memory_card_2_path.clear();
|
||||
}
|
||||
|
||||
void Settings::Load(const char* filename)
|
||||
@ -72,13 +72,13 @@ void Settings::Load(const char* filename)
|
||||
bios_patch_tty_enable = ini.GetBoolValue("BIOS", "PatchTTYEnable", true);
|
||||
bios_patch_fast_boot = ini.GetBoolValue("BIOS", "PatchFastBoot", false);
|
||||
|
||||
controller_a_type = ParseControllerTypeName(ini.GetValue("Controller", "PortAType", "DigitalController"))
|
||||
controller_1_type = ParseControllerTypeName(ini.GetValue("Ports", "Controller1Type", "DigitalController"))
|
||||
.value_or(ControllerType::DigitalController);
|
||||
controller_b_type =
|
||||
ParseControllerTypeName(ini.GetValue("Controller", "PortBType", "None")).value_or(ControllerType::None);
|
||||
controller_2_type =
|
||||
ParseControllerTypeName(ini.GetValue("Ports", "Controller2Type", "None")).value_or(ControllerType::None);
|
||||
|
||||
memory_card_a_path = ini.GetValue("MemoryCard", "CardAPath", "memory_card_a.mcd");
|
||||
memory_card_b_path = ini.GetValue("MemoryCard", "CardBPath", "");
|
||||
memory_card_1_path = ini.GetValue("Ports", "MemoryCard1Path", "memory_card_1.mcd");
|
||||
memory_card_2_path = ini.GetValue("Ports", "MemoryCard2Path", "");
|
||||
}
|
||||
|
||||
bool Settings::Save(const char* filename) const
|
||||
@ -110,18 +110,25 @@ bool Settings::Save(const char* filename) const
|
||||
ini.SetBoolValue("BIOS", "PatchTTYEnable", bios_patch_tty_enable);
|
||||
ini.SetBoolValue("BIOS", "PatchFastBoot", bios_patch_fast_boot);
|
||||
|
||||
ini.SetValue("Controller", "PortAType", GetControllerTypeName(controller_a_type));
|
||||
ini.SetValue("Controller", "PortBType", GetControllerTypeName(controller_b_type));
|
||||
|
||||
if (!memory_card_a_path.empty())
|
||||
ini.SetValue("MemoryCard", "CardAPath", memory_card_a_path.c_str());
|
||||
if (controller_1_type != ControllerType::None)
|
||||
ini.SetValue("Ports", "Controller1Type", GetControllerTypeName(controller_1_type));
|
||||
else
|
||||
ini.DeleteValue("MemoryCard", "CardAPath", nullptr);
|
||||
ini.DeleteValue("Ports", "Controller1Type", nullptr);
|
||||
|
||||
if (!memory_card_b_path.empty())
|
||||
ini.SetValue("MemoryCard", "CardBPath", memory_card_b_path.c_str());
|
||||
if (controller_2_type != ControllerType::None)
|
||||
ini.SetValue("Ports", "Controller2Type", GetControllerTypeName(controller_2_type));
|
||||
else
|
||||
ini.DeleteValue("MemoryCard", "CardBPath", nullptr);
|
||||
ini.DeleteValue("Ports", "Controller2Type", nullptr);
|
||||
|
||||
if (!memory_card_1_path.empty())
|
||||
ini.SetValue("Ports", "MemoryCard1Path", memory_card_1_path.c_str());
|
||||
else
|
||||
ini.DeleteValue("Ports", "MemoryCard1Path", nullptr);
|
||||
|
||||
if (!memory_card_2_path.empty())
|
||||
ini.SetValue("Ports", "MemoryCard2Path", memory_card_2_path.c_str());
|
||||
else
|
||||
ini.DeleteValue("Ports", "MemoryCard2Path", nullptr);
|
||||
|
||||
err = ini.SaveFile(filename, false);
|
||||
if (err != SI_OK)
|
||||
|
@ -45,11 +45,11 @@ struct Settings
|
||||
bool bios_patch_tty_enable = false;
|
||||
bool bios_patch_fast_boot = false;
|
||||
|
||||
ControllerType controller_a_type = ControllerType::None;
|
||||
ControllerType controller_b_type = ControllerType::None;
|
||||
ControllerType controller_1_type = ControllerType::None;
|
||||
ControllerType controller_2_type = ControllerType::None;
|
||||
|
||||
std::string memory_card_a_path;
|
||||
std::string memory_card_b_path;
|
||||
std::string memory_card_1_path;
|
||||
std::string memory_card_2_path;
|
||||
|
||||
void SetDefaults();
|
||||
void Load(const char* filename);
|
||||
|
@ -463,16 +463,16 @@ void System::UpdateControllers()
|
||||
m_pad->SetController(1, nullptr);
|
||||
|
||||
const Settings& settings = m_host_interface->GetSettings();
|
||||
if (settings.controller_a_type != ControllerType::None)
|
||||
if (settings.controller_1_type != ControllerType::None)
|
||||
{
|
||||
std::unique_ptr<Controller> controller = Controller::Create(settings.controller_a_type);
|
||||
std::unique_ptr<Controller> controller = Controller::Create(settings.controller_1_type);
|
||||
if (controller)
|
||||
m_pad->SetController(0, std::move(controller));
|
||||
}
|
||||
|
||||
if (settings.controller_b_type != ControllerType::None)
|
||||
if (settings.controller_2_type != ControllerType::None)
|
||||
{
|
||||
std::unique_ptr<Controller> controller = Controller::Create(settings.controller_b_type);
|
||||
std::unique_ptr<Controller> controller = Controller::Create(settings.controller_2_type);
|
||||
if (controller)
|
||||
m_pad->SetController(1, std::move(controller));
|
||||
}
|
||||
@ -484,16 +484,16 @@ void System::UpdateMemoryCards()
|
||||
m_pad->SetMemoryCard(1, nullptr);
|
||||
|
||||
const Settings& settings = m_host_interface->GetSettings();
|
||||
if (!settings.memory_card_a_path.empty())
|
||||
if (!settings.memory_card_1_path.empty())
|
||||
{
|
||||
std::unique_ptr<MemoryCard> card = MemoryCard::Open(this, settings.memory_card_a_path);
|
||||
std::unique_ptr<MemoryCard> card = MemoryCard::Open(this, settings.memory_card_1_path);
|
||||
if (card)
|
||||
m_pad->SetMemoryCard(0, std::move(card));
|
||||
}
|
||||
|
||||
if (!settings.memory_card_b_path.empty())
|
||||
if (!settings.memory_card_2_path.empty())
|
||||
{
|
||||
std::unique_ptr<MemoryCard> card = MemoryCard::Open(this, settings.memory_card_b_path);
|
||||
std::unique_ptr<MemoryCard> card = MemoryCard::Open(this, settings.memory_card_2_path);
|
||||
if (card)
|
||||
m_pad->SetMemoryCard(1, std::move(card));
|
||||
}
|
||||
|
@ -51,7 +51,8 @@ enum class ControllerType
|
||||
{
|
||||
None,
|
||||
DigitalController,
|
||||
AnalogController
|
||||
AnalogController,
|
||||
Count
|
||||
};
|
||||
|
||||
enum : u32
|
||||
|
Reference in New Issue
Block a user