Merge pull request #7204 from spycrab/exclusive_mapping
Support for exclusive mapping booleans
This commit is contained in:
commit
eb01a0a040
|
@ -49,7 +49,7 @@ namespace
|
|||
// :)
|
||||
auto const TAU = 6.28318530717958647692;
|
||||
auto const PI = TAU / 2.0;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
@ -308,12 +308,13 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index), ir_sin(0), ir_cos(1
|
|||
|
||||
// options
|
||||
groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options")));
|
||||
m_options->boolean_settings.emplace_back(
|
||||
m_sideways_setting = new ControllerEmu::BooleanSetting("Sideways Wiimote",
|
||||
_trans("Sideways Wii Remote"), false));
|
||||
m_options->boolean_settings.emplace_back(
|
||||
m_upright_setting = new ControllerEmu::BooleanSetting("Upright Wiimote",
|
||||
_trans("Upright Wii Remote"), false));
|
||||
m_options->boolean_settings.emplace_back(m_upright_setting = new ControllerEmu::BooleanSetting(
|
||||
"Upright Wiimote", _trans("Upright Wii Remote"),
|
||||
true, ControllerEmu::SettingType::NORMAL, true));
|
||||
m_options->boolean_settings.emplace_back(m_sideways_setting = new ControllerEmu::BooleanSetting(
|
||||
"Sideways Wiimote", _trans("Sideways Wii Remote"),
|
||||
false, ControllerEmu::SettingType::NORMAL, true));
|
||||
|
||||
m_options->numeric_settings.emplace_back(
|
||||
std::make_unique<ControllerEmu::NumericSetting>(_trans("Speaker Pan"), 0, -127, 127));
|
||||
m_options->numeric_settings.emplace_back(
|
||||
|
|
|
@ -63,6 +63,7 @@ add_executable(dolphin-emu
|
|||
Config/Mapping/MappingCommon.cpp
|
||||
Config/Mapping/MappingIndicator.cpp
|
||||
Config/Mapping/MappingNumeric.cpp
|
||||
Config/Mapping/MappingRadio.cpp
|
||||
Config/Mapping/MappingWidget.cpp
|
||||
Config/Mapping/MappingWindow.cpp
|
||||
Config/Mapping/WiimoteEmuExtension.cpp
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DolphinQt2/Config/Mapping/MappingRadio.h"
|
||||
|
||||
#include "DolphinQt2/Config/Mapping/MappingWidget.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
|
||||
MappingRadio::MappingRadio(MappingWidget* widget, ControllerEmu::BooleanSetting* setting)
|
||||
: QRadioButton(tr(setting->m_ui_name.c_str())), m_parent(widget), m_setting(setting)
|
||||
{
|
||||
Update();
|
||||
Connect();
|
||||
}
|
||||
|
||||
void MappingRadio::Connect()
|
||||
{
|
||||
connect(this, &QRadioButton::toggled, this, [this](int value) {
|
||||
m_setting->SetValue(value);
|
||||
m_parent->SaveSettings();
|
||||
m_parent->GetController()->UpdateReferences(g_controller_interface);
|
||||
});
|
||||
}
|
||||
|
||||
void MappingRadio::Clear()
|
||||
{
|
||||
m_setting->SetValue(false);
|
||||
m_parent->SaveSettings();
|
||||
Update();
|
||||
}
|
||||
|
||||
void MappingRadio::Update()
|
||||
{
|
||||
setChecked(m_setting->GetValue());
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QRadioButton>
|
||||
|
||||
class MappingWidget;
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class BooleanSetting;
|
||||
};
|
||||
|
||||
class MappingRadio : public QRadioButton
|
||||
{
|
||||
public:
|
||||
MappingRadio(MappingWidget* widget, ControllerEmu::BooleanSetting* setting);
|
||||
|
||||
void Clear();
|
||||
void Update();
|
||||
|
||||
private:
|
||||
void Connect();
|
||||
|
||||
MappingWidget* m_parent;
|
||||
ControllerEmu::BooleanSetting* m_setting;
|
||||
};
|
|
@ -13,6 +13,7 @@
|
|||
#include "DolphinQt2/Config/Mapping/MappingButton.h"
|
||||
#include "DolphinQt2/Config/Mapping/MappingIndicator.h"
|
||||
#include "DolphinQt2/Config/Mapping/MappingNumeric.h"
|
||||
#include "DolphinQt2/Config/Mapping/MappingRadio.h"
|
||||
#include "DolphinQt2/Config/Mapping/MappingWindow.h"
|
||||
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
|
@ -114,7 +115,22 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
|
|||
|
||||
for (auto& boolean : group->boolean_settings)
|
||||
{
|
||||
if (!boolean->IsExclusive())
|
||||
continue;
|
||||
|
||||
auto* checkbox = new MappingRadio(this, boolean.get());
|
||||
|
||||
form_layout->addRow(checkbox);
|
||||
m_radio.push_back(checkbox);
|
||||
}
|
||||
|
||||
for (auto& boolean : group->boolean_settings)
|
||||
{
|
||||
if (boolean->IsExclusive())
|
||||
continue;
|
||||
|
||||
auto* checkbox = new MappingBool(this, boolean.get());
|
||||
|
||||
form_layout->addRow(checkbox);
|
||||
m_bools.push_back(checkbox);
|
||||
}
|
||||
|
@ -135,6 +151,9 @@ void MappingWidget::OnClearFields()
|
|||
|
||||
for (auto* checkbox : m_bools)
|
||||
checkbox->Clear();
|
||||
|
||||
for (auto* radio : m_radio)
|
||||
radio->Clear();
|
||||
}
|
||||
|
||||
void MappingWidget::Update()
|
||||
|
@ -148,6 +167,9 @@ void MappingWidget::Update()
|
|||
for (auto* checkbox : m_bools)
|
||||
checkbox->Update();
|
||||
|
||||
for (auto* radio : m_radio)
|
||||
radio->Update();
|
||||
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ class MappingBool;
|
|||
class MappingButton;
|
||||
class MappingNumeric;
|
||||
class MappingWindow;
|
||||
class MappingRadio;
|
||||
class QGroupBox;
|
||||
|
||||
namespace ControllerEmu
|
||||
|
@ -64,6 +65,7 @@ private:
|
|||
MappingWindow* m_parent;
|
||||
bool m_first = true;
|
||||
std::vector<MappingBool*> m_bools;
|
||||
std::vector<MappingRadio*> m_radio;
|
||||
std::vector<MappingButton*> m_buttons;
|
||||
std::vector<MappingNumeric*> m_numerics;
|
||||
};
|
||||
|
|
|
@ -296,6 +296,7 @@
|
|||
<ClCompile Include="Config\Mapping\MappingCommon.cpp" />
|
||||
<ClCompile Include="Config\Mapping\MappingIndicator.cpp" />
|
||||
<ClCompile Include="Config\Mapping\MappingNumeric.cpp" />
|
||||
<ClCompile Include="Config\Mapping\MappingRadio.cpp" />
|
||||
<ClCompile Include="Config\Mapping\MappingWidget.cpp" />
|
||||
<ClCompile Include="Config\Mapping\MappingWindow.cpp" />
|
||||
<ClCompile Include="Config\Mapping\WiimoteEmuExtension.cpp" />
|
||||
|
@ -368,6 +369,7 @@
|
|||
<!--Put standard C/C++ headers here. Headers that are listed in the QtMoc ItemGroup must NOT be listed here.-->
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Config\Mapping\MappingCommon.h" />
|
||||
<ClInclude Include="Config\Mapping\MappingRadio.h" />
|
||||
<ClInclude Include="Debugger\RegisterColumn.h" />
|
||||
<ClInclude Include="QtUtils\ActionHelper.h" />
|
||||
<ClInclude Include="QtUtils\ImageConverter.h" />
|
||||
|
|
|
@ -7,15 +7,16 @@
|
|||
namespace ControllerEmu
|
||||
{
|
||||
BooleanSetting::BooleanSetting(const std::string& setting_name, const std::string& ui_name,
|
||||
const bool default_value, const SettingType setting_type)
|
||||
const bool default_value, const SettingType setting_type,
|
||||
const bool exclusive)
|
||||
: m_type(setting_type), m_name(setting_name), m_ui_name(ui_name),
|
||||
m_default_value(default_value), m_value(default_value)
|
||||
m_default_value(default_value), m_value(default_value), m_exclusive(exclusive)
|
||||
{
|
||||
}
|
||||
|
||||
BooleanSetting::BooleanSetting(const std::string& setting_name, const bool default_value,
|
||||
const SettingType setting_type)
|
||||
: BooleanSetting(setting_name, setting_name, default_value, setting_type)
|
||||
const SettingType setting_type, const bool exclusive)
|
||||
: BooleanSetting(setting_name, setting_name, default_value, setting_type, exclusive)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -23,6 +24,12 @@ bool BooleanSetting::GetValue() const
|
|||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
bool BooleanSetting::IsExclusive() const
|
||||
{
|
||||
return m_exclusive;
|
||||
}
|
||||
|
||||
void BooleanSetting::SetValue(bool value)
|
||||
{
|
||||
m_value = value;
|
||||
|
|
|
@ -15,17 +15,24 @@ class BooleanSetting
|
|||
{
|
||||
public:
|
||||
BooleanSetting(const std::string& setting_name, const std::string& ui_name,
|
||||
const bool default_value, const SettingType setting_type = SettingType::NORMAL);
|
||||
const bool default_value, const SettingType setting_type = SettingType::NORMAL,
|
||||
const bool exclusive = false);
|
||||
BooleanSetting(const std::string& setting_name, const bool default_value,
|
||||
const SettingType setting_type = SettingType::NORMAL);
|
||||
const SettingType setting_type = SettingType::NORMAL,
|
||||
const bool exclusive = false);
|
||||
|
||||
bool GetValue() const;
|
||||
void SetValue(bool value);
|
||||
bool IsExclusive() const;
|
||||
|
||||
const SettingType m_type;
|
||||
const std::string m_name;
|
||||
const std::string m_ui_name;
|
||||
const bool m_default_value;
|
||||
bool m_value;
|
||||
|
||||
private:
|
||||
const bool m_exclusive;
|
||||
};
|
||||
|
||||
} // namespace ControllerEmu
|
||||
|
|
Loading…
Reference in New Issue