Fixed PrimeHack toggle being reset

This commit is contained in:
sirmangler 2022-09-26 15:42:52 +01:00
parent aaa54ae2a7
commit 9190dcecf7
6 changed files with 15 additions and 12 deletions

View File

@ -137,8 +137,8 @@ bool IsSettingSaveable(const Config::Location& config_location)
// PrimeHack
&Config::PRIMEHACK_ENABLE.GetLocation(),
&Config::PRIMEHACK_INITIAL_RUN.GetLocation(),
&Config::PRIMEHACK_ENABLE.GetLocation(),
&Config::PRIMEHACK_PROMPT_TAB.GetLocation(),
&Config::PRIMEHACK_NOCLIP.GetLocation(),
&Config::PRIMEHACK_INVULNERABILITY.GetLocation(),

View File

@ -37,11 +37,6 @@ namespace
static std::array<std::atomic<WiimoteSource>, MAX_BBMOTES> s_wiimote_sources;
static std::optional<size_t> s_config_callback_id = std::nullopt;
WiimoteSource GetSource(unsigned int index)
{
return s_wiimote_sources[index];
}
void OnSourceChanged(unsigned int index, WiimoteSource source)
{
const WiimoteSource previous_source = s_wiimote_sources[index].exchange(source);
@ -52,10 +47,6 @@ void OnSourceChanged(unsigned int index, WiimoteSource source)
return;
}
if (index == 0) {
Config::SetBaseOrCurrent(Config::PRIMEHACK_ENABLE, source == WiimoteSource::Real ? false : true);
}
WiimoteReal::HandleWiimoteSourceChange(index);
Core::RunAsCPUThread([index] { WiimoteCommon::UpdateSource(index); });
@ -84,7 +75,7 @@ HIDWiimote* GetHIDWiimoteSource(unsigned int index)
{
HIDWiimote* hid_source = nullptr;
WiimoteSource src = GetSource(index);
WiimoteSource src = Wiimote::GetSource(index);
switch (src)
{
case WiimoteSource::Emulated:
@ -227,6 +218,11 @@ void Pause()
WiimoteReal::Pause();
}
WiimoteSource GetSource(unsigned int index)
{
return s_wiimote_sources[index];
}
void ChangeUIPrimeHack(int number, bool useMetroidUI)
{
WiimoteEmu::Wiimote* wiimote = static_cast<WiimoteEmu::Wiimote*>(s_config.GetController(number));

View File

@ -96,6 +96,7 @@ ControllerEmu::ControlGroup* GetDrawsomeTabletGroup(int number,
WiimoteEmu::DrawsomeTabletGroup group);
ControllerEmu::ControlGroup* GetTaTaConGroup(int number, WiimoteEmu::TaTaConGroup group);
WiimoteSource GetSource(unsigned int index);
void ChangeUIPrimeHack(int number, bool useMetroidUI);
bool CheckVisor(int visor_count);

View File

@ -500,4 +500,8 @@ std::string GetMotd() {
auto lock = std::lock_guard<std::mutex>(motd_lock);
return trilogy_motd;
}
bool UsingRealWiimote() {
return Wiimote::GetSource(0) == WiimoteSource::Real;
}
} // namespace prime

View File

@ -102,4 +102,6 @@ void ResumeMod();
void SetMotd(std::string const& motd);
std::string GetMotd();
bool UsingRealWiimote();
}

View File

@ -215,7 +215,7 @@ void HackManager::update_mod_states() {
}
// Disallow any PrimeHack control mods
if (!Config::Get(Config::PRIMEHACK_ENABLE))
if (!Config::Get(Config::PRIMEHACK_ENABLE) || UsingRealWiimote())
{
disable_mod("fps_controls");
disable_mod("springball_button");