fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
818d962
gram
1#include "modes/ProjectM.hpp" 2 3#define ANALOG_STICK_MIN 28 4#define ANALOG_STICK_NEUTRAL 128 5#define ANALOG_STICK_MAX 228 6 7ProjectM ::ProjectM () :ControllerMode () { 8_horizontal_socd = false; 9} 10 11void ProjectM ::SetConfig (GameModeConfig & config ,const ProjectMOptions options ) { 12InputMode ::SetConfig (config ); 13_options = options ; 14} 15 16void ProjectM ::HandleSocd (InputState & inputs ) { 17_horizontal_socd = inputs .lf3 && inputs .lf1 ; 18InputMode ::HandleSocd (inputs ); 19} 20 21void ProjectM ::UpdateDigitalOutputs (const InputState & inputs ,OutputState & outputs ) { 22outputs .a = inputs .rt1 ; 23outputs .b = inputs .rf1 ; 24outputs .x = inputs .rf2 ; 25outputs .y = inputs .rf6 ; 26// True Z press vs macro lightshield + A. 27if (_options .true_z_press || inputs .lt1 ) { 28outputs .buttonR = inputs .rf3 ; 29 }else { 30outputs .a = inputs .rt1 || inputs .rf3 ; 31 } 32if (inputs .nunchuk_connected ) { 33outputs .triggerLDigital = inputs .nunchuk_z ; 34 }else { 35outputs .triggerLDigital = inputs .lf4 ; 36 } 37outputs .triggerRDigital = inputs .rf5 ; 38outputs .start = inputs .mb1 ; 39 40// Activate D-Pad layer by holding Mod X + Mod Y or Nunchuk C button. 41if ((inputs .lt1 && inputs .lt2 )|| inputs .nunchuk_c ) { 42outputs .dpadUp = inputs .rt4 ; 43outputs .dpadDown = inputs .rt2 ; 44outputs .dpadLeft = inputs .rt3 ; 45outputs .dpadRight = inputs .rt5 ; 46 } 47 48// Don't override dpad up if it's already pressed using the MX + MY dpad 49// layer. 50outputs .dpadUp = outputs .dpadUp || inputs .rf8 ; 51 52if (inputs .mb3 ) 53outputs .dpadLeft = true; 54if (inputs .mb2 ) 55outputs .dpadRight = true; 56} 57 58void ProjectM ::UpdateAnalogOutputs (const InputState & inputs ,OutputState & outputs ) { 59UpdateDirections ( 60inputs .lf3 ,// Left 61inputs .lf1 ,// Right 62inputs .lf2 ,// Down 63inputs .rf4 ,// Up 64inputs .rt3 ,// C-Left 65inputs .rt5 ,// C-Right 66inputs .rt2 ,// C-Down 67inputs .rt4 ,// C-Up 68ANALOG_STICK_MIN , 69ANALOG_STICK_NEUTRAL , 70ANALOG_STICK_MAX , 71outputs 72 ); 73 74bool shield_button_pressed = inputs .lf4 || inputs .rf7 ; 75 76if (directions .diagonal ) { 77if (directions .y == 1 ) { 78outputs .leftStickX = 128 + (directions .x * 83 ); 79outputs .leftStickY = 128 + (directions .y * 93 ); 80 } 81 } 82 83/* Mod X */ 84if (inputs .lt1 ) { 85if (directions .horizontal ) { 86outputs .leftStickX = 128 + (directions .x * 70 ); 87 } 88if (directions .vertical ) { 89outputs .leftStickY = 128 + (directions .y * 60 ); 90 } 91 92if (directions .cx != 0 ) { 93outputs .rightStickX = 128 + (directions .cx * 65 ); 94outputs .rightStickY = 128 + (directions .y * 23 ); 95 } 96 97if (directions .diagonal ) { 98// Default MX Diagonal 99outputs .leftStickX = 128 + (directions .x * 70 ); 100outputs .leftStickY = 128 + (directions .y * 34 ); 101 102if (inputs .rf1 ) { 103outputs .leftStickX = 128 + (directions .x * 85 ); 104outputs .leftStickY = 128 + (directions .y * 31 ); 105 } 106 107// Airdodge angle 108if (inputs .rf5 ) { 109if (_options .has_custom_airdodge ) { 110outputs .leftStickX = 128 + (directions .x * _options .custom_airdodge .x ); 111outputs .leftStickY = 128 + (directions .y * _options .custom_airdodge .y ); 112 }else { 113outputs .leftStickX = 128 + (directions .x * 82 ); 114outputs .leftStickY = 128 + (directions .y * 35 ); 115 } 116 } 117 118if (inputs .rt4 ) { 119outputs .leftStickX = 128 + (directions .x * 77 ); 120outputs .leftStickY = 128 + (directions .y * 55 ); 121 } 122 123if (inputs .rt2 ) { 124outputs .leftStickX = 128 + (directions .x * 82 ); 125outputs .leftStickY = 128 + (directions .y * 36 ); 126 } 127 128if (inputs .rt3 ) { 129outputs .leftStickX = 128 + (directions .x * 84 ); 130outputs .leftStickY = 128 + (directions .y * 50 ); 131 } 132 133if (inputs .rt5 ) { 134outputs .leftStickX = 128 + (directions .x * 72 ); 135outputs .leftStickY = 128 + (directions .y * 61 ); 136 } 137 } 138 } 139 140/* Mod Y */ 141if (inputs .lt2 ) { 142if (directions .horizontal ) { 143outputs .leftStickX = 128 + (directions .x * 35 ); 144 } 145if (directions .vertical ) { 146outputs .leftStickY = 128 + (directions .y * 70 ); 147 } 148 149if (directions .diagonal ) { 150outputs .leftStickX = 128 + (directions .x * 28 ); 151outputs .leftStickY = 128 + (directions .y * 58 ); 152 153if (inputs .rf1 ) { 154outputs .leftStickX = 128 + (directions .x * 28 ); 155outputs .leftStickY = 128 + (directions .y * 85 ); 156 } 157 158if (inputs .rf5 ) { 159outputs .leftStickX = 128 + (directions .x * 51 ); 160outputs .leftStickY = 128 + (directions .y * 82 ); 161 } 162 163if (inputs .rt4 ) { 164outputs .leftStickX = 128 + (directions .x * 55 ); 165outputs .leftStickY = 128 + (directions .y * 77 ); 166 } 167 168if (inputs .rt2 ) { 169outputs .leftStickX = 128 + (directions .x * 34 ); 170outputs .leftStickY = 128 + (directions .y * 82 ); 171 } 172 173if (inputs .rt3 ) { 174outputs .leftStickX = 128 + (directions .x * 40 ); 175outputs .leftStickY = 128 + (directions .y * 84 ); 176 } 177 178if (inputs .rt5 ) { 179outputs .leftStickX = 128 + (directions .x * 62 ); 180outputs .leftStickY = 128 + (directions .y * 72 ); 181 } 182 } 183 } 184 185// C-stick ASDI Slideoff angle overrides any other C-stick modifiers (such as 186// angled fsmash). 187// We don't apply this for c-up + c-left/c-right in case we want to implement 188// C-stick nair somehow. 189if (directions .cx != 0 && directions .cy == -1 ) { 190// 3000 9875 = 30 78 191outputs .rightStickX = 128 + (directions .cx * 35 ); 192outputs .rightStickY = 128 + (directions .cy * 98 ); 193 } 194 195// Horizontal SOCD overrides X-axis modifiers (for ledgedash maximum jump 196// trajectory). 197if (!_options .disable_ledgedash_socd_override && _horizontal_socd && !directions .vertical && 198 !shield_button_pressed ) { 199outputs .leftStickX = 128 + (directions .x * 100 ); 200 } 201 202if (inputs .rf7 ) { 203outputs .triggerRAnalog = 49 ; 204 } 205 206// Send lightshield input if we are using Z = lightshield + A macro. 207if (inputs .rf3 && !(inputs .lt1 || _options .true_z_press )) { 208outputs .triggerRAnalog = 49 ; 209 } 210 211if (outputs .triggerLDigital ) { 212outputs .triggerLAnalog = 140 ; 213 } 214 215if (outputs .triggerRDigital ) { 216outputs .triggerRAnalog = 140 ; 217 } 218 219// Shut off C-stick when using D-Pad layer. 220if ((inputs .lt1 && inputs .lt2 )|| inputs .nunchuk_c ) { 221outputs .rightStickX = 128 ; 222outputs .rightStickY = 128 ; 223 } 224 225// Nunchuk overrides left stick. 226if (inputs .nunchuk_connected ) { 227outputs .leftStickX = inputs .nunchuk_x ; 228outputs .leftStickY = inputs .nunchuk_y ; 229 } 230}