diff --git a/HAL/avr/avr_nousb/include/core/KeyboardMode.hpp b/HAL/avr/avr_nousb/include/core/KeyboardMode.hpp index 4f08a6f9..7c0b7c8f 100644 --- a/HAL/avr/avr_nousb/include/core/KeyboardMode.hpp +++ b/HAL/avr/avr_nousb/include/core/KeyboardMode.hpp @@ -8,7 +8,7 @@ class KeyboardMode : public InputMode { public: - KeyboardMode(socd::SocdType socd_type); + KeyboardMode(); ~KeyboardMode(); void SendReport(InputState &inputs); diff --git a/HAL/avr/avr_nousb/src/core/KeyboardMode.cpp b/HAL/avr/avr_nousb/src/core/KeyboardMode.cpp index 3901ec72..b7ce470d 100644 --- a/HAL/avr/avr_nousb/src/core/KeyboardMode.cpp +++ b/HAL/avr/avr_nousb/src/core/KeyboardMode.cpp @@ -2,7 +2,7 @@ #include "core/InputMode.hpp" -KeyboardMode::KeyboardMode(socd::SocdType socd_type) : InputMode(socd_type) {} +KeyboardMode::KeyboardMode() {} KeyboardMode::~KeyboardMode() {} diff --git a/HAL/avr/avr_usb/include/core/KeyboardMode.hpp b/HAL/avr/avr_usb/include/core/KeyboardMode.hpp index 61295216..bcdcf9c6 100644 --- a/HAL/avr/avr_usb/include/core/KeyboardMode.hpp +++ b/HAL/avr/avr_usb/include/core/KeyboardMode.hpp @@ -9,7 +9,7 @@ class KeyboardMode : public InputMode { public: - KeyboardMode(socd::SocdType socd_type); + KeyboardMode(); ~KeyboardMode(); void SendReport(InputState &inputs); diff --git a/HAL/avr/avr_usb/src/core/KeyboardMode.cpp b/HAL/avr/avr_usb/src/core/KeyboardMode.cpp index cde3e861..edf6435e 100644 --- a/HAL/avr/avr_usb/src/core/KeyboardMode.cpp +++ b/HAL/avr/avr_usb/src/core/KeyboardMode.cpp @@ -4,7 +4,7 @@ #include -KeyboardMode::KeyboardMode(socd::SocdType socd_type) : InputMode(socd_type) {} +KeyboardMode::KeyboardMode() {} KeyboardMode::~KeyboardMode() { _keyboard.releaseAll(); diff --git a/HAL/pico/include/core/KeyboardMode.hpp b/HAL/pico/include/core/KeyboardMode.hpp index 6dd719ec..e2d5e79f 100644 --- a/HAL/pico/include/core/KeyboardMode.hpp +++ b/HAL/pico/include/core/KeyboardMode.hpp @@ -9,7 +9,7 @@ class KeyboardMode : public InputMode { public: - KeyboardMode(socd::SocdType socd_type); + KeyboardMode(); ~KeyboardMode(); void SendReport(InputState &inputs); diff --git a/HAL/pico/src/core/KeyboardMode.cpp b/HAL/pico/src/core/KeyboardMode.cpp index 31d9b6a1..c87acf7c 100644 --- a/HAL/pico/src/core/KeyboardMode.cpp +++ b/HAL/pico/src/core/KeyboardMode.cpp @@ -4,7 +4,7 @@ #include -KeyboardMode::KeyboardMode(socd::SocdType socd_type) : InputMode(socd_type) { +KeyboardMode::KeyboardMode() { _keyboard = new TUKeyboard(); _keyboard->begin(); } diff --git a/README.md b/README.md index ae989448..ecd4a082 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Features include: - Existing modes for popular games (e.g. Melee, Project M, Ultimate, Rivals of Aether, traditional fighting games) - Easy to create new controller modes (or keyboard modes) for different games - USB keyboard game modes for games that lack gamepad support -- Fully customisable SOCD cleaning, allowing you to configure SOCD button pairs (e.g. left/right, up/down) for each controller/keyboard mode, and also easily change the SOCD resolution method +- Fully customisable SOCD cleaning, allowing you to configure SOCD button pairs (e.g. left/right, up/down) for each controller/keyboard mode, and also easily change the SOCD resolution method for each SOCD pair - Switch modes on the fly without unplugging your controller - Automatically detects whether plugged into console or USB - Game modes and communication backends are independent entities, meaning you can use any game mode with any supported console without extra work @@ -210,9 +210,8 @@ To configure the button holds for input modes (controller/keyboard modes), edit the `select_mode()` function in `config/mode_selection.hpp`. Each `if` statement is a button combination to select an input mode. -All input modes support passing in a SOCD cleaning mode, e.g. -`socd::2IP_NO_REAC`. You can see the other available modes in -`src/include/socd.hpp`. +Most input modes support passing in an SOCD cleaning mode, e.g. +`socd::2IP_NO_REAC`. See [here](#socd) for the other available modes. ### Creating custom input modes @@ -281,7 +280,7 @@ along with the other analog outputs. Also note: You don't need to worry about resetting the output state or clearing anything from it. This is done automatically at the start of each iteration. -#### SOCD +### SOCD In the constructor of each mode (for controller modes *and* keyboard modes), you can configure pairs of opposing direction inputs to apply SOCD cleaning to. @@ -290,10 +289,10 @@ For example, in `src/modes/Melee20Button.cpp`: ``` _socd_pair_count = 4; _socd_pairs = new socd::SocdPair[_socd_pair_count]{ - socd::SocdPair{&InputState::left, &InputState::right }, - socd::SocdPair{ &InputState::down, &InputState::up }, - socd::SocdPair{ &InputState::c_left, &InputState::c_right}, - socd::SocdPair{ &InputState::c_down, &InputState::c_up }, + socd::SocdPair{&InputState::left, &InputState::right, socd_type}, + socd::SocdPair{ &InputState::down, &InputState::up, socd_type}, + socd::SocdPair{ &InputState::c_left, &InputState::c_right, socd_type}, + socd::SocdPair{ &InputState::c_down, &InputState::c_up, socd_type}, }; ``` @@ -303,8 +302,22 @@ cleaning is automatically done before `UpdateDigitalOutputs()` and `UpdateAnalogOutputs()`, and you do not need to worry about it any further than that. -Note that you do not have to write a `HandleSocd()` function like in the -Melee20Button and Melee18Button modes. It is only overridden in these two modes +For each `SocdPair` you can pass in an `SocdType` of your choosing. By default +for most modes this is passed in as a single constructor parameter, but it is +possible to pass in multiple parameters, or simply use a hardcoded value. Both +of these approaches are exemplified in `src/modes/FgcMode.cpp`. + +| `SocdType` | Description | +| ---------- | ----------- | +| `SOCD_NEUTRAL` | Left + right = neutral - the default if no `SocdType` specified in the `SocdPair` | +| `SOCD_2IP` | Second input priority - left -> left + right = right, and vice versa. Releasing the second direction gives the original direction | +| `SOCD_2IP_NO_REAC` | Second input priority without reactivation - same as above, except releasing the second direction results in neutral. The original direction must be physically reactuated. | +| `SOCD_DIR1_PRIORITY` | The first button in the `SocdPair` always takes priority over the second | +| `SOCD_DIR2_PRIORITY` | The second button in the `SocdPair` always takes priority over the first | +| `SOCD_NONE` | No SOCD resolution - the game decides | + +Note that you do not have to implement a `HandleSocd()` function like in the +Melee20Button and Melee18Button modes. It is only overridden in these modes so that we can check if left and right are both held *before* SOCD cleaning, because when they are both held (without a vertical direction being held) we need to override all modifiers. diff --git a/config/mode_selection.hpp b/config/mode_selection.hpp index c28daa70..181b7fec 100644 --- a/config/mode_selection.hpp +++ b/config/mode_selection.hpp @@ -49,7 +49,7 @@ void select_mode(CommunicationBackend *backend) { } else if (inputs.down) { set_mode(backend, new Ultimate(socd::SOCD_2IP)); } else if (inputs.right) { - set_mode(backend, new FgcMode(socd::SOCD_NEUTRAL)); + set_mode(backend, new FgcMode(socd::SOCD_NEUTRAL, socd::SOCD_NEUTRAL)); } else if (inputs.b) { set_mode(backend, new RivalsOfAether(socd::SOCD_2IP)); } diff --git a/include/core/ControllerMode.hpp b/include/core/ControllerMode.hpp index b70df9e3..05b776b0 100644 --- a/include/core/ControllerMode.hpp +++ b/include/core/ControllerMode.hpp @@ -7,7 +7,7 @@ class ControllerMode : public InputMode { public: - ControllerMode(socd::SocdType socd_type); + ControllerMode(); void UpdateOutputs(InputState &inputs, OutputState &outputs); void ResetDirections(); virtual void UpdateDirections( diff --git a/include/core/InputMode.hpp b/include/core/InputMode.hpp index de60bf8c..2be670c2 100644 --- a/include/core/InputMode.hpp +++ b/include/core/InputMode.hpp @@ -6,15 +6,12 @@ class InputMode { public: - InputMode(socd::SocdType socd_type); + InputMode(); virtual ~InputMode(); protected: socd::SocdPair *_socd_pairs = nullptr; size_t _socd_pair_count = 0; - /* Exposed to child classes so that game modes are able to have different behaviour depending on - * SOCD cleaning mode. */ - socd::SocdType _socd_type; virtual void HandleSocd(InputState &inputs); diff --git a/include/core/socd.hpp b/include/core/socd.hpp index bef20694..78b6bddd 100644 --- a/include/core/socd.hpp +++ b/include/core/socd.hpp @@ -5,17 +5,19 @@ #include "stdlib.hpp" namespace socd { - typedef enum { SOCD_NEUTRAL, SOCD_2IP, SOCD_2IP_NO_REAC, - SOCD_KEYBOARD, + SOCD_DIR1_PRIORITY, + SOCD_DIR2_PRIORITY, + SOCD_NONE, } SocdType; typedef struct { bool InputState::*input_dir1; bool InputState::*input_dir2; + SocdType socd_type = SOCD_NEUTRAL; } SocdPair; typedef struct { @@ -25,12 +27,17 @@ namespace socd { bool lock_dir2 = false; } SocdState; - void twoIPNoReactivate(bool &input_dir1, bool &input_dir2, SocdState &socd_state); + void second_input_priority_no_reactivation( + bool &input_dir1, + bool &input_dir2, + SocdState &socd_state + ); - void twoIP(bool &input_dir1, bool &input_dir2, SocdState &socd_state); + void second_input_priority(bool &input_dir1, bool &input_dir2, SocdState &socd_state); void neutral(bool &input_dir1, bool &input_dir2); + void dir1_priority(bool &input_dir1, bool &input_dir2); } #endif diff --git a/include/modes/FgcMode.hpp b/include/modes/FgcMode.hpp index 1982b066..bc838827 100644 --- a/include/modes/FgcMode.hpp +++ b/include/modes/FgcMode.hpp @@ -7,10 +7,9 @@ class FgcMode : public ControllerMode { public: - FgcMode(socd::SocdType socd_type); + FgcMode(socd::SocdType horizontal_socd, socd::SocdType vertical_socd); private: - void HandleSocd(InputState &inputs); void UpdateDigitalOutputs(InputState &inputs, OutputState &outputs); void UpdateAnalogOutputs(InputState &inputs, OutputState &outputs); }; diff --git a/src/core/ControllerMode.cpp b/src/core/ControllerMode.cpp index f3380a63..af203165 100644 --- a/src/core/ControllerMode.cpp +++ b/src/core/ControllerMode.cpp @@ -1,6 +1,6 @@ #include "core/ControllerMode.hpp" -ControllerMode::ControllerMode(socd::SocdType socd_type) : InputMode(socd_type) { +ControllerMode::ControllerMode() { // Set up initial state. ResetDirections(); } diff --git a/src/core/InputMode.cpp b/src/core/InputMode.cpp index b67d35a8..56afd594 100644 --- a/src/core/InputMode.cpp +++ b/src/core/InputMode.cpp @@ -3,9 +3,7 @@ #include "core/socd.hpp" #include "core/state.hpp" -InputMode::InputMode(socd::SocdType socd_type) { - _socd_type = socd_type; -} +InputMode::InputMode() {} InputMode::~InputMode() { delete[] _socd_pairs; @@ -25,21 +23,31 @@ void InputMode::HandleSocd(InputState &inputs) { // Handle SOCD resolution for each SOCD button pair. for (size_t i = 0; i < _socd_pair_count; i++) { socd::SocdPair pair = _socd_pairs[i]; - switch (_socd_type) { + switch (pair.socd_type) { case socd::SOCD_NEUTRAL: socd::neutral(inputs.*(pair.input_dir1), inputs.*(pair.input_dir2)); break; case socd::SOCD_2IP: - socd::twoIP(inputs.*(pair.input_dir1), inputs.*(pair.input_dir2), _socd_states[i]); + socd::second_input_priority( + inputs.*(pair.input_dir1), + inputs.*(pair.input_dir2), + _socd_states[i] + ); break; case socd::SOCD_2IP_NO_REAC: - socd::twoIPNoReactivate( + socd::second_input_priority_no_reactivation( inputs.*(pair.input_dir1), inputs.*(pair.input_dir2), _socd_states[i] ); break; - case socd::SOCD_KEYBOARD: + case socd::SOCD_DIR1_PRIORITY: + socd::dir1_priority(inputs.*(pair.input_dir1), inputs.*(pair.input_dir2)); + break; + case socd::SOCD_DIR2_PRIORITY: + socd::dir1_priority(inputs.*(pair.input_dir2), inputs.*(pair.input_dir1)); + break; + case socd::SOCD_NONE: break; } } diff --git a/src/core/socd.cpp b/src/core/socd.cpp index f3bfc39d..504f3500 100644 --- a/src/core/socd.cpp +++ b/src/core/socd.cpp @@ -1,6 +1,10 @@ #include "core/socd.hpp" -void socd::twoIPNoReactivate(bool &input_dir1, bool &input_dir2, SocdState &socd_state) { +void socd::second_input_priority_no_reactivation( + bool &input_dir1, + bool &input_dir2, + SocdState &socd_state +) { bool is_dir1 = false; bool is_dir2 = false; if (input_dir1 && input_dir2) { @@ -39,7 +43,7 @@ void socd::twoIPNoReactivate(bool &input_dir1, bool &input_dir2, SocdState &socd input_dir2 = is_dir2; } -void socd::twoIP(bool &input_dir1, bool &input_dir2, SocdState &socd_state) { +void socd::second_input_priority(bool &input_dir1, bool &input_dir2, SocdState &socd_state) { bool is_dir1 = false; bool is_dir2 = false; if (input_dir1 && socd_state.was_dir2) { @@ -67,16 +71,14 @@ void socd::twoIP(bool &input_dir1, bool &input_dir2, SocdState &socd_state) { } void socd::neutral(bool &input_dir1, bool &input_dir2) { - bool is_dir1 = false; - bool is_dir2 = false; - if (!input_dir1 && input_dir2) { - is_dir1 = false; - is_dir2 = true; + if (input_dir1 && input_dir2) { + input_dir1 = false; + input_dir2 = false; } - if (input_dir1 && !input_dir2) { - is_dir1 = true; - is_dir2 = false; +} + +void socd::dir1_priority(bool &input_dir1, bool &input_dir2) { + if (input_dir1 && input_dir2) { + input_dir2 = false; } - input_dir1 = is_dir1; - input_dir2 = is_dir2; } diff --git a/src/modes/DefaultKeyboardMode.cpp b/src/modes/DefaultKeyboardMode.cpp index 7f64e64a..33960778 100644 --- a/src/modes/DefaultKeyboardMode.cpp +++ b/src/modes/DefaultKeyboardMode.cpp @@ -3,7 +3,7 @@ #include "core/socd.hpp" #include "core/state.hpp" -DefaultKeyboardMode::DefaultKeyboardMode(socd::SocdType socd_type) : KeyboardMode(socd_type) {} +DefaultKeyboardMode::DefaultKeyboardMode(socd::SocdType socd_type) {} void DefaultKeyboardMode::UpdateKeys(InputState &inputs) { Press(HID_KEY_A, inputs.l); diff --git a/src/modes/FgcMode.cpp b/src/modes/FgcMode.cpp index 9385e55e..4928a89e 100644 --- a/src/modes/FgcMode.cpp +++ b/src/modes/FgcMode.cpp @@ -1,19 +1,19 @@ #include "modes/FgcMode.hpp" -FgcMode::FgcMode(socd::SocdType socd_type) : ControllerMode(socd_type) { - _socd_pair_count = 1; +FgcMode::FgcMode(socd::SocdType horizontal_socd, socd::SocdType vertical_socd) { + _socd_pair_count = 4; _socd_pairs = new socd::SocdPair[_socd_pair_count]{ - socd::SocdPair{&InputState::left, &InputState::right}, + socd::SocdPair{&InputState::left, &InputState::right, horizontal_socd }, + /* Mod X override C-Up input if both are pressed. Without this, neutral SOCD doesn't work + properly if Down and both Up buttons are pressed, because it first resolves Down + Mod X + to set both as unpressed, and then it sees C-Up as pressed but not Down, so you get an up + input instead of neutral. */ + socd::SocdPair{ &InputState::mod_x, &InputState::c_up, socd::SOCD_DIR1_PRIORITY}, + socd::SocdPair{ &InputState::down, &InputState::mod_x, vertical_socd }, + socd::SocdPair{ &InputState::down, &InputState::c_up, vertical_socd }, }; } -void FgcMode::HandleSocd(InputState &inputs) { - if (inputs.down && (inputs.mod_x || inputs.c_up)) { - inputs.down = false; - } - InputMode::HandleSocd(inputs); -} - void FgcMode::UpdateDigitalOutputs(InputState &inputs, OutputState &outputs) { // Directions outputs.dpadLeft = inputs.left; diff --git a/src/modes/Melee18Button.cpp b/src/modes/Melee18Button.cpp index 26375f4b..d9ac9f60 100644 --- a/src/modes/Melee18Button.cpp +++ b/src/modes/Melee18Button.cpp @@ -4,14 +4,13 @@ #define ANALOG_STICK_NEUTRAL 128 #define ANALOG_STICK_MAX 208 -Melee18Button::Melee18Button(socd::SocdType socd_type, Melee18ButtonOptions options) - : ControllerMode(socd_type) { +Melee18Button::Melee18Button(socd::SocdType socd_type, Melee18ButtonOptions options) { _socd_pair_count = 4; _socd_pairs = new socd::SocdPair[_socd_pair_count]{ - socd::SocdPair{&InputState::left, &InputState::right }, - socd::SocdPair{ &InputState::down, &InputState::up }, - socd::SocdPair{ &InputState::c_left, &InputState::c_right}, - socd::SocdPair{ &InputState::c_down, &InputState::c_up }, + socd::SocdPair{&InputState::left, &InputState::right, socd_type}, + socd::SocdPair{ &InputState::down, &InputState::up, socd_type}, + socd::SocdPair{ &InputState::c_left, &InputState::c_right, socd_type}, + socd::SocdPair{ &InputState::c_down, &InputState::c_up, socd_type}, }; _options = options; diff --git a/src/modes/Melee20Button.cpp b/src/modes/Melee20Button.cpp index aab92a10..cfb47075 100644 --- a/src/modes/Melee20Button.cpp +++ b/src/modes/Melee20Button.cpp @@ -4,14 +4,13 @@ #define ANALOG_STICK_NEUTRAL 128 #define ANALOG_STICK_MAX 208 -Melee20Button::Melee20Button(socd::SocdType socd_type, Melee20ButtonOptions options) - : ControllerMode(socd_type) { +Melee20Button::Melee20Button(socd::SocdType socd_type, Melee20ButtonOptions options) { _socd_pair_count = 4; _socd_pairs = new socd::SocdPair[_socd_pair_count]{ - socd::SocdPair{&InputState::left, &InputState::right }, - socd::SocdPair{ &InputState::down, &InputState::up }, - socd::SocdPair{ &InputState::c_left, &InputState::c_right}, - socd::SocdPair{ &InputState::c_down, &InputState::c_up }, + socd::SocdPair{&InputState::left, &InputState::right, socd_type}, + socd::SocdPair{ &InputState::down, &InputState::up, socd_type}, + socd::SocdPair{ &InputState::c_left, &InputState::c_right, socd_type}, + socd::SocdPair{ &InputState::c_down, &InputState::c_up, socd_type}, }; _options = options; diff --git a/src/modes/ProjectM.cpp b/src/modes/ProjectM.cpp index a1851577..704ea041 100644 --- a/src/modes/ProjectM.cpp +++ b/src/modes/ProjectM.cpp @@ -4,13 +4,13 @@ #define ANALOG_STICK_NEUTRAL 128 #define ANALOG_STICK_MAX 228 -ProjectM::ProjectM(socd::SocdType socd_type, ProjectMOptions options) : ControllerMode(socd_type) { +ProjectM::ProjectM(socd::SocdType socd_type, ProjectMOptions options) { _socd_pair_count = 4; _socd_pairs = new socd::SocdPair[_socd_pair_count]{ - socd::SocdPair{&InputState::left, &InputState::right }, - socd::SocdPair{ &InputState::down, &InputState::up }, - socd::SocdPair{ &InputState::c_left, &InputState::c_right}, - socd::SocdPair{ &InputState::c_down, &InputState::c_up }, + socd::SocdPair{&InputState::left, &InputState::right, socd_type}, + socd::SocdPair{ &InputState::down, &InputState::up, socd_type}, + socd::SocdPair{ &InputState::c_left, &InputState::c_right, socd_type}, + socd::SocdPair{ &InputState::c_down, &InputState::c_up, socd_type}, }; _options = options; diff --git a/src/modes/RivalsOfAether.cpp b/src/modes/RivalsOfAether.cpp index f5352dab..b43aed8b 100644 --- a/src/modes/RivalsOfAether.cpp +++ b/src/modes/RivalsOfAether.cpp @@ -4,13 +4,13 @@ #define ANALOG_STICK_NEUTRAL 128 #define ANALOG_STICK_MAX 228 -RivalsOfAether::RivalsOfAether(socd::SocdType socd_type) : ControllerMode(socd_type) { +RivalsOfAether::RivalsOfAether(socd::SocdType socd_type) { _socd_pair_count = 4; _socd_pairs = new socd::SocdPair[_socd_pair_count]{ - socd::SocdPair{&InputState::left, &InputState::right }, - socd::SocdPair{ &InputState::down, &InputState::up }, - socd::SocdPair{ &InputState::c_left, &InputState::c_right}, - socd::SocdPair{ &InputState::c_down, &InputState::c_up }, + socd::SocdPair{&InputState::left, &InputState::right, socd_type}, + socd::SocdPair{ &InputState::down, &InputState::up, socd_type}, + socd::SocdPair{ &InputState::c_left, &InputState::c_right, socd_type}, + socd::SocdPair{ &InputState::c_down, &InputState::c_up, socd_type}, }; } diff --git a/src/modes/Ultimate.cpp b/src/modes/Ultimate.cpp index d46c187e..c23289ad 100644 --- a/src/modes/Ultimate.cpp +++ b/src/modes/Ultimate.cpp @@ -5,13 +5,13 @@ #define ANALOG_STICK_NEUTRAL 128 #define ANALOG_STICK_MAX 228 -Ultimate::Ultimate(socd::SocdType socd_type) : ControllerMode(socd_type) { +Ultimate::Ultimate(socd::SocdType socd_type) { _socd_pair_count = 4; _socd_pairs = new socd::SocdPair[_socd_pair_count]{ - socd::SocdPair{&InputState::left, &InputState::right }, - socd::SocdPair{ &InputState::down, &InputState::up }, - socd::SocdPair{ &InputState::c_left, &InputState::c_right}, - socd::SocdPair{ &InputState::c_down, &InputState::c_up }, + socd::SocdPair{&InputState::left, &InputState::right, socd_type}, + socd::SocdPair{ &InputState::down, &InputState::up, socd_type}, + socd::SocdPair{ &InputState::c_left, &InputState::c_right, socd_type}, + socd::SocdPair{ &InputState::c_down, &InputState::c_up, socd_type}, }; } diff --git a/src/modes/extra/DarkSouls.cpp b/src/modes/extra/DarkSouls.cpp index 814b397a..3e432120 100644 --- a/src/modes/extra/DarkSouls.cpp +++ b/src/modes/extra/DarkSouls.cpp @@ -4,13 +4,13 @@ #define ANALOG_STICK_NEUTRAL 128 #define ANALOG_STICK_MAX 255 -DarkSouls::DarkSouls(socd::SocdType socd_type) : ControllerMode(socd_type) { +DarkSouls::DarkSouls(socd::SocdType socd_type) { _socd_pair_count = 4; _socd_pairs = new socd::SocdPair[_socd_pair_count]{ - socd::SocdPair{&InputState::left, &InputState::right }, - socd::SocdPair{ &InputState::down, &InputState::mod_x }, - socd::SocdPair{ &InputState::c_left, &InputState::c_right}, - socd::SocdPair{ &InputState::c_down, &InputState::c_up }, + socd::SocdPair{&InputState::left, &InputState::right, socd_type}, + socd::SocdPair{ &InputState::down, &InputState::mod_x, socd_type}, + socd::SocdPair{ &InputState::c_left, &InputState::c_right, socd_type}, + socd::SocdPair{ &InputState::c_down, &InputState::c_up, socd_type}, }; } diff --git a/src/modes/extra/HollowKnight.cpp b/src/modes/extra/HollowKnight.cpp index cfa2c351..5cd66e83 100644 --- a/src/modes/extra/HollowKnight.cpp +++ b/src/modes/extra/HollowKnight.cpp @@ -4,13 +4,13 @@ #define ANALOG_STICK_NEUTRAL 128 #define ANALOG_STICK_MAX 255 -HollowKnight::HollowKnight(socd::SocdType socd_type) : ControllerMode(socd_type) { +HollowKnight::HollowKnight(socd::SocdType socd_type) { _socd_pair_count = 4; _socd_pairs = new socd::SocdPair[_socd_pair_count]{ - socd::SocdPair{&InputState::left, &InputState::right }, - socd::SocdPair{ &InputState::down, &InputState::mod_x }, - socd::SocdPair{ &InputState::c_left, &InputState::c_right}, - socd::SocdPair{ &InputState::c_down, &InputState::c_up }, + socd::SocdPair{&InputState::left, &InputState::right, socd_type}, + socd::SocdPair{ &InputState::down, &InputState::mod_x, socd_type}, + socd::SocdPair{ &InputState::c_left, &InputState::c_right, socd_type}, + socd::SocdPair{ &InputState::c_down, &InputState::c_up, socd_type}, }; } diff --git a/src/modes/extra/MKWii.cpp b/src/modes/extra/MKWii.cpp index 52925f54..8bef561a 100644 --- a/src/modes/extra/MKWii.cpp +++ b/src/modes/extra/MKWii.cpp @@ -4,13 +4,13 @@ #define ANALOG_STICK_NEUTRAL 128 #define ANALOG_STICK_MAX 255 -MKWii::MKWii(socd::SocdType socd_type) : ControllerMode(socd_type) { +MKWii::MKWii(socd::SocdType socd_type) { _socd_pair_count = 4; _socd_pairs = new socd::SocdPair[_socd_pair_count]{ - socd::SocdPair{&InputState::left, &InputState::right}, - socd::SocdPair{ &InputState::l, &InputState::down }, - socd::SocdPair{ &InputState::l, &InputState::mod_x}, - socd::SocdPair{ &InputState::l, &InputState::mod_y}, + socd::SocdPair{&InputState::left, &InputState::right, socd_type}, + socd::SocdPair{ &InputState::l, &InputState::down, socd_type}, + socd::SocdPair{ &InputState::l, &InputState::mod_x, socd_type}, + socd::SocdPair{ &InputState::l, &InputState::mod_y, socd_type}, }; } diff --git a/src/modes/extra/MultiVersus.cpp b/src/modes/extra/MultiVersus.cpp index c3bc2b04..83ffe989 100644 --- a/src/modes/extra/MultiVersus.cpp +++ b/src/modes/extra/MultiVersus.cpp @@ -4,13 +4,13 @@ #define ANALOG_STICK_NEUTRAL 128 #define ANALOG_STICK_MAX 255 -MultiVersus::MultiVersus(socd::SocdType socd_type) : ControllerMode(socd_type) { +MultiVersus::MultiVersus(socd::SocdType socd_type) { _socd_pair_count = 4; _socd_pairs = new socd::SocdPair[_socd_pair_count]{ - socd::SocdPair{&InputState::left, &InputState::right }, - socd::SocdPair{ &InputState::down, &InputState::up }, - socd::SocdPair{ &InputState::c_left, &InputState::c_right}, - socd::SocdPair{ &InputState::c_down, &InputState::c_up }, + socd::SocdPair{&InputState::left, &InputState::right, socd_type}, + socd::SocdPair{ &InputState::down, &InputState::up, socd_type}, + socd::SocdPair{ &InputState::c_left, &InputState::c_right, socd_type}, + socd::SocdPair{ &InputState::c_down, &InputState::c_up, socd_type}, }; } diff --git a/src/modes/extra/RocketLeague.cpp b/src/modes/extra/RocketLeague.cpp index 3c7612cb..e10299ec 100644 --- a/src/modes/extra/RocketLeague.cpp +++ b/src/modes/extra/RocketLeague.cpp @@ -4,22 +4,16 @@ #define ANALOG_STICK_NEUTRAL 128 #define ANALOG_STICK_MAX 255 -RocketLeague::RocketLeague(socd::SocdType socd_type) : ControllerMode(socd_type) { - _socd_pair_count = 3; +RocketLeague::RocketLeague(socd::SocdType socd_type) { + _socd_pair_count = 4; _socd_pairs = new socd::SocdPair[_socd_pair_count]{ - socd::SocdPair{&InputState::left, &InputState::right }, - socd::SocdPair{ &InputState::c_left, &InputState::c_right}, - socd::SocdPair{ &InputState::c_down, &InputState::c_up }, + socd::SocdPair{&InputState::left, &InputState::right, socd_type }, + socd::SocdPair{ &InputState::down, &InputState::mod_x, socd::SOCD_DIR2_PRIORITY}, + socd::SocdPair{ &InputState::c_left, &InputState::c_right, socd_type }, + socd::SocdPair{ &InputState::c_down, &InputState::c_up, socd_type }, }; } -void RocketLeague::HandleSocd(InputState &inputs) { - if (inputs.mod_x && inputs.down) { - inputs.down = false; - } - InputMode::HandleSocd(inputs); -} - void RocketLeague::UpdateDigitalOutputs(InputState &inputs, OutputState &outputs) { outputs.a = inputs.a; outputs.b = inputs.b; diff --git a/src/modes/extra/SaltAndSanctuary.cpp b/src/modes/extra/SaltAndSanctuary.cpp index c7dc7e48..d1581817 100644 --- a/src/modes/extra/SaltAndSanctuary.cpp +++ b/src/modes/extra/SaltAndSanctuary.cpp @@ -4,13 +4,13 @@ #define ANALOG_STICK_NEUTRAL 128 #define ANALOG_STICK_MAX 255 -SaltAndSanctuary::SaltAndSanctuary(socd::SocdType socd_type) : ControllerMode(socd_type) { +SaltAndSanctuary::SaltAndSanctuary(socd::SocdType socd_type) { _socd_pair_count = 4; _socd_pairs = new socd::SocdPair[_socd_pair_count]{ - socd::SocdPair{&InputState::left, &InputState::right }, - socd::SocdPair{ &InputState::down, &InputState::mod_x }, - socd::SocdPair{ &InputState::c_left, &InputState::c_right}, - socd::SocdPair{ &InputState::c_down, &InputState::c_up }, + socd::SocdPair{&InputState::left, &InputState::right, socd_type}, + socd::SocdPair{ &InputState::down, &InputState::mod_x, socd_type}, + socd::SocdPair{ &InputState::c_left, &InputState::c_right, socd_type}, + socd::SocdPair{ &InputState::c_down, &InputState::c_up, socd_type}, }; } diff --git a/src/modes/extra/ShovelKnight.cpp b/src/modes/extra/ShovelKnight.cpp index 60be679d..e956a7bf 100644 --- a/src/modes/extra/ShovelKnight.cpp +++ b/src/modes/extra/ShovelKnight.cpp @@ -4,13 +4,13 @@ #define ANALOG_STICK_NEUTRAL 128 #define ANALOG_STICK_MAX 255 -ShovelKnight::ShovelKnight(socd::SocdType socd_type) : ControllerMode(socd_type) { +ShovelKnight::ShovelKnight(socd::SocdType socd_type) { _socd_pair_count = 4; _socd_pairs = new socd::SocdPair[_socd_pair_count]{ - socd::SocdPair{&InputState::left, &InputState::right }, - socd::SocdPair{ &InputState::down, &InputState::mod_x }, - socd::SocdPair{ &InputState::c_left, &InputState::c_right}, - socd::SocdPair{ &InputState::c_down, &InputState::c_up }, + socd::SocdPair{&InputState::left, &InputState::right, socd_type}, + socd::SocdPair{ &InputState::down, &InputState::mod_x, socd_type}, + socd::SocdPair{ &InputState::c_left, &InputState::c_right, socd_type}, + socd::SocdPair{ &InputState::c_down, &InputState::c_up, socd_type}, }; } diff --git a/src/modes/extra/ToughLoveArena.cpp b/src/modes/extra/ToughLoveArena.cpp index 22b557fc..e1d765d3 100644 --- a/src/modes/extra/ToughLoveArena.cpp +++ b/src/modes/extra/ToughLoveArena.cpp @@ -1,9 +1,9 @@ #include "modes/extra/ToughLoveArena.hpp" -ToughLoveArena::ToughLoveArena(socd::SocdType socd_type) : KeyboardMode(socd_type) { +ToughLoveArena::ToughLoveArena(socd::SocdType socd_type) { _socd_pair_count = 1; _socd_pairs = new socd::SocdPair[_socd_pair_count]{ - socd::SocdPair{&InputState::left, &InputState::right}, + socd::SocdPair{&InputState::left, &InputState::right, socd_type}, }; } diff --git a/src/modes/extra/Ultimate2.cpp b/src/modes/extra/Ultimate2.cpp index eb769c8c..666dd94c 100644 --- a/src/modes/extra/Ultimate2.cpp +++ b/src/modes/extra/Ultimate2.cpp @@ -5,13 +5,13 @@ #define ANALOG_STICK_NEUTRAL 128 #define ANALOG_STICK_MAX 228 -Ultimate2::Ultimate2(socd::SocdType socd_type) : ControllerMode(socd_type) { +Ultimate2::Ultimate2(socd::SocdType socd_type) { _socd_pair_count = 4; _socd_pairs = new socd::SocdPair[_socd_pair_count]{ - socd::SocdPair{&InputState::left, &InputState::right }, - socd::SocdPair{ &InputState::down, &InputState::up }, - socd::SocdPair{ &InputState::c_left, &InputState::c_right}, - socd::SocdPair{ &InputState::c_down, &InputState::c_up }, + socd::SocdPair{&InputState::left, &InputState::right, socd_type}, + socd::SocdPair{ &InputState::down, &InputState::up, socd_type}, + socd::SocdPair{ &InputState::c_left, &InputState::c_right, socd_type}, + socd::SocdPair{ &InputState::c_down, &InputState::c_up, socd_type}, }; }