Merge pull request #5123 from ligfx/fixwiimoteemu

WiimoteEmu: refer to settings by name, not index
This commit is contained in:
Matthew Parlane 2017-03-26 14:56:44 +13:00 committed by GitHub
commit 5d40daa507
2 changed files with 27 additions and 17 deletions

View File

@ -231,7 +231,7 @@ void Wiimote::Reset()
// 0x33 - 0x43: level 2 // 0x33 - 0x43: level 2
// 0x33 - 0x54: level 3 // 0x33 - 0x54: level 3
// 0x55 - 0xff: level 4 // 0x55 - 0xff: level 4
m_status.battery = (u8)(m_options->numeric_settings[1]->GetValue() * 100); m_status.battery = (u8)(m_battery_setting->GetValue() * 100);
memset(m_shake_step, 0, sizeof(m_shake_step)); memset(m_shake_step, 0, sizeof(m_shake_step));
@ -282,11 +282,11 @@ Wiimote::Wiimote(const unsigned int index)
m_extension->attachments.emplace_back(new WiimoteEmu::Turntable(m_reg_ext)); m_extension->attachments.emplace_back(new WiimoteEmu::Turntable(m_reg_ext));
m_extension->boolean_settings.emplace_back( m_extension->boolean_settings.emplace_back(
std::make_unique<ControllerEmu::BooleanSetting>(_trans("Motion Plus"), false)); m_motion_plus_setting = new ControllerEmu::BooleanSetting(_trans("Motion Plus"), false));
// rumble // rumble
groups.emplace_back(m_rumble = new ControllerEmu::ControlGroup(_trans("Rumble"))); groups.emplace_back(m_rumble = new ControllerEmu::ControlGroup(_trans("Rumble")));
m_rumble->controls.emplace_back(new ControllerEmu::Output(_trans("Motor"))); m_rumble->controls.emplace_back(m_motor = new ControllerEmu::Output(_trans("Motor")));
// dpad // dpad
groups.emplace_back(m_dpad = new ControllerEmu::Buttons("D-Pad")); groups.emplace_back(m_dpad = new ControllerEmu::Buttons("D-Pad"));
@ -295,16 +295,18 @@ Wiimote::Wiimote(const unsigned int index)
// options // options
groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options"))); groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options")));
m_options->boolean_settings.emplace_back(std::make_unique<ControllerEmu::BooleanSetting>( m_options->boolean_settings.emplace_back(
"Sideways Wiimote", _trans("Sideways Wii Remote"), false)); m_sideways_setting = new ControllerEmu::BooleanSetting("Sideways Wiimote",
m_options->boolean_settings.emplace_back(std::make_unique<ControllerEmu::BooleanSetting>( _trans("Sideways Wii Remote"), false));
"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"), false));
m_options->boolean_settings.emplace_back(std::make_unique<ControllerEmu::BooleanSetting>( m_options->boolean_settings.emplace_back(std::make_unique<ControllerEmu::BooleanSetting>(
_trans("Iterative Input"), false, ControllerEmu::SettingType::VIRTUAL)); _trans("Iterative Input"), false, ControllerEmu::SettingType::VIRTUAL));
m_options->numeric_settings.emplace_back( m_options->numeric_settings.emplace_back(
std::make_unique<ControllerEmu::NumericSetting>(_trans("Speaker Pan"), 0, -127, 127)); std::make_unique<ControllerEmu::NumericSetting>(_trans("Speaker Pan"), 0, -127, 127));
m_options->numeric_settings.emplace_back( m_options->numeric_settings.emplace_back(
std::make_unique<ControllerEmu::NumericSetting>(_trans("Battery"), 95.0 / 100, 0, 255)); m_battery_setting = new ControllerEmu::NumericSetting(_trans("Battery"), 95.0 / 100, 0, 255));
// hotkeys // hotkeys
groups.emplace_back(m_hotkeys = new ControllerEmu::ModifySettingsButton(_trans("Hotkeys"))); groups.emplace_back(m_hotkeys = new ControllerEmu::ModifySettingsButton(_trans("Hotkeys")));
@ -386,9 +388,9 @@ ControllerEmu::ControlGroup* Wiimote::GetTurntableGroup(TurntableGroup group)
bool Wiimote::Step() bool Wiimote::Step()
{ {
// TODO: change this a bit // TODO: change this a bit
m_motion_plus_present = m_extension->boolean_settings[0]->GetValue(); m_motion_plus_present = m_motion_plus_setting->GetValue();
m_rumble->controls[0]->control_ref->State(m_rumble_on); m_motor->control_ref->State(m_rumble_on);
// when a movie is active, this button status update is disabled (moved), because movies only // when a movie is active, this button status update is disabled (moved), because movies only
// record data reports. // record data reports.
@ -441,8 +443,8 @@ void Wiimote::UpdateButtonsStatus()
m_status.buttons.hex = 0; m_status.buttons.hex = 0;
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];
const bool is_sideways = m_options->boolean_settings[1]->GetValue() ^ sideways_modifier_toggle ^ const bool is_sideways =
sideways_modifier_switch; m_sideways_setting->GetValue() ^ sideways_modifier_toggle ^ sideways_modifier_switch;
m_buttons->GetState(&m_status.buttons.hex, button_bitmasks); m_buttons->GetState(&m_status.buttons.hex, button_bitmasks);
m_dpad->GetState(&m_status.buttons.hex, is_sideways ? dpad_sideways_bitmasks : dpad_bitmasks); m_dpad->GetState(&m_status.buttons.hex, is_sideways ? dpad_sideways_bitmasks : dpad_bitmasks);
} }
@ -465,10 +467,10 @@ void Wiimote::GetAccelData(u8* const data, const ReportFeatures& rptf)
const bool upright_modifier_toggle = m_hotkeys->getSettingsModifier()[1]; const bool upright_modifier_toggle = m_hotkeys->getSettingsModifier()[1];
const bool sideways_modifier_switch = m_hotkeys->getSettingsModifier()[2]; const bool sideways_modifier_switch = m_hotkeys->getSettingsModifier()[2];
const bool upright_modifier_switch = m_hotkeys->getSettingsModifier()[3]; const bool upright_modifier_switch = m_hotkeys->getSettingsModifier()[3];
const bool is_sideways = m_options->boolean_settings[1]->GetValue() ^ sideways_modifier_toggle ^ const bool is_sideways =
sideways_modifier_switch; m_sideways_setting->GetValue() ^ sideways_modifier_toggle ^ sideways_modifier_switch;
const bool is_upright = m_options->boolean_settings[2]->GetValue() ^ upright_modifier_toggle ^ const bool is_upright =
upright_modifier_switch; m_upright_setting->GetValue() ^ upright_modifier_toggle ^ upright_modifier_switch;
EmulateTilt(&m_accel, m_tilt, is_sideways, is_upright); EmulateTilt(&m_accel, m_tilt, is_sideways, is_upright);
EmulateSwing(&m_accel, m_swing, is_sideways, is_upright); EmulateSwing(&m_accel, m_swing, is_sideways, is_upright);
@ -721,7 +723,7 @@ void Wiimote::Update()
Movie::SetPolledDevice(); Movie::SetPolledDevice();
m_status.battery = (u8)(m_options->numeric_settings[1]->GetValue() * 100); m_status.battery = (u8)(m_battery_setting->GetValue() * 100);
const ReportFeatures& rptf = reporting_mode_features[m_reporting_mode - WM_REPORT_CORE]; const ReportFeatures& rptf = reporting_mode_features[m_reporting_mode - WM_REPORT_CORE];
s8 rptf_size = rptf.size; s8 rptf_size = rptf.size;

