fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
1f92ae6
WASD_NeutralSOCD
1#include "modes/extra/MultiVersus.hpp" 2 3#define ANALOG_STICK_MIN 0 4#define ANALOG_STICK_NEUTRAL 128 5#define ANALOG_STICK_MAX 255 6 7MultiVersus ::MultiVersus (socd::SocdType socd_type ) { 8_socd_pair_count = 4 ; 9_socd_pairs = new socd::SocdPair [_socd_pair_count ]{ 10 socd::SocdPair {& InputState ::left ,& InputState ::right ,socd_type }, 11 socd::SocdPair {& InputState ::down ,& InputState ::up ,socd_type }, 12 socd::SocdPair {& InputState ::c_left ,& InputState ::c_right ,socd_type }, 13 socd::SocdPair {& InputState ::c_down ,& InputState ::c_up ,socd_type }, 14 }; 15} 16 17void MultiVersus ::UpdateDigitalOutputs (InputState & inputs ,OutputState & outputs ) { 18// Bind X and Y to "jump" in-game. 19outputs .x = inputs .x ; 20outputs .y = inputs .y ; 21 22outputs .start = !inputs .mod_y && inputs .start ; 23 24// Select, MS, or MY + Start for "Reset" in the Lab. Not supported by GameCube adapter. 25outputs .select = inputs .select || inputs .midshield || (inputs .mod_y && inputs .start ); 26 27// Home not supported by GameCube adapter. 28outputs .home = inputs .home ; 29 30// L or Nunchuk Z = LT. Bind to "dodge" in-game. 31if (inputs .nunchuk_connected ) { 32outputs .triggerLDigital = inputs .nunchuk_z ; 33 }else { 34outputs .triggerLDigital = inputs .l ; 35 } 36 37// R = RT. Can be bound to "pickup item" or left unbound. 38outputs .triggerRDigital = inputs .r ; 39 40if (!inputs .mod_x ) { 41// Bind A to "attack" in-game. 42outputs .a = inputs .a ; 43 44// Bind B to "special" in-game. 45outputs .b = inputs .b ; 46 47// Z = RB. Bind to "dodge" in-game. 48outputs .buttonR = inputs .z ; 49 50// LS = LB. Not supported by GameCube adapter. 51outputs .buttonL = inputs .lightshield ; 52 } 53 54// MX activates a layer for "neutral" binds. Uses D-Pad buttons. 55if (inputs .mod_x && !inputs .mod_y ) { 56// MX + A = D-Pad Left. Bind to "neutral attack" in-game. 57outputs .dpadLeft = inputs .a ; 58 59// MX + B = D-Pad Right. Bind to "neutral special" in-game. 60outputs .dpadRight = inputs .b ; 61 62// MX + Z = D-Pad Down. Bind to "neutral evade" in-game. 63outputs .dpadDown = inputs .z ; 64 65// MX + LS = D-Pad Up. Bind to "taunt 1" in-game. 66outputs .dpadUp = inputs .lightshield ; 67 } 68 69// MY activates C-Stick to D-Pad conversion. 70if (inputs .mod_y && !inputs .mod_x ) { 71outputs .dpadLeft = inputs .c_left ; 72outputs .dpadRight = inputs .c_right ; 73outputs .dpadDown = inputs .c_down ; 74outputs .dpadUp = inputs .c_up ; 75 } 76} 77 78void MultiVersus ::UpdateAnalogOutputs (InputState & inputs ,OutputState & outputs ) { 79// Coordinate calculations to make modifier handling simpler. 80UpdateDirections ( 81inputs .left , 82inputs .right , 83inputs .down , 84inputs .up , 85inputs .c_left , 86inputs .c_right , 87inputs .c_down , 88inputs .c_up , 89ANALOG_STICK_MIN , 90ANALOG_STICK_NEUTRAL , 91ANALOG_STICK_MAX , 92outputs 93 ); 94 95if (inputs .mod_y && !inputs .mod_x ) { 96// MY slows down the cursor for easier menu navigation. 97// Menu cursor speed can also be turned down in-game under "Interface" settings. 98// 128 ± 76 results in the slowest cursor that still actuates directional inputs in-game. 99outputs .leftStickX = ANALOG_STICK_NEUTRAL + directions .x * 76 ; 100outputs .leftStickY = ANALOG_STICK_NEUTRAL + directions .y * 76 ; 101 102if (directions .diagonal ) { 103// Maintain a consistent cursor velocity when MY is held. 104// ⌊76 × √2/2⌋ = 53 105outputs .leftStickX = ANALOG_STICK_NEUTRAL + directions .x * 53 ; 106outputs .leftStickY = ANALOG_STICK_NEUTRAL + directions .y * 53 ; 107 } 108 109// Also shut off C-Stick for D-Pad conversion. 110outputs .rightStickX = ANALOG_STICK_NEUTRAL ; 111outputs .rightStickY = ANALOG_STICK_NEUTRAL ; 112 } 113 114if (outputs .triggerLDigital ) { 115outputs .triggerLAnalog = 140 ; 116 } 117 118if (outputs .triggerRDigital ) { 119outputs .triggerRAnalog = 140 ; 120 } 121 122// Nunchuk overrides left stick. 123if (inputs .nunchuk_connected ) { 124outputs .leftStickX = inputs .nunchuk_x ; 125outputs .leftStickY = inputs .nunchuk_y ; 126 } 127}