fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
007edc4
v0.1.0
1#include "modes/Melee20Button.hpp" 2 3#define ANALOG_STICK_MIN 48 4#define ANALOG_STICK_NEUTRAL 128 5#define ANALOG_STICK_MAX 208 6 7Melee20Button ::Melee20Button (socd::SocdType socd_type ,Melee20ButtonOptions options ) { 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_options = options ; 17_horizontal_socd = false; 18} 19 20void Melee20Button ::HandleSocd (InputState & inputs ) { 21_horizontal_socd = inputs .left && inputs .right ; 22InputMode ::HandleSocd (inputs ); 23} 24 25void Melee20Button ::UpdateDigitalOutputs (InputState & inputs ,OutputState & outputs ) { 26outputs .a = inputs .a ; 27outputs .b = inputs .b ; 28outputs .x = inputs .x ; 29outputs .y = inputs .y ; 30outputs .buttonR = inputs .z ; 31if (inputs .nunchuk_connected ) { 32outputs .triggerLDigital = inputs .nunchuk_z ; 33 }else { 34outputs .triggerLDigital = inputs .l ; 35 } 36outputs .triggerRDigital = inputs .r ; 37outputs .start = inputs .start ; 38 39// Activate D-Pad layer by holding Mod X + Mod Y or Nunchuk C button. 40if ((inputs .mod_x && inputs .mod_y )|| inputs .up2 ) { 41outputs .dpadUp = inputs .c_up ; 42outputs .dpadDown = inputs .c_down ; 43outputs .dpadLeft = inputs .c_left ; 44outputs .dpadRight = inputs .c_right ; 45 } 46 47if (inputs .select ) 48outputs .dpadLeft = true; 49if (inputs .home ) 50outputs .dpadRight = true; 51} 52 53void Melee20Button ::UpdateAnalogOutputs (InputState & inputs ,OutputState & outputs ) { 54// Coordinate calculations to make modifier handling simpler. 55UpdateDirections ( 56inputs .left , 57inputs .right , 58inputs .down , 59inputs .up , 60inputs .c_left , 61inputs .c_right , 62inputs .c_down , 63inputs .c_up , 64ANALOG_STICK_MIN , 65ANALOG_STICK_NEUTRAL , 66ANALOG_STICK_MAX , 67outputs 68 ); 69 70bool shield_button_pressed = inputs .l || inputs .r || inputs .lightshield || inputs .midshield ; 71if (directions .diagonal ) { 72// q1/2 = 7000 7000 73outputs .leftStickX = 128 + (directions .x * 56 ); 74outputs .leftStickY = 128 + (directions .y * 56 ); 75// L, R, LS, and MS + q3/4 = 7000 6875 (For vanilla shield drop. Gives 44.5 76// degree wavedash). Also used as default q3/4 diagonal if crouch walk option select is 77// enabled. 78if (directions .y == -1 && (shield_button_pressed || _options .crouch_walk_os )) { 79outputs .leftStickX = 128 + (directions .x * 56 ); 80outputs .leftStickY = 128 + (directions .y * 55 ); 81 } 82 } 83 84if (inputs .mod_x ) { 85// MX + Horizontal (even if shield is held) = 6625 = 53 86if (directions .horizontal ) { 87outputs .leftStickX = 128 + (directions .x * 53 ); 88 } 89// MX + Vertical (even if shield is held) = 5375 = 43 90if (directions .vertical ) { 91outputs .leftStickY = 128 + (directions .y * 43 ); 92 } 93if (directions .diagonal && shield_button_pressed ) { 94// MX + L, R, LS, and MS + q1/2/3/4 = 6375 3750 = 51 30 95outputs .leftStickX = 128 + (directions .x * 51 ); 96outputs .leftStickY = 128 + (directions .y * 30 ); 97 } 98 99/* Up B angles */ 100if (directions .diagonal && !shield_button_pressed ) { 101// 22.9638 - 7375 3125 = 59 25 102outputs .leftStickX = 128 + (directions .x * 59 ); 103outputs .leftStickY = 128 + (directions .y * 25 ); 104// 27.37104 - 7000 3625 (27.38) = 56 29 105if (inputs .c_down ) { 106outputs .leftStickX = 128 + (directions .x * 56 ); 107outputs .leftStickY = 128 + (directions .y * 29 ); 108 } 109// 31.77828 - 7875 4875 (31.76) = 63 39 110if (inputs .c_left ) { 111outputs .leftStickX = 128 + (directions .x * 63 ); 112outputs .leftStickY = 128 + (directions .y * 39 ); 113 } 114// 36.18552 - 7000 5125 (36.21) = 56 41 115if (inputs .c_up ) { 116outputs .leftStickX = 128 + (directions .x * 56 ); 117outputs .leftStickY = 128 + (directions .y * 41 ); 118 } 119// 40.59276 - 6125 5250 (40.6) = 49 42 120if (inputs .c_right ) { 121outputs .leftStickX = 128 + (directions .x * 49 ); 122outputs .leftStickY = 128 + (directions .y * 42 ); 123 } 124 125/* Extended Up B Angles */ 126if (inputs .b ) { 127// 22.9638 - 9125 3875 (23.0) = 73 31 128outputs .leftStickX = 128 + (directions .x * 73 ); 129outputs .leftStickY = 128 + (directions .y * 31 ); 130// 27.37104 - 8750 4500 (27.2) = 70 36 131if (inputs .c_down ) { 132outputs .leftStickX = 128 + (directions .x * 70 ); 133outputs .leftStickY = 128 + (directions .y * 36 ); 134 } 135// 31.77828 - 8500 5250 (31.7) = 68 42 136if (inputs .c_left ) { 137outputs .leftStickX = 128 + (directions .x * 68 ); 138outputs .leftStickY = 128 + (directions .y * 42 ); 139 } 140// 36.18552 - 7375 5375 (36.1) = 59 43 141if (inputs .c_up ) { 142outputs .leftStickX = 128 + (directions .x * 59 ); 143outputs .leftStickY = 128 + (directions .y * 43 ); 144 } 145// 40.59276 - 6375 5375 (40.1) = 51 43 146if (inputs .c_right ) { 147outputs .leftStickX = 128 + (directions .x * 51 ); 148outputs .leftStickY = 128 + (directions .y * 43 ); 149 } 150 } 151 } 152 153// Angled fsmash 154if (directions .cx != 0 ) { 155// 8500 5250 = 68 42 156outputs .rightStickX = 128 + (directions .cx * 68 ); 157outputs .rightStickY = 128 + (directions .y * 42 ); 158 } 159 } 160 161if (inputs .mod_y ) { 162// MY + Horizontal (even if shield is held) = 3375 = 27 163if (directions .horizontal ) { 164outputs .leftStickX = 128 + (directions .x * 27 ); 165 } 166// MY + Vertical (even if shield is held) = 7375 = 59 167if (directions .vertical ) { 168outputs .leftStickY = 128 + (directions .y * 59 ); 169 } 170if (directions .diagonal && shield_button_pressed ) { 171// MY + L, R, LS, and MS + q1/2 = 4750 8750 = 38 70 172outputs .leftStickX = 128 + (directions .x * 38 ); 173outputs .leftStickY = 128 + (directions .y * 70 ); 174// MY + L, R, LS, and MS + q3/4 = 5000 8500 = 40 68 175if (directions .y == -1 ) { 176outputs .leftStickX = 128 + (directions .x * 40 ); 177outputs .leftStickY = 128 + (directions .y * 68 ); 178 } 179 } 180 181// Turnaround neutral B nerf 182if (inputs .b ) { 183outputs .leftStickX = 128 + (directions .x * 80 ); 184 } 185 186/* Up B angles */ 187if (directions .diagonal && !shield_button_pressed ) { 188// 67.0362 - 3125 7375 = 25 59 189outputs .leftStickX = 128 + (directions .x * 25 ); 190outputs .leftStickY = 128 + (directions .y * 59 ); 191// 62.62896 - 3625 7000 (62.62) = 29 56 192if (inputs .c_down ) { 193outputs .leftStickX = 128 + (directions .x * 29 ); 194outputs .leftStickY = 128 + (directions .y * 56 ); 195 } 196// 58.22172 - 4875 7875 (58.24) = 39 63 197if (inputs .c_left ) { 198outputs .leftStickX = 128 + (directions .x * 39 ); 199outputs .leftStickY = 128 + (directions .y * 63 ); 200 } 201// 53.81448 - 5125 7000 (53.79) = 41 56 202if (inputs .c_up ) { 203outputs .leftStickX = 128 + (directions .x * 41 ); 204outputs .leftStickY = 128 + (directions .y * 56 ); 205 } 206// 49.40724 - 6375 7625 (50.10) = 51 61 207if (inputs .c_right ) { 208outputs .leftStickX = 128 + (directions .x * 51 ); 209outputs .leftStickY = 128 + (directions .y * 61 ); 210 } 211 212/* Extended Up B Angles */ 213if (inputs .b ) { 214// 67.0362 - 3875 9125 = 31 73 215outputs .leftStickX = 128 + (directions .x * 31 ); 216outputs .leftStickY = 128 + (directions .y * 73 ); 217// 62.62896 - 4500 8750 (62.8) = 36 70 218if (inputs .c_down ) { 219outputs .leftStickX = 128 + (directions .x * 36 ); 220outputs .leftStickY = 128 + (directions .y * 70 ); 221 } 222// 58.22172 - 5250 8500 (58.3) = 42 68 223if (inputs .c_left ) { 224outputs .leftStickX = 128 + (directions .x * 42 ); 225outputs .leftStickY = 128 + (directions .y * 68 ); 226 } 227// 53.81448 - 5875 8000 (53.7) = 47 64 228if (inputs .c_up ) { 229outputs .leftStickX = 128 + (directions .x * 47 ); 230outputs .leftStickY = 128 + (directions .y * 64 ); 231 } 232// 49.40724 - 5875 7125 (50.49) = 47 57 233if (inputs .c_right ) { 234outputs .leftStickX = 128 + (directions .x * 47 ); 235outputs .leftStickY = 128 + (directions .y * 57 ); 236 } 237 } 238 } 239 } 240 241// C-stick ASDI Slideoff angle overrides any other C-stick modifiers (such as 242// angled fsmash). 243if (directions .cx != 0 && directions .cy != 0 ) { 244// 5250 8500 = 42 68 245outputs .rightStickX = 128 + (directions .cx * 42 ); 246outputs .rightStickY = 128 + (directions .cy * 68 ); 247 } 248 249// Horizontal SOCD overrides X-axis modifiers (for ledgedash maximum jump 250// trajectory). 251if (_horizontal_socd && !directions .vertical ) { 252outputs .leftStickX = 128 + (directions .x * 80 ); 253 } 254 255if (inputs .lightshield ) { 256outputs .triggerRAnalog = 49 ; 257 } 258if (inputs .midshield ) { 259outputs .triggerRAnalog = 94 ; 260 } 261 262if (outputs .triggerLDigital ) { 263outputs .triggerLAnalog = 140 ; 264 } 265if (outputs .triggerRDigital ) { 266outputs .triggerRAnalog = 140 ; 267 } 268 269// Shut off C-stick when using D-Pad layer. 270if ((inputs .mod_x && inputs .mod_y )|| inputs .up2 ) { 271outputs .rightStickX = 128 ; 272outputs .rightStickY = 128 ; 273 } 274 275// Nunchuk overrides left stick. 276if (inputs .nunchuk_connected ) { 277outputs .leftStickX = inputs .nunchuk_x ; 278outputs .leftStickY = inputs .nunchuk_y ; 279 } 280}