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