fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
007edc4
v0.1.0
1/* Ultimate profile by Taker */ 2#include "modes/UltimateUSB.hpp" 3 4#define ANALOG_STICK_MIN 28 5#define ANALOG_STICK_NEUTRAL 128 6#define ANALOG_STICK_MAX 228 7 8UltimateUSB ::UltimateUSB (socd::SocdType socd_type ) { 9_socd_pair_count = 5 ; 10_socd_pairs = new socd::SocdPair [_socd_pair_count ]{ 11 socd::SocdPair {& InputState ::left ,& InputState ::right ,socd_type }, 12 socd::SocdPair {& InputState ::down ,& InputState ::up ,socd_type }, 13 socd::SocdPair {& InputState ::down ,& InputState ::up2 ,socd_type }, 14 socd::SocdPair {& InputState ::c_left ,& InputState ::c_right ,socd_type }, 15 socd::SocdPair {& InputState ::c_down ,& InputState ::c_up ,socd_type }, 16 }; 17} 18 19void UltimateUSB ::UpdateDigitalOutputs (InputState & inputs ,OutputState & outputs ) { 20outputs .b = inputs .a ; 21outputs .a = inputs .b ; 22outputs .x = inputs .x ; 23outputs .y = inputs .y ; 24outputs .buttonL = inputs .lightshield ; 25outputs .buttonR = inputs .z || inputs .midshield ; 26outputs .triggerLDigital = inputs .l ; 27outputs .triggerRDigital = inputs .r ; 28outputs .start = inputs .start ; 29outputs .select = inputs .select ; 30outputs .home = inputs .home ; 31 32// Turn on D-Pad layer by holding Mod X + Mod Y or Nunchuk C button. 33if ((inputs .mod_x && inputs .mod_y )|| inputs .up2 ) { 34outputs .dpadUp = inputs .c_up ; 35outputs .dpadDown = inputs .c_down ; 36outputs .dpadLeft = inputs .c_left ; 37outputs .dpadRight = inputs .c_right ; 38 } 39 40// Activate select/home by holding Mod Y 41if ((inputs .mod_y )) { 42outputs .select = inputs .midshield ; 43outputs .home = inputs .start ; 44 } 45} 46 47void UltimateUSB ::UpdateAnalogOutputs (InputState & inputs ,OutputState & outputs ) { 48// Coordinate calculations to make modifier handling simpler. 49UpdateDirections ( 50inputs .left , 51inputs .right , 52inputs .down , 53inputs .up , 54inputs .c_left , 55inputs .c_right , 56inputs .c_down , 57inputs .c_up , 58ANALOG_STICK_MIN , 59ANALOG_STICK_NEUTRAL , 60ANALOG_STICK_MAX , 61outputs 62 ); 63 64bool shield_button_pressed = inputs .l || inputs .r ; 65 66if (inputs .mod_x ) { 67// MX + Horizontal = 6625 = 53 68if (directions .horizontal ) { 69outputs .leftStickX = 128 + (directions .x * 53 ); 70// Horizontal Shield tilt = 51 71if (shield_button_pressed ) { 72outputs .leftStickX = 128 + (directions .x * 51 ); 73 } 74// Horizontal Tilts = 36 75if (inputs .a ) { 76outputs .leftStickX = 128 + (directions .x * 36 ); 77 } 78 } 79// MX + Vertical = 44 80if (directions .vertical ) { 81outputs .leftStickY = 128 + (directions .y * 44 ); 82// Vertical Shield Tilt = 51 83if (shield_button_pressed ) { 84outputs .leftStickY = 128 + (directions .y * 51 ); 85 } 86 } 87if (directions .diagonal ) { 88// MX + q1/2/3/4 = 53 35 89outputs .leftStickX = 128 + (directions .x * 53 ); 90outputs .leftStickY = 128 + (directions .y * 35 ); 91if (shield_button_pressed ) { 92// MX + L, R, LS, and MS + q1/2/3/4 = 6375 3750 = 51 30 93outputs .leftStickX = 128 + (directions .x * 51 ); 94outputs .leftStickY = 128 + (directions .y * 30 ); 95 } 96 } 97 98// Angled fsmash/ftilt with C-Stick + MX 99if (directions .cx != 0 ) { 100outputs .rightStickX = 128 + (directions .cx * 127 ); 101outputs .rightStickY = 128 + (directions .y * 59 ); 102 } 103 104/* Up B angles */ 105if (directions .diagonal && !shield_button_pressed ) { 106// (33.44) = 53 35 107outputs .leftStickX = 128 + (directions .x * 53 ); 108outputs .leftStickY = 128 + (directions .y * 35 ); 109// (39.05) = 53 43 110if (inputs .c_down ) { 111outputs .leftStickX = 128 + (directions .x * 53 ); 112outputs .leftStickY = 128 + (directions .y * 43 ); 113 } 114// (36.35) = 53 39 115if (inputs .c_left ) { 116outputs .leftStickX = 128 + (directions .x * 53 ); 117outputs .leftStickY = 128 + (directions .y * 39 ); 118 } 119// (30.32) = 56 41 120if (inputs .c_up ) { 121outputs .leftStickX = 128 + (directions .x * 53 ); 122outputs .leftStickY = 128 + (directions .y * 31 ); 123 } 124// (27.85) = 49 42 125if (inputs .c_right ) { 126outputs .leftStickX = 128 + (directions .x * 53 ); 127outputs .leftStickY = 128 + (directions .y * 28 ); 128 } 129 130/* Extended Up B Angles */ 131if (inputs .b ) { 132// (33.29) = 67 44 133outputs .leftStickX = 128 + (directions .x * 67 ); 134outputs .leftStickY = 128 + (directions .y * 44 ); 135// (39.38) = 67 55 136if (inputs .c_down ) { 137outputs .leftStickX = 128 + (directions .x * 67 ); 138outputs .leftStickY = 128 + (directions .y * 55 ); 139 } 140// (36.18) = 67 49 141if (inputs .c_left ) { 142outputs .leftStickX = 128 + (directions .x * 67 ); 143outputs .leftStickY = 128 + (directions .y * 49 ); 144 } 145// (30.2) = 67 39 146if (inputs .c_up ) { 147outputs .leftStickX = 128 + (directions .x * 67 ); 148outputs .leftStickY = 128 + (directions .y * 39 ); 149 } 150// (27.58) = 67 35 151if (inputs .c_right ) { 152outputs .leftStickX = 128 + (directions .x * 67 ); 153outputs .leftStickY = 128 + (directions .y * 35 ); 154 } 155 } 156 157// Angled Ftilts 158if (inputs .a ) { 159outputs .leftStickX = 128 + (directions .x * 36 ); 160outputs .leftStickY = 128 + (directions .y * 26 ); 161 } 162 } 163 } 164 165if (inputs .mod_y ) { 166// MY + Horizontal (even if shield is held) = 41 167if (directions .horizontal ) { 168outputs .leftStickX = 128 + (directions .x * 41 ); 169// MY Horizontal Tilts 170if (inputs .a ) { 171outputs .leftStickX = 128 + (directions .x * 36 ); 172 } 173 } 174// MY + Vertical (even if shield is held) = 53 175if (directions .vertical ) { 176outputs .leftStickY = 128 + (directions .y * 53 ); 177// MY Vertical Tilts 178if (inputs .a ) { 179outputs .leftStickY = 128 + (directions .y * 36 ); 180 } 181 } 182if (directions .diagonal ) { 183// MY + q1/2/3/4 = 35 59 184outputs .leftStickX = 128 + (directions .x * 35 ); 185outputs .leftStickY = 128 + (directions .y * 53 ); 186if (shield_button_pressed ) { 187// MY + L, R, LS, and MS + q1/2 = 38 70 188outputs .leftStickX = 128 + (directions .x * 38 ); 189outputs .leftStickY = 128 + (directions .y * 70 ); 190// MY + L, R, LS, and MS + q3/4 = 40 68 191if (directions .x == -1 ) { 192outputs .leftStickX = 128 + (directions .x * 40 ); 193outputs .leftStickY = 128 + (directions .y * 68 ); 194 } 195 } 196 } 197 198/* Up B angles */ 199if (directions .diagonal && !shield_button_pressed ) { 200// (56.56) = 35 53 201outputs .leftStickX = 128 + (directions .x * 35 ); 202outputs .leftStickY = 128 + (directions .y * 53 ); 203// (50.95) = 43 53 204if (inputs .c_down ) { 205outputs .leftStickX = 128 + (directions .x * 43 ); 206outputs .leftStickY = 128 + (directions .y * 53 ); 207 } 208// (53.65) = 39 53 209if (inputs .c_left ) { 210outputs .leftStickX = 128 + (directions .x * 49 ); 211outputs .leftStickY = 128 + (directions .y * 53 ); 212 } 213// (59.68) = 31 53 214if (inputs .c_up ) { 215outputs .leftStickX = 128 + (directions .x * 31 ); 216outputs .leftStickY = 128 + (directions .y * 53 ); 217 } 218// (62.15) = 28 53 219if (inputs .c_right ) { 220outputs .leftStickX = 128 + (directions .x * 28 ); 221outputs .leftStickY = 128 + (directions .y * 53 ); 222 } 223 224/* Extended Up B Angles */ 225if (inputs .b ) { 226// (56.71) = 44 67 227outputs .leftStickX = 128 + (directions .x * 44 ); 228outputs .leftStickY = 128 + (directions .y * 67 ); 229// (50.62) = 55 67 230if (inputs .c_down ) { 231outputs .leftStickX = 128 + (directions .x * 55 ); 232outputs .leftStickY = 128 + (directions .y * 67 ); 233 } 234// (53.82) = 49 67 235if (inputs .c_left ) { 236outputs .leftStickX = 128 + (directions .x * 49 ); 237outputs .leftStickY = 128 + (directions .y * 67 ); 238 } 239// (59.8) = 39 67 240if (inputs .c_up ) { 241outputs .leftStickX = 128 + (directions .x * 39 ); 242outputs .leftStickY = 128 + (directions .y * 67 ); 243 } 244// (62.42) = 35 67 245if (inputs .c_right ) { 246outputs .leftStickX = 128 + (directions .x * 35 ); 247outputs .leftStickY = 128 + (directions .y * 67 ); 248 } 249 } 250 251// MY Pivot Uptilt/Dtilt 252if (inputs .a ) { 253outputs .leftStickX = 128 + (directions .x * 34 ); 254outputs .leftStickY = 128 + (directions .y * 38 ); 255 } 256 } 257 } 258 259// C-stick ASDI Slideoff angle overrides any other C-stick modifiers (such as 260// angled fsmash). 261if (directions .cx != 0 && directions .cy != 0 ) { 262// 5250 8500 = 42 68 263outputs .rightStickX = 128 + (directions .cx * 42 ); 264outputs .rightStickY = 128 + (directions .cy * 68 ); 265 } 266 267if (inputs .l ) { 268outputs .triggerLAnalog = 140 ; 269 } 270 271if (inputs .r ) { 272outputs .triggerRAnalog = 140 ; 273 } 274 275// Shut off C-stick when using D-Pad layer. 276if ((inputs .mod_x && inputs .mod_y )|| inputs .up2 ) { 277outputs .rightStickX = 128 ; 278outputs .rightStickY = 128 ; 279 } 280 281// Turns off Start when holding Mod Y 282if ((inputs .mod_y )) { 283outputs .start = false; 284 } 285 286// Nunchuk overrides left stick. 287if (inputs .nunchuk_connected ) { 288outputs .leftStickX = inputs .nunchuk_x ; 289outputs .leftStickY = inputs .nunchuk_y ; 290 } 291}