View File

@ -22,12 +22,15 @@ class PointerWrap;
namespace ControllerEmu namespace ControllerEmu
{ {
class BooleanSetting;
class Buttons; class Buttons;
class ControlGroup; class ControlGroup;
class Cursor; class Cursor;
class Extension; class Extension;
class Force; class Force;
class ModifySettingsButton; class ModifySettingsButton;
class NumericSetting;
class Output;
class Tilt; class Tilt;
} }
@ -245,8 +248,13 @@ private:
ControllerEmu::Tilt* m_tilt; ControllerEmu::Tilt* m_tilt;
ControllerEmu::Force* m_swing; ControllerEmu::Force* m_swing;
ControllerEmu::ControlGroup* m_rumble; ControllerEmu::ControlGroup* m_rumble;
ControllerEmu::Output* m_motor;
ControllerEmu::Extension* m_extension; ControllerEmu::Extension* m_extension;
ControllerEmu::BooleanSetting* m_motion_plus_setting;
ControllerEmu::ControlGroup* m_options; ControllerEmu::ControlGroup* m_options;
ControllerEmu::BooleanSetting* m_sideways_setting;
ControllerEmu::BooleanSetting* m_upright_setting;
ControllerEmu::NumericSetting* m_battery_setting;
ControllerEmu::ModifySettingsButton* m_hotkeys; ControllerEmu::ModifySettingsButton* m_hotkeys;
// Wiimote accel data // Wiimote accel data