mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-01-31 19:43:35 +00:00
Yellow squiggly lines begone! Done automatically on .cpp files through `run-clang-tidy`, with manual corrections to the mistakes. If an import is directly used, but is technically unnecessary since it's recursively imported by something else, it is *not* removed. The tool doesn't touch .h files, so I did some of them by hand while fixing errors due to old recursive imports. Not everything is removed, but the cleanup should be substantial enough. Because this done on Linux, code that isn't used on it is mostly untouched. (Hopefully no open PR is depending on these imports...)
73 lines
1.8 KiB
C++
73 lines
1.8 KiB
C++
// Copyright 2017 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include "InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h"
|
|
|
|
#include <cstddef>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <utility>
|
|
|
|
#include "InputCommon/ControllerEmu/Control/Control.h"
|
|
#include "VideoCommon/OnScreenDisplay.h"
|
|
|
|
namespace ControllerEmu
|
|
{
|
|
ModifySettingsButton::ModifySettingsButton(std::string button_name)
|
|
: Buttons(std::move(button_name))
|
|
{
|
|
}
|
|
|
|
void ModifySettingsButton::AddInput(std::string button_name, bool toggle)
|
|
{
|
|
ControlGroup::AddInput(Translatability::Translate, std::move(button_name));
|
|
m_threshold_exceeded.emplace_back(false);
|
|
m_associated_settings.emplace_back(false);
|
|
m_associated_settings_toggle.emplace_back(toggle);
|
|
}
|
|
|
|
void ModifySettingsButton::UpdateState()
|
|
{
|
|
for (size_t i = 0; i < controls.size(); ++i)
|
|
{
|
|
const bool state = controls[i]->GetState<bool>();
|
|
|
|
if (!m_associated_settings_toggle[i])
|
|
{
|
|
// not toggled
|
|
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 (!m_threshold_exceeded[i] && state)
|
|
{
|
|
m_associated_settings[i] = !m_associated_settings[i];
|
|
|
|
if (m_associated_settings[i])
|
|
OSD::AddMessage(controls[i]->ui_name + ": on");
|
|
else
|
|
OSD::AddMessage(controls[i]->ui_name + ": off");
|
|
|
|
m_threshold_exceeded[i] = true;
|
|
}
|
|
|
|
if (!state)
|
|
m_threshold_exceeded[i] = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
const std::vector<bool>& ModifySettingsButton::IsSettingToggled() const
|
|
{
|
|
return m_associated_settings_toggle;
|
|
}
|
|
|
|
const std::vector<bool>& ModifySettingsButton::GetSettingsModifier() const
|
|
{
|
|
return m_associated_settings;
|
|
}
|
|
} // namespace ControllerEmu
|