fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
dccae31
gram
1#include "modes/Melee20Button.hpp" 2 3//wider wavedash angle 4 5#define ANALOG_STICK_MIN (128-112) 6#define ANALOG_STICK_NEUTRAL 128 7#define ANALOG_STICK_MAX (128+112) 8 9Melee20Button ::Melee20Button () :ControllerMode () { 10} 11 12void Melee20Button ::SetConfig (GameModeConfig & config ,const MeleeOptions options ) { 13InputMode ::SetConfig (config ); 14_options = options ; 15} 16 17void Melee20Button ::HandleSocd (InputState & inputs ) { 18//force neutral socd 19if (inputs .lf3 && inputs .lf1 ) { 20inputs .lf3 = false; 21inputs .lf1 = false; 22 } 23if (inputs .lf2 && inputs .rf4 ) { 24inputs .lf2 = false; 25inputs .rf4 = false; 26 } 27if (inputs .rt3 && inputs .rt5 ) { 28inputs .rt3 = false; 29inputs .rt5 = false; 30 } 31if (inputs .rt2 && inputs .rt4 ) { 32inputs .rt2 = false; 33inputs .rt4 = false; 34 } 35InputMode ::HandleSocd (inputs ); 36} 37 38void Melee20Button ::UpdateDigitalOutputs (const InputState & inputs ,OutputState & outputs ) { 39outputs .a = inputs .rt1 ; 40outputs .b = inputs .rf1 ; 41outputs .x = inputs .rf2 ; 42outputs .y = inputs .rf6 ; 43outputs .buttonR = inputs .rf3 ; 44if (inputs .nunchuk_connected ) { 45outputs .triggerLDigital = inputs .nunchuk_z ; 46 }else { 47outputs .triggerLDigital = inputs .lf4 ; 48 } 49outputs .triggerRDigital = inputs .rf5 ; 50outputs .start = inputs .mb1 ; 51 52// Activate D-Pad layer by holding Mod X + Mod Y or Nunchuk C button. 53if ((inputs .lt1 && inputs .lt2 )|| inputs .nunchuk_c || inputs .lf6 ) { 54outputs .dpadUp = inputs .rt4 ; 55outputs .dpadDown = inputs .rt2 ; 56outputs .dpadLeft = inputs .rt3 ; 57outputs .dpadRight = inputs .rt5 ; 58 } 59 60if (inputs .mb3 ) 61outputs .dpadLeft = true; 62if (inputs .mb2 ) 63outputs .dpadRight = true; 64} 65 66void Melee20Button ::UpdateAnalogOutputs (const InputState & inputs ,OutputState & outputs ) { 67// Coordinate calculations to make modifier handling simpler. 68UpdateDirections ( 69inputs .lf3 ,// Left 70inputs .lf1 ,// Right 71inputs .lf2 ,// Down 72inputs .rf4 ,// Up 73inputs .rt3 ,// C-Left 74inputs .rt5 ,// C-Right 75inputs .rt2 ,// C-Down 76inputs .rt4 ,// C-Up 77ANALOG_STICK_MIN , 78ANALOG_STICK_NEUTRAL , 79ANALOG_STICK_MAX , 80outputs 81 ); 82 83const bool shield_button_pressed = inputs .lf4 || inputs .rf5 || inputs .rf7 || inputs .rf8 ; 84if (directions .diagonal ) { 85// q1/2 = 7000 7000 86outputs .leftStickX = 128 + (directions .x * 56 ); 87outputs .leftStickY = 128 + (directions .y * 61 ); 88// L, R, LS, and MS + q3/4 = 7000 6875 (For vanilla shield drop. Gives 44.5 89// degree wavedash). Also used as default q3/4 diagonal if crouch walk option select is 90// enabled. 91if (directions .y == -1 && (shield_button_pressed || _options .crouch_walk_os )) { 92outputs .leftStickX = 128 + (directions .x * 61 ); 93outputs .leftStickY = 128 + (directions .y * 56 ); 94 } 95 } 96 97/* Mod X */ 98if (inputs .lt1 ) { 99// MX + Horizontal (even if shield is held) = 6625 = 53 100if (directions .horizontal ) { 101outputs .leftStickX = 128 + (directions .x * 53 ); 102 } 103// MX + Vertical (even if shield is held) = 5375 = 43 104// y=-0.5500 (44) is solo nana ice block, so we reduce this by one 105// MX + Vertical (even if shield is held) = 5250 = 42 106if (directions .vertical ) { 107outputs .leftStickY = 128 + (directions .y * 42 ); 108 } 109if (directions .diagonal && shield_button_pressed ) { 110// Use custom airdodge angle if set, otherwise B0XX standard default. 111if (_options .has_custom_airdodge ) { 112outputs .leftStickX = 128 + (directions .x * _options .custom_airdodge .x ); 113outputs .leftStickY = 128 + (directions .y * _options .custom_airdodge .y ); 114 }else { 115if (!inputs .rf1 ) { 116// MX + L, R, LS, and MS + q1/2/3/4 = 117// 6375 3750 - 24.84 deg - 54 25 (will be overridden for LR digital) 118outputs .leftStickX = 128 + (directions .x * 54 ); 119outputs .leftStickY = 128 + (directions .y * 25 ); 120 }else { 121// Extended angle to have magnitude similarity for DI 122// 9000 4250 - 25.28 deg - 72 34 (will be overridden for LR digital but remain rim) 123outputs .leftStickX = 128 + (directions .x * 72 ); 124outputs .leftStickY = 128 + (directions .y * 34 ); 125 } 126 } 127 } 128 129/* Up B angles */ 130if (directions .diagonal && !shield_button_pressed ) { 131if (!inputs .rf1 ) { 132// 7250 3125 - 23.32deg - 58 25 - modX 133// 7000 3625 - 27.38deg - 56 29 - modX + cDown 134// 6625 4125 - 31.91deg - 53 33 - modX + cLeft 135// 6375 4625 - 35.96deg - 51 37 - modX + cUp 136// 6125 5125 - 39.92deg - 49 41 - modX + cRight 137outputs .leftStickX = 128 + (directions .x * 58 ); 138outputs .leftStickY = 128 + (directions .y * 25 ); 139if (inputs .rt2 ) { 140outputs .leftStickX = 128 + (directions .x * 56 ); 141outputs .leftStickY = 128 + (directions .y * 29 ); 142 } 143if (inputs .rt3 ) { 144outputs .leftStickX = 128 + (directions .x * 53 ); 145outputs .leftStickY = 128 + (directions .y * 33 ); 146 } 147if (inputs .rt4 ) { 148outputs .leftStickX = 128 + (directions .x * 51 ); 149outputs .leftStickY = 128 + (directions .y * 37 ); 150 } 151if (inputs .rt5 ) { 152outputs .leftStickX = 128 + (directions .x * 49 ); 153outputs .leftStickY = 128 + (directions .y * 41 ); 154 } 155 }else { 156/* Extended Up B Angles */ 157// 9125 3875 - 23.01deg - 73 31 - modX + B 158// 8750 4500 - 27.22deg - 70 36 - modX + B + cDown 159// 8500 5250 - 31.70deg - 68 42 - modX + B + cLeft 160// 7250 5250 - 35.91deg - 58 42 - modX + B + cUp 161// 6375 5250 - 39.47deg - 51 42 - modX + B + cRight 162outputs .leftStickX = 128 + (directions .x * 73 ); 163outputs .leftStickY = 128 + (directions .y * 31 ); 164if (inputs .rt2 ) { 165outputs .leftStickX = 128 + (directions .x * 70 ); 166outputs .leftStickY = 128 + (directions .y * 36 ); 167 } 168if (inputs .rt3 ) { 169outputs .leftStickX = 128 + (directions .x * 68 ); 170outputs .leftStickY = 128 + (directions .y * 42 ); 171 } 172if (inputs .rt4 ) { 173outputs .leftStickX = 128 + (directions .x * 58 ); 174outputs .leftStickY = 128 + (directions .y * 42 ); 175 } 176if (inputs .rt5 ) { 177outputs .leftStickX = 128 + (directions .x * 51 ); 178outputs .leftStickY = 128 + (directions .y * 42 ); 179 } 180 } 181 } 182 183// Angled fsmash 184if (directions .cx != 0 ) { 185// 8500 5250 = 68 42 186outputs .rightStickX = 128 + (directions .cx * 68 ); 187outputs .rightStickY = 128 + (directions .y * 42 ); 188 } 189 } 190 191/* Mod Y */ 192if (inputs .lt2 ) { 193// MY + Horizontal (even if shield is held) = 3375 = 27 194if (directions .horizontal ) { 195outputs .leftStickX = 128 + (directions .x * 27 ); 196 } 197// MY + Vertical (even if shield is held) = 7375 = 59 198if (directions .vertical ) { 199outputs .leftStickY = 128 + (directions .y * 59 ); 200 } 201if (directions .diagonal && shield_button_pressed ) { 202// MY + L, R, LS, and MS + q1/2 = 4750 8750 = 38 70 203outputs .leftStickX = 128 + (directions .x * 38 ); 204outputs .leftStickY = 128 + (directions .y * 70 ); 205// MY + L, R, LS, and MS + q3/4 = 5000 8500 = 40 68 206if (directions .y == -1 ) { 207outputs .leftStickX = 128 + (directions .x * 40 ); 208outputs .leftStickY = 128 + (directions .y * 68 ); 209 } 210 } 211 212// Turnaround neutral B nerf 213if (inputs .rf1 ) { 214outputs .leftStickX = 128 + (directions .x * 80 ); 215 } 216 217/* Up B angles */ 218if (directions .diagonal && !shield_button_pressed ) { 219if (!inputs .rf1 ) { 220// 3250 7625 - 23.09deg - 26 61 - modY 221// 3625 7000 - 27.38deg - 29 56 - modY + cDown 222// 4500 6875 - 33.21deg - 36 55 - modY + cLeft (this is shield drop straight down but the cstick will buffer) 223// 5125 7000 - 36.21deg - 41 56 - modY + cUp 224// 5750 7125 - 38.90deg - 46 57 - modY + cRight 225outputs .leftStickX = 128 + (directions .x * 26 ); 226outputs .leftStickY = 128 + (directions .y * 61 ); 227if (inputs .rt2 ) { 228outputs .leftStickX = 128 + (directions .x * 29 ); 229outputs .leftStickY = 128 + (directions .y * 56 ); 230 } 231if (inputs .rt3 ) { 232//outputs.leftStickX = 128 + (directions.x * 35); 233//outputs.leftStickY = 128 + (directions.y * 56); 234outputs .leftStickX = 128 + (directions .x * 36 ); 235outputs .leftStickY = 128 + (directions .y * 55 ); 236 } 237if (inputs .rt4 ) { 238outputs .leftStickX = 128 + (directions .x * 41 ); 239outputs .leftStickY = 128 + (directions .y * 56 ); 240 } 241if (inputs .rt5 ) { 242outputs .leftStickX = 128 + (directions .x * 46 ); 243outputs .leftStickY = 128 + (directions .y * 57 ); 244 } 245 }else { 246/* Extended Up B Angles */ 247// 3875 9125 - 23.01deg - 31 73 - modY + B 248// 4625 8750 - 27.86deg - 37 70 - modY + B + cDown 249// 5375 8250 - 33.08deg - 42 68 - modY + B + cLeft 250// 5750 7875 - 36.14deg - 46 63 - modY + B + cUp 251// 5750 7125 - 38.90deg - 46 57 - modY + B + cRight 252outputs .leftStickX = 128 + (directions .x * 31 ); 253outputs .leftStickY = 128 + (directions .y * 73 ); 254if (inputs .rt2 ) { 255outputs .leftStickX = 128 + (directions .x * 37 ); 256outputs .leftStickY = 128 + (directions .y * 70 ); 257 } 258if (inputs .rt3 ) { 259outputs .leftStickX = 128 + (directions .x * 43 ); 260outputs .leftStickY = 128 + (directions .y * 66 ); 261 } 262if (inputs .rt4 ) { 263outputs .leftStickX = 128 + (directions .x * 46 ); 264outputs .leftStickY = 128 + (directions .y * 63 ); 265 } 266if (inputs .rt5 ) { 267outputs .leftStickX = 128 + (directions .x * 46 ); 268outputs .leftStickY = 128 + (directions .y * 57 ); 269 } 270 } 271 } 272 } 273 274// C-stick ASDI Slideoff angle overrides any other C-stick modifiers (such as 275// angled fsmash). 276if (directions .cx != 0 && directions .cy != 0 ) { 277// 5250 8500 = 42 68 278outputs .rightStickX = 128 + (directions .cx * 42 ); 279outputs .rightStickY = 128 + (directions .cy * 68 ); 280 } 281 282/* 283// Horizontal SOCD overrides X-axis modifiers (for ledgedash maximum jump 284// trajectory). 285if (!_options.disable_ledgedash_socd_override && _horizontal_socd && !directions.vertical) { 286outputs.leftStickX = 128 + (directions.x * 80); 287} 288*/ 289 290if (inputs .rf7 ) { 291outputs .triggerRAnalog = 49 ; 292 } 293if (inputs .rf8 ) { 294outputs .triggerRAnalog = 94 ; 295 } 296 297if (outputs .triggerLDigital ) { 298outputs .triggerLAnalog = 140 ; 299 } 300if (outputs .triggerRDigital ) { 301outputs .triggerRAnalog = 140 ; 302 } 303 304// Shut off C-stick when using D-Pad layer. 305if ((inputs .lt1 && inputs .lt2 )|| inputs .nunchuk_c || inputs .lt3 || inputs .lf6 ) { 306outputs .rightStickX = 128 ; 307outputs .rightStickY = 128 ; 308 } 309 310/* 311// Nunchuk overrides left stick. 312if (inputs.nunchuk_connected) { 313outputs.leftStickX = inputs.nunchuk_x; 314outputs.leftStickY = inputs.nunchuk_y; 315} 316*/ 317}