Skip to content

Commit

Permalink
InputCommon: follow coding conventions and rename GetState() to Updat…
Browse files Browse the repository at this point in the history
…eState()

And remove useless include
  • Loading branch information
Filoppi committed May 10, 2021
1 parent a261e61 commit e9e41b9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
1 change: 0 additions & 1 deletion Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp
Expand Up @@ -19,7 +19,6 @@
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
#include "Core/HW/WiimoteReal/WiimoteReal.h"
#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
#include "InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h"

namespace WiimoteEmu
{
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
Expand Up @@ -428,7 +428,7 @@ void Wiimote::Update()

// Hotkey / settings modifier
// Data is later accessed in IsSideways and IsUpright
m_hotkeys->GetState();
m_hotkeys->UpdateState();

// Update our motion simulations.
StepDynamics();
Expand Down Expand Up @@ -700,15 +700,15 @@ EncryptionKey Wiimote::GetExtensionEncryptionKey() const

bool Wiimote::IsSideways() const
{
const bool sideways_modifier_toggle = m_hotkeys->getSettingsModifier()[0];
const bool sideways_modifier_switch = m_hotkeys->getSettingsModifier()[2];
const bool sideways_modifier_toggle = m_hotkeys->GetSettingsModifier()[0];
const bool sideways_modifier_switch = m_hotkeys->GetSettingsModifier()[2];
return m_sideways_setting.GetValue() ^ sideways_modifier_toggle ^ sideways_modifier_switch;
}

bool Wiimote::IsUpright() const
{
const bool upright_modifier_toggle = m_hotkeys->getSettingsModifier()[1];
const bool upright_modifier_switch = m_hotkeys->getSettingsModifier()[3];
const bool upright_modifier_toggle = m_hotkeys->GetSettingsModifier()[1];
const bool upright_modifier_switch = m_hotkeys->GetSettingsModifier()[3];
return m_upright_setting.GetValue() ^ upright_modifier_toggle ^ upright_modifier_switch;
}

Expand Down
Expand Up @@ -26,52 +26,52 @@ ModifySettingsButton::ModifySettingsButton(std::string button_name)
void ModifySettingsButton::AddInput(std::string button_name, bool toggle)
{
ControlGroup::AddInput(Translate, std::move(button_name));
threshold_exceeded.emplace_back(false);
associated_settings.emplace_back(false);
associated_settings_toggle.emplace_back(toggle);
m_threshold_exceeded.emplace_back(false);
m_associated_settings.emplace_back(false);
m_associated_settings_toggle.emplace_back(toggle);
}

void ModifySettingsButton::GetState()
void ModifySettingsButton::UpdateState()
{
for (size_t i = 0; i < controls.size(); ++i)
{
const bool state = controls[i]->GetState<bool>();

if (!associated_settings_toggle[i])
if (!m_associated_settings_toggle[i])
{
// not toggled
associated_settings[i] = state;
m_associated_settings[i] = state;
}
else
{
// toggle (loading savestates does not en-/disable toggle)
// after we passed the threshold, we en-/disable. but after that, we don't change it
// 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");
else
OSD::AddMessage(controls[i]->ui_name + ": off");

threshold_exceeded[i] = true;
m_threshold_exceeded[i] = true;
}

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
Expand Up @@ -18,14 +18,14 @@ class ModifySettingsButton : public Buttons

void AddInput(std::string button_name, bool toggle = false);

void GetState();
void UpdateState();

const std::vector<bool>& isSettingToggled() const;
const std::vector<bool>& getSettingsModifier() const;
const std::vector<bool>& IsSettingToggled() const;
const std::vector<bool>& GetSettingsModifier() const;

private:
std::vector<bool> threshold_exceeded; // internal calculation (if "state" was above threshold)
std::vector<bool> associated_settings_toggle; // is setting toggled or hold?
std::vector<bool> associated_settings; // result
std::vector<bool> m_threshold_exceeded; // internal calculation (if "state" was above threshold)
std::vector<bool> m_associated_settings_toggle; // is setting toggled or hold?
std::vector<bool> m_associated_settings; // result
};
} // namespace ControllerEmu

0 comments on commit e9e41b9

Please sign in to comment.