From 9936a83a1b56b6e7b6f170c112caa683a125b356 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Wed, 21 Mar 2018 22:48:17 -0500 Subject: [PATCH] Add game-configurable shake/swing commands for the nunchuk at three intensities --- .../Core/Core/Config/WiimoteInputSettings.cpp | 10 ++++++++ .../Core/Core/Config/WiimoteInputSettings.h | 10 ++++++++ .../Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp | 23 +++++++++++++++++-- .../Core/HW/WiimoteEmu/Attachment/Nunchuk.h | 6 +++++ 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/Config/WiimoteInputSettings.cpp b/Source/Core/Core/Config/WiimoteInputSettings.cpp index 408e9f68a3..a60ed45e9f 100644 --- a/Source/Core/Core/Config/WiimoteInputSettings.cpp +++ b/Source/Core/Core/Config/WiimoteInputSettings.cpp @@ -17,4 +17,14 @@ namespace Config const ConfigInfo WIIMOTE_INPUT_SHAKE_INTENSITY_HARD{ { System::WiiPad, "Shake", "Hard" }, 5.0 }; const ConfigInfo WIIMOTE_INPUT_SHAKE_INTENSITY_MEDIUM{ { System::WiiPad, "Shake", "Medium" }, 3.0 }; const ConfigInfo WIIMOTE_INPUT_SHAKE_INTENSITY_SOFT{ { System::WiiPad, "Shake", "Soft" }, 2.0 }; + + // NunchuckInput.Settings + + const ConfigInfo NUNCHUK_INPUT_SWING_INTENSITY_FAST{ { System::WiiPad, "Nunchuk_Swing", "Fast" }, 4.5 }; + const ConfigInfo NUNCHUK_INPUT_SWING_INTENSITY_MEDIUM{ { System::WiiPad, "Nunchuk_Swing", "Medium" }, 2.5 }; + const ConfigInfo NUNCHUK_INPUT_SWING_INTENSITY_SLOW{ { System::WiiPad, "Nunchuk_Swing", "Slow" }, 1.5 }; + + const ConfigInfo NUNCHUK_INPUT_SHAKE_INTENSITY_HARD{ { System::WiiPad, "Nunchuk_Shake", "Hard" }, 5.0 }; + const ConfigInfo NUNCHUK_INPUT_SHAKE_INTENSITY_MEDIUM{ { System::WiiPad, "Nunchuk_Shake", "Medium" }, 3.0 }; + const ConfigInfo NUNCHUK_INPUT_SHAKE_INTENSITY_SOFT{ { System::WiiPad, "Nunchuk_Shake", "Soft" }, 2.0 }; } diff --git a/Source/Core/Core/Config/WiimoteInputSettings.h b/Source/Core/Core/Config/WiimoteInputSettings.h index c9946af046..44ab85b37d 100644 --- a/Source/Core/Core/Config/WiimoteInputSettings.h +++ b/Source/Core/Core/Config/WiimoteInputSettings.h @@ -20,4 +20,14 @@ namespace Config extern const ConfigInfo WIIMOTE_INPUT_SHAKE_INTENSITY_MEDIUM; extern const ConfigInfo WIIMOTE_INPUT_SHAKE_INTENSITY_SOFT; + // NunchuckInput.Settings + + extern const ConfigInfo NUNCHUK_INPUT_SWING_INTENSITY_FAST; + extern const ConfigInfo NUNCHUK_INPUT_SWING_INTENSITY_MEDIUM; + extern const ConfigInfo NUNCHUK_INPUT_SWING_INTENSITY_SLOW; + + extern const ConfigInfo NUNCHUK_INPUT_SHAKE_INTENSITY_HARD; + extern const ConfigInfo NUNCHUK_INPUT_SHAKE_INTENSITY_MEDIUM; + extern const ConfigInfo NUNCHUK_INPUT_SHAKE_INTENSITY_SOFT; + } // namespace Config diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp index 092ef0c36d..9ba2a8e079 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp @@ -11,6 +11,7 @@ #include "Common/Common.h" #include "Common/CommonTypes.h" #include "Common/MathUtil.h" +#include "Core/Config/WiimoteInputSettings.h" #include "Core/HW/WiimoteEmu/WiimoteEmu.h" #include "InputCommon/ControllerEmu/Control/Input.h" @@ -42,6 +43,8 @@ Nunchuk::Nunchuk(ExtensionReg& reg) : Attachment(_trans("Nunchuk"), reg) // swing groups.emplace_back(m_swing = new ControllerEmu::Force(_trans("Swing"))); + groups.emplace_back(m_swing_slow = new ControllerEmu::Force("SwingSlow")); + groups.emplace_back(m_swing_fast = new ControllerEmu::Force("SwingFast")); // tilt groups.emplace_back(m_tilt = new ControllerEmu::Tilt(_trans("Tilt"))); @@ -55,6 +58,16 @@ Nunchuk::Nunchuk(ExtensionReg& reg) : Attachment(_trans("Nunchuk"), reg) // i18n: Refers to a 3D axis (used when mapping motion controls) m_shake->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::Translate, _trans("Z"))); + groups.emplace_back(m_shake_soft = new ControllerEmu::Buttons("ShakeSoft")); + m_shake_soft->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "X")); + m_shake_soft->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "Y")); + m_shake_soft->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "Z")); + + groups.emplace_back(m_shake_hard = new ControllerEmu::Buttons("ShakeHard")); + m_shake_hard->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "X")); + m_shake_hard->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "Y")); + m_shake_hard->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "Z")); + m_id = nunchuk_id; } @@ -91,9 +104,15 @@ void Nunchuk::GetState(u8* const data) EmulateTilt(&accel, m_tilt); // swing - EmulateSwing(&accel, m_swing, 2.5); + EmulateSwing(&accel, m_swing, Config::Get(Config::NUNCHUK_INPUT_SWING_INTENSITY_MEDIUM)); + EmulateSwing(&accel, m_swing_slow, Config::Get(Config::NUNCHUK_INPUT_SWING_INTENSITY_SLOW)); + EmulateSwing(&accel, m_swing_fast, Config::Get(Config::NUNCHUK_INPUT_SWING_INTENSITY_FAST)); + // shake - EmulateShake(&accel, m_shake, 3.0, m_shake_step.data()); + EmulateShake(&accel, m_shake, Config::Get(Config::NUNCHUK_INPUT_SHAKE_INTENSITY_MEDIUM), m_shake_step.data()); + EmulateShake(&accel, m_shake_soft, Config::Get(Config::NUNCHUK_INPUT_SHAKE_INTENSITY_SOFT), m_shake_soft_step.data()); + EmulateShake(&accel, m_shake_hard, Config::Get(Config::NUNCHUK_INPUT_SHAKE_INTENSITY_HARD), m_shake_hard_step.data()); + // buttons m_buttons->GetState(&nc_data.bt.hex, nunchuk_button_bitmasks.data()); diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h index 48ec942672..8a8f5d5d08 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.h @@ -55,12 +55,18 @@ public: private: ControllerEmu::Tilt* m_tilt; ControllerEmu::Force* m_swing; + ControllerEmu::Force* m_swing_slow; + ControllerEmu::Force* m_swing_fast; ControllerEmu::Buttons* m_shake; + ControllerEmu::Buttons* m_shake_soft; + ControllerEmu::Buttons* m_shake_hard; ControllerEmu::Buttons* m_buttons; ControllerEmu::AnalogStick* m_stick; std::array m_shake_step{}; + std::array m_shake_soft_step{}; + std::array m_shake_hard_step{}; }; }