fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
2c36333
codespace-scaling-space-guide-56rpxqvxpg2v57v
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 (socd::SocdType socd_type ,ProjectMOptions 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 ProjectM ::HandleSocd (InputState & inputs ) { 21_horizontal_socd = inputs .left && inputs .right ; 22InputMode ::HandleSocd (inputs ); 23} 24 25void ProjectM ::UpdateDigitalOutputs (InputState & inputs ,OutputState & outputs ) { 26outputs .a = inputs .a ; 27outputs .b = inputs .b ; 28outputs .x = inputs .x ; 29outputs .y = inputs .y ; 30// True Z press vs macro lightshield + A. 31if (_options .true_z_press || inputs .mod_x ) { 32outputs .buttonR = inputs .z ; 33 }else { 34outputs .a = inputs .a || inputs .z ; 35 } 36if (inputs .nunchuk_connected ) { 37outputs .triggerLDigital = inputs .nunchuk_z ; 38 }else { 39outputs .triggerLDigital = inputs .l ; 40 } 41outputs .triggerRDigital = inputs .r ; 42outputs .start = inputs .start ; 43 44// Activate D-Pad layer by holding Mod X + Mod Y or Nunchuk C button. 45if ((inputs .mod_x && inputs .mod_y )|| inputs .up2 ) { 46outputs .dpadUp = inputs .c_up ; 47outputs .dpadDown = inputs .c_down ; 48outputs .dpadLeft = inputs .c_left ; 49outputs .dpadRight = inputs .c_right ; 50 } 51 52// Don't override dpad up if it's already pressed using the MX + MY dpad 53// layer. 54outputs .dpadUp = outputs .dpadUp || inputs .midshield ; 55 56if (inputs .select ) 57outputs .dpadLeft = true; 58if (inputs .home ) 59outputs .dpadRight = true; 60} 61 62void ProjectM ::UpdateAnalogOutputs (InputState & inputs ,OutputState & outputs ) { 63UpdateDirections ( 64inputs .left , 65inputs .right , 66inputs .down , 67inputs .up , 68inputs .c_left , 69inputs .c_right , 70inputs .c_down , 71inputs .c_up , 72ANALOG_STICK_MIN , 73ANALOG_STICK_NEUTRAL , 74ANALOG_STICK_MAX , 75outputs 76 ); 77 78bool shield_button_pressed = inputs .l || inputs .lightshield ; 79 80if (directions .diagonal ) { 81if (directions .y == 1 ) { 82outputs .leftStickX = 128 + (directions .x * 83 ); 83outputs .leftStickY = 128 + (directions .y * 93 ); 84 } 85 } 86 87if (inputs .mod_x ) { 88if (directions .horizontal ) { 89outputs .leftStickX = 128 + (directions .x * 70 ); 90 } 91if (directions .vertical ) { 92outputs .leftStickY = 128 + (directions .y * 60 ); 93 } 94 95if (directions .cx != 0 ) { 96outputs .rightStickX = 128 + (directions .cx * 65 ); 97outputs .rightStickY = 128 + (directions .y * 23 ); 98 } 99 100if (directions .diagonal ) { 101outputs .leftStickX = 128 + (directions .x * 70 ); 102outputs .leftStickY = 128 + (directions .y * 34 ); 103 104if (inputs .b ) { 105outputs .leftStickX = 128 + (directions .x * 85 ); 106outputs .leftStickY = 128 + (directions .y * 31 ); 107 } 108 109if (inputs .r ) { 110outputs .leftStickX = 128 + (directions .x * 82 ); 111outputs .leftStickY = 128 + (directions .y * 35 ); 112 } 113 114if (inputs .c_up ) { 115outputs .leftStickX = 128 + (directions .x * 77 ); 116outputs .leftStickY = 128 + (directions .y * 55 ); 117 } 118 119if (inputs .c_down ) { 120outputs .leftStickX = 128 + (directions .x * 82 ); 121outputs .leftStickY = 128 + (directions .y * 36 ); 122 } 123 124if (inputs .c_left ) { 125outputs .leftStickX = 128 + (directions .x * 84 ); 126outputs .leftStickY = 128 + (directions .y * 50 ); 127 } 128 129if (inputs .c_right ) { 130outputs .leftStickX = 128 + (directions .x * 72 ); 131outputs .leftStickY = 128 + (directions .y * 61 ); 132 } 133 } 134 } 135 136if (inputs .mod_y ) { 137if (directions .horizontal ) { 138outputs .leftStickX = 128 + (directions .x * 35 ); 139 } 140if (directions .vertical ) { 141outputs .leftStickY = 128 + (directions .y * 70 ); 142 } 143 144if (directions .diagonal ) { 145outputs .leftStickX = 128 + (directions .x * 28 ); 146outputs .leftStickY = 128 + (directions .y * 58 ); 147 148if (inputs .b ) { 149outputs .leftStickX = 128 + (directions .x * 28 ); 150outputs .leftStickY = 128 + (directions .y * 85 ); 151 } 152 153if (inputs .r ) { 154outputs .leftStickX = 128 + (directions .x * 51 ); 155outputs .leftStickY = 128 + (directions .y * 82 ); 156 } 157 158if (inputs .c_up ) { 159outputs .leftStickX = 128 + (directions .x * 55 ); 160outputs .leftStickY = 128 + (directions .y * 77 ); 161 } 162 163if (inputs .c_down ) { 164outputs .leftStickX = 128 + (directions .x * 34 ); 165outputs .leftStickY = 128 + (directions .y * 82 ); 166 } 167 168if (inputs .c_left ) { 169outputs .leftStickX = 128 + (directions .x * 40 ); 170outputs .leftStickY = 128 + (directions .y * 84 ); 171 } 172 173if (inputs .c_right ) { 174outputs .leftStickX = 128 + (directions .x * 62 ); 175outputs .leftStickY = 128 + (directions .y * 72 ); 176 } 177 } 178 } 179 180// C-stick ASDI Slideoff angle overrides any other C-stick modifiers (such as 181// angled fsmash). 182// We don't apply this for c-up + c-left/c-right in case we want to implement 183// C-stick nair somehow. 184if (directions .cx != 0 && directions .cy == -1 ) { 185// 3000 9875 = 30 78 186outputs .rightStickX = 128 + (directions .cx * 35 ); 187outputs .rightStickY = 128 + (directions .cy * 98 ); 188 } 189 190// Horizontal SOCD overrides X-axis modifiers (for ledgedash maximum jump 191// trajectory). 192if (_options .ledgedash_max_jump_traj && _horizontal_socd && !directions .vertical && 193 !shield_button_pressed ) { 194outputs .leftStickX = 128 + (directions .x * 100 ); 195 } 196 197if (inputs .lightshield ) { 198outputs .triggerRAnalog = 49 ; 199 } 200 201// Send lightshield input if we are using Z = lightshield + A macro. 202if (inputs .z && !(inputs .mod_x || _options .true_z_press )) { 203outputs .triggerRAnalog = 49 ; 204 } 205 206if (outputs .triggerLDigital ) { 207outputs .triggerLAnalog = 140 ; 208 } 209 210if (outputs .triggerRDigital ) { 211outputs .triggerRAnalog = 140 ; 212 } 213 214// Shut off C-stick when using D-Pad layer. 215if ((inputs .mod_x && inputs .mod_y )|| inputs .up2 ) { 216outputs .rightStickX = 128 ; 217outputs .rightStickY = 128 ; 218 } 219 220// Nunchuk overrides left stick. 221if (inputs .nunchuk_connected ) { 222outputs .leftStickX = inputs .nunchuk_x ; 223outputs .leftStickY = inputs .nunchuk_y ; 224 } 225}