InputCommon: follow coding conventions and rename GetState() to UpdateState()

And remove useless include
This commit is contained in:
Filoppi 2021-05-04 23:48:55 +03:00
parent a261e61e9e
commit e9e41b925b
4 changed files with 26 additions and 27 deletions

View File

@ -19,7 +19,6 @@
#include "Core/HW/WiimoteEmu/WiimoteEmu.h" #include "Core/HW/WiimoteEmu/WiimoteEmu.h"
#include "Core/HW/WiimoteReal/WiimoteReal.h" #include "Core/HW/WiimoteReal/WiimoteReal.h"
#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h" #include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
#include "InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h"
namespace WiimoteEmu namespace WiimoteEmu
{ {

View File

@ -428,7 +428,7 @@ void Wiimote::Update()
// Hotkey / settings modifier // Hotkey / settings modifier
// Data is later accessed in IsSideways and IsUpright // Data is later accessed in IsSideways and IsUpright
m_hotkeys->GetState(); m_hotkeys->UpdateState();
// Update our motion simulations. // Update our motion simulations.
StepDynamics(); StepDynamics();
@ -700,15 +700,15 @@ EncryptionKey Wiimote::GetExtensionEncryptionKey() const
bool Wiimote::IsSideways() const bool Wiimote::IsSideways() const
{ {
const bool sideways_modifier_toggle = m_hotkeys->getSettingsModifier()[0]; const bool sideways_modifier_toggle = m_hotkeys->GetSettingsModifier()[0];
const bool sideways_modifier_switch = m_hotkeys->getSettingsModifier()[2]; const bool sideways_modifier_switch = m_hotkeys->GetSettingsModifier()[2];
return m_sideways_setting.GetValue() ^ sideways_modifier_toggle ^ sideways_modifier_switch; return m_sideways_setting.GetValue() ^ sideways_modifier_toggle ^ sideways_modifier_switch;
} }
bool Wiimote::IsUpright() const bool Wiimote::IsUpright() const
{ {
const bool upright_modifier_toggle = m_hotkeys->getSettingsModifier()[1]; const bool upright_modifier_toggle = m_hotkeys->GetSettingsModifier()[1];
const bool upright_modifier_switch = m_hotkeys->getSettingsModifier()[3]; const bool upright_modifier_switch = m_hotkeys->GetSettingsModifier()[3];
return m_upright_setting.GetValue() ^ upright_modifier_toggle ^ upright_modifier_switch; return m_upright_setting.GetValue() ^ upright_modifier_toggle ^ upright_modifier_switch;
} }

View File

@ -26,52 +26,52 @@ ModifySettingsButton::ModifySettingsButton(std::string button_name)
void ModifySettingsButton::AddInput(std::string button_name, bool toggle) void ModifySettingsButton::AddInput(std::string button_name, bool toggle)
{ {
ControlGroup::AddInput(Translate, std::move(button_name)); ControlGroup::AddInput(Translate, std::move(button_name));
threshold_exceeded.emplace_back(false); m_threshold_exceeded.emplace_back(false);
associated_settings.emplace_back(false); m_associated_settings.emplace_back(false);
associated_settings_toggle.emplace_back(toggle); m_associated_settings_toggle.emplace_back(toggle);
} }
void ModifySettingsButton::GetState() void ModifySettingsButton::UpdateState()
{ {
for (size_t i = 0; i < controls.size(); ++i) for (size_t i = 0; i < controls.size(); ++i)
{ {
const bool state = controls[i]->GetState<bool>(); const bool state = controls[i]->GetState<bool>();
if (!associated_settings_toggle[i]) if (!m_associated_settings_toggle[i])
{ {
// not toggled // not toggled
associated_settings[i] = state; m_associated_settings[i] = state;
} }
else else
{ {
// toggle (loading savestates does not en-/disable toggle) // toggle (loading savestates does not en-/disable toggle)
// after we passed the threshold, we en-/disable. but after that, we don't change it // after we passed the threshold, we en-/disable. but after that, we don't change it
// anymore // anymore
if (!threshold_exceeded[i] && state) if (!m_threshold_exceeded[i] && state)
{ {
associated_settings[i] = !associated_settings[i]; m_associated_settings[i] = !m_associated_settings[i];
if (associated_settings[i]) if (m_associated_settings[i])
OSD::AddMessage(controls[i]->ui_name + ": on"); OSD::AddMessage(controls[i]->ui_name + ": on");
else else
OSD::AddMessage(controls[i]->ui_name + ": off"); OSD::AddMessage(controls[i]->ui_name + ": off");
threshold_exceeded[i] = true; m_threshold_exceeded[i] = true;
} }
if (!state) if (!state)
threshold_exceeded[i] = false; m_threshold_exceeded[i] = false;
} }
} }
} }
const std::vector<bool>& ModifySettingsButton::isSettingToggled() const const std::vector<bool>& ModifySettingsButton::IsSettingToggled() const
{ {
return associated_settings_toggle; return m_associated_settings_toggle;
} }
const std::vector<bool>& ModifySettingsButton::getSettingsModifier() const const std::vector<bool>& ModifySettingsButton::GetSettingsModifier() const
{ {
return associated_settings; return m_associated_settings;
} }
} // namespace ControllerEmu } // namespace ControllerEmu

View File

@ -18,14 +18,14 @@ public:
void AddInput(std::string button_name, bool toggle = false); void AddInput(std::string button_name, bool toggle = false);
void GetState(); void UpdateState();
const std::vector<bool>& isSettingToggled() const; const std::vector<bool>& IsSettingToggled() const;
const std::vector<bool>& getSettingsModifier() const; const std::vector<bool>& GetSettingsModifier() const;
private: private:
std::vector<bool> threshold_exceeded; // internal calculation (if "state" was above threshold) std::vector<bool> m_threshold_exceeded; // internal calculation (if "state" was above threshold)
std::vector<bool> associated_settings_toggle; // is setting toggled or hold? std::vector<bool> m_associated_settings_toggle; // is setting toggled or hold?
std::vector<bool> associated_settings; // result std::vector<bool> m_associated_settings; // result
}; };
} // namespace ControllerEmu } // namespace ControllerEmu