diff --git a/HAL/pico/include/config_defaults.hpp b/HAL/pico/include/config_defaults.hpp index bddea8c2..e0fcc6ed 100644 --- a/HAL/pico/include/config_defaults.hpp +++ b/HAL/pico/include/config_defaults.hpp @@ -152,6 +152,14 @@ const Config default_config = { }, .default_backend_config = 1, .default_usb_backend_config = 1, + .melee_options = { + .crouch_walk_os = false, + .disable_ledgedash_socd_override = false, + }, + .project_m_options = { + .true_z_press = false, + .disable_ledgedash_socd_override = false, + }, }; // clang-format on diff --git a/include/modes/Melee20Button.hpp b/include/modes/Melee20Button.hpp index 71518a42..54f904f2 100644 --- a/include/modes/Melee20Button.hpp +++ b/include/modes/Melee20Button.hpp @@ -6,20 +6,17 @@ #include -typedef struct { - bool crouch_walk_os = false; -} Melee20ButtonOptions; - class Melee20Button : public ControllerMode { public: - Melee20Button(Melee20ButtonOptions options = {}); + Melee20Button(); + void SetConfig(GameModeConfig &config, const MeleeOptions options); protected: void UpdateDigitalOutputs(const InputState &inputs, OutputState &outputs); void UpdateAnalogOutputs(const InputState &inputs, OutputState &outputs); private: - Melee20ButtonOptions _options; + MeleeOptions _options; bool _horizontal_socd; void HandleSocd(InputState &inputs); diff --git a/include/modes/ProjectM.hpp b/include/modes/ProjectM.hpp index ed75856c..580fd544 100644 --- a/include/modes/ProjectM.hpp +++ b/include/modes/ProjectM.hpp @@ -4,14 +4,17 @@ #include "core/ControllerMode.hpp" #include "core/state.hpp" -typedef struct { - bool true_z_press = false; - bool ledgedash_max_jump_traj = true; -} ProjectMOptions; +#include + +// typedef struct { +// bool true_z_press = false; +// bool ledgedash_max_jump_traj = true; +// } ProjectMOptions; class ProjectM : public ControllerMode { public: - ProjectM(ProjectMOptions options = {}); + ProjectM(); + void SetConfig(GameModeConfig &config, const ProjectMOptions options); private: ProjectMOptions _options; diff --git a/platformio.ini b/platformio.ini index 1aec6b16..0672291d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -22,7 +22,7 @@ custom_nanopb_options = --error-on-unmatched lib_deps = nanopb/Nanopb@^0.4.8 - https://github.com/JonnyHaystack/HayBox-proto#703e11f + https://github.com/JonnyHaystack/HayBox-proto#f37657b [avr_base] platform = atmelavr diff --git a/src/core/mode_selection.cpp b/src/core/mode_selection.cpp index 4e8c44e0..a5b98822 100644 --- a/src/core/mode_selection.cpp +++ b/src/core/mode_selection.cpp @@ -12,8 +12,8 @@ #include -Melee20Button melee_mode({ .crouch_walk_os = false }); -ProjectM projectm_mode({ .true_z_press = false, .ledgedash_max_jump_traj = true }); +Melee20Button melee_mode; +ProjectM projectm_mode; Ultimate ultimate_mode; FgcMode fgc_mode; RivalsOfAether rivals_mode; @@ -49,11 +49,11 @@ void set_mode(CommunicationBackend *backend, KeyboardMode *mode) { void set_mode(CommunicationBackend *backend, GameModeConfig &mode_config, Config &config) { switch (mode_config.mode_id) { case MODE_MELEE: - melee_mode.SetConfig(mode_config); + melee_mode.SetConfig(mode_config, config.melee_options); set_mode(backend, &melee_mode); break; case MODE_PROJECT_M: - projectm_mode.SetConfig(mode_config); + projectm_mode.SetConfig(mode_config, config.project_m_options); set_mode(backend, &projectm_mode); break; case MODE_ULTIMATE: diff --git a/src/modes/Melee20Button.cpp b/src/modes/Melee20Button.cpp index 04da2bc7..766e609d 100644 --- a/src/modes/Melee20Button.cpp +++ b/src/modes/Melee20Button.cpp @@ -4,11 +4,15 @@ #define ANALOG_STICK_NEUTRAL 128 #define ANALOG_STICK_MAX 208 -Melee20Button::Melee20Button(Melee20ButtonOptions options) : ControllerMode() { - _options = options; +Melee20Button::Melee20Button() : ControllerMode() { _horizontal_socd = false; } +void Melee20Button::SetConfig(GameModeConfig &config, const MeleeOptions options) { + InputMode::SetConfig(config); + _options = options; +} + void Melee20Button::HandleSocd(InputState &inputs) { _horizontal_socd = inputs.lf3 && inputs.lf1; InputMode::HandleSocd(inputs); @@ -73,6 +77,7 @@ void Melee20Button::UpdateAnalogOutputs(const InputState &inputs, OutputState &o } } + /* Mod X */ if (inputs.lt1) { // MX + Horizontal (even if shield is held) = 6625 = 53 if (directions.horizontal) { @@ -83,9 +88,15 @@ void Melee20Button::UpdateAnalogOutputs(const InputState &inputs, OutputState &o outputs.leftStickY = 128 + (directions.y * 43); } if (directions.diagonal && shield_button_pressed) { - // MX + L, R, LS, and MS + q1/2/3/4 = 6375 3750 = 51 30 - outputs.leftStickX = 128 + (directions.x * 51); - outputs.leftStickY = 128 + (directions.y * 30); + // Use custom airdodge angle if set, otherwise B0XX standard default. + if (_options.has_custom_airdodge) { + outputs.leftStickX = 128 + (directions.x * _options.custom_airdodge.x); + outputs.leftStickY = 128 + (directions.y * _options.custom_airdodge.y); + } else { + // MX + L, R, LS, and MS + q1/2/3/4 = 6375 3750 = 51 30 + outputs.leftStickX = 128 + (directions.x * 51); + outputs.leftStickY = 128 + (directions.y * 30); + } } /* Up B angles */ @@ -150,6 +161,7 @@ void Melee20Button::UpdateAnalogOutputs(const InputState &inputs, OutputState &o } } + /* Mod Y */ if (inputs.lt2) { // MY + Horizontal (even if shield is held) = 3375 = 27 if (directions.horizontal) { @@ -240,7 +252,7 @@ void Melee20Button::UpdateAnalogOutputs(const InputState &inputs, OutputState &o // Horizontal SOCD overrides X-axis modifiers (for ledgedash maximum jump // trajectory). - if (_horizontal_socd && !directions.vertical) { + if (!_options.disable_ledgedash_socd_override && _horizontal_socd && !directions.vertical) { outputs.leftStickX = 128 + (directions.x * 80); } diff --git a/src/modes/ProjectM.cpp b/src/modes/ProjectM.cpp index 5556c31c..5246bbca 100644 --- a/src/modes/ProjectM.cpp +++ b/src/modes/ProjectM.cpp @@ -4,11 +4,15 @@ #define ANALOG_STICK_NEUTRAL 128 #define ANALOG_STICK_MAX 228 -ProjectM::ProjectM(ProjectMOptions options) : ControllerMode() { - _options = options; +ProjectM::ProjectM() : ControllerMode() { _horizontal_socd = false; } +void ProjectM::SetConfig(GameModeConfig &config, const ProjectMOptions options) { + InputMode::SetConfig(config); + _options = options; +} + void ProjectM::HandleSocd(InputState &inputs) { _horizontal_socd = inputs.lf3 && inputs.lf1; InputMode::HandleSocd(inputs); @@ -76,6 +80,7 @@ void ProjectM::UpdateAnalogOutputs(const InputState &inputs, OutputState &output } } + /* Mod X */ if (inputs.lt1) { if (directions.horizontal) { outputs.leftStickX = 128 + (directions.x * 70); @@ -90,6 +95,7 @@ void ProjectM::UpdateAnalogOutputs(const InputState &inputs, OutputState &output } if (directions.diagonal) { + // Default MX Diagonal outputs.leftStickX = 128 + (directions.x * 70); outputs.leftStickY = 128 + (directions.y * 34); @@ -98,9 +104,15 @@ void ProjectM::UpdateAnalogOutputs(const InputState &inputs, OutputState &output outputs.leftStickY = 128 + (directions.y * 31); } + // Airdodge angle if (inputs.rf5) { - outputs.leftStickX = 128 + (directions.x * 82); - outputs.leftStickY = 128 + (directions.y * 35); + if (_options.has_custom_airdodge) { + outputs.leftStickX = 128 + (directions.x * _options.custom_airdodge.x); + outputs.leftStickY = 128 + (directions.y * _options.custom_airdodge.y); + } else { + outputs.leftStickX = 128 + (directions.x * 82); + outputs.leftStickY = 128 + (directions.y * 35); + } } if (inputs.rt4) { @@ -125,6 +137,7 @@ void ProjectM::UpdateAnalogOutputs(const InputState &inputs, OutputState &output } } + /* Mod Y */ if (inputs.lt2) { if (directions.horizontal) { outputs.leftStickX = 128 + (directions.x * 35); @@ -181,7 +194,7 @@ void ProjectM::UpdateAnalogOutputs(const InputState &inputs, OutputState &output // Horizontal SOCD overrides X-axis modifiers (for ledgedash maximum jump // trajectory). - if (_options.ledgedash_max_jump_traj && _horizontal_socd && !directions.vertical && + if (!_options.disable_ledgedash_socd_override && _horizontal_socd && !directions.vertical && !shield_button_pressed) { outputs.leftStickX = 128 + (directions.x * 100); }