fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
818d962
gram
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 () :ControllerMode () {} 8 9void MultiVersus ::UpdateDigitalOutputs (const InputState & inputs ,OutputState & outputs ) { 10// Bind X and Y to "jump" in-game. 11outputs .x = inputs .rf2 ; 12outputs .y = inputs .rf6 ; 13 14outputs .start = !inputs .lt2 && inputs .mb1 ; 15 16// Select, MS, or MY + Start for "Reset" in the Lab. Not supported by GameCube adapter. 17outputs .select = inputs .mb3 || inputs .rf8 || (inputs .lt2 && inputs .mb1 ); 18 19// Home not supported by GameCube adapter. 20outputs .home = inputs .mb2 ; 21 22// L or Nunchuk Z = LT. Bind to "dodge" in-game. 23if (inputs .nunchuk_connected ) { 24outputs .triggerLDigital = inputs .nunchuk_z ; 25 }else { 26outputs .triggerLDigital = inputs .lf4 ; 27 } 28 29// R = RT. Can be bound to "pickup item" or left unbound. 30outputs .triggerRDigital = inputs .rf5 ; 31 32if (!inputs .lt1 ) { 33// Bind A to "attack" in-game. 34outputs .a = inputs .rt1 ; 35 36// Bind B to "special" in-game. 37outputs .b = inputs .rf1 ; 38 39// Z = RB. Bind to "dodge" in-game. 40outputs .buttonR = inputs .rf3 ; 41 42// LS = LB. Not supported by GameCube adapter. 43outputs .buttonL = inputs .rf7 ; 44 } 45 46// MX activates a layer for "neutral" binds. Uses D-Pad buttons. 47if (inputs .lt1 && !inputs .lt2 ) { 48// MX + A = D-Pad Left. Bind to "neutral attack" in-game. 49outputs .dpadLeft = inputs .rt1 ; 50 51// MX + B = D-Pad Right. Bind to "neutral special" in-game. 52outputs .dpadRight = inputs .rf1 ; 53 54// MX + Z = D-Pad Down. Bind to "neutral evade" in-game. 55outputs .dpadDown = inputs .rf3 ; 56 57// MX + LS = D-Pad Up. Bind to "taunt 1" in-game. 58outputs .dpadUp = inputs .rf7 ; 59 } 60 61// MY activates C-Stick to D-Pad conversion. 62if (inputs .lt2 && !inputs .lt1 ) { 63outputs .dpadLeft = inputs .rt3 ; 64outputs .dpadRight = inputs .rt5 ; 65outputs .dpadDown = inputs .rt2 ; 66outputs .dpadUp = inputs .rt4 ; 67 } 68} 69 70void MultiVersus ::UpdateAnalogOutputs (const InputState & inputs ,OutputState & outputs ) { 71// Coordinate calculations to make modifier handling simpler. 72UpdateDirections ( 73inputs .lf3 ,// Left 74inputs .lf1 ,// Right 75inputs .lf2 ,// Down 76inputs .rf4 ,// Up 77inputs .rt3 ,// C-Left 78inputs .rt5 ,// C-Right 79inputs .rt2 ,// C-Down 80inputs .rt4 ,// C-Up 81ANALOG_STICK_MIN , 82ANALOG_STICK_NEUTRAL , 83ANALOG_STICK_MAX , 84outputs 85 ); 86 87if (inputs .lt2 && !inputs .lt1 ) { 88// MY slows down the cursor for easier menu navigation. 89// Menu cursor speed can also be turned down in-game under "Interface" settings. 90// 128 ± 76 results in the slowest cursor that still actuates directional inputs in-game. 91outputs .leftStickX = ANALOG_STICK_NEUTRAL + directions .x * 76 ; 92outputs .leftStickY = ANALOG_STICK_NEUTRAL + directions .y * 76 ; 93 94if (directions .diagonal ) { 95// Maintain a consistent cursor velocity when MY is held. 96// ⌊76 × √2/2⌋ = 53 97outputs .leftStickX = ANALOG_STICK_NEUTRAL + directions .x * 53 ; 98outputs .leftStickY = ANALOG_STICK_NEUTRAL + directions .y * 53 ; 99 } 100 101// Also shut off C-Stick for D-Pad conversion. 102outputs .rightStickX = ANALOG_STICK_NEUTRAL ; 103outputs .rightStickY = ANALOG_STICK_NEUTRAL ; 104 } 105 106if (outputs .triggerLDigital ) { 107outputs .triggerLAnalog = 140 ; 108 } 109 110if (outputs .triggerRDigital ) { 111outputs .triggerRAnalog = 140 ; 112 } 113 114// Nunchuk overrides left stick. 115if (inputs .nunchuk_connected ) { 116outputs .leftStickX = inputs .nunchuk_x ; 117outputs .leftStickY = inputs .nunchuk_y ; 118 } 119}