fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
1f92ae6
v0.1.2
1#include "modes/extra/RocketLeague.hpp" 2 3#define ANALOG_STICK_MIN 0 4#define ANALOG_STICK_NEUTRAL 128 5#define ANALOG_STICK_MAX 255 6 7RocketLeague ::RocketLeague (socd::SocdType socd_type ) { 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 ::mod_x , socd::SOCD_DIR2_PRIORITY }, 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 17void RocketLeague ::UpdateDigitalOutputs (InputState & inputs ,OutputState & outputs ) { 18outputs .a = inputs .a ; 19outputs .b = inputs .b ; 20outputs .x = inputs .midshield ; 21outputs .y = inputs .up ; 22outputs .buttonL = inputs .l ; 23outputs .buttonR = inputs .lightshield ; 24outputs .triggerLDigital = inputs .z ; 25outputs .triggerRDigital = inputs .x ; 26outputs .leftStickClick = inputs .r ; 27 28// Hold accelerate and reverse simultaneously for rear view. 29if (inputs .z && inputs .x ) { 30outputs .rightStickClick = true; 31// Override (deactivate) accelerator. 32outputs .triggerRDigital = false; 33 } 34 35// MX + Start = Select 36if (inputs .mod_x ) 37outputs .select = inputs .start ; 38else 39outputs .start = inputs .start ; 40 41// D-Pad 42if (inputs .mod_x && inputs .mod_y ) { 43outputs .dpadUp = inputs .c_up ; 44outputs .dpadDown = inputs .c_down ; 45outputs .dpadLeft = inputs .c_left ; 46outputs .dpadRight = inputs .c_right ; 47 } 48} 49 50void RocketLeague ::UpdateAnalogOutputs (InputState & inputs ,OutputState & outputs ) { 51// Coordinate calculations to make modifier handling simpler. 52UpdateDirections ( 53inputs .left , 54inputs .right , 55inputs .down , 56inputs .mod_x , 57inputs .c_left , 58inputs .c_right , 59inputs .c_down , 60inputs .c_up , 61ANALOG_STICK_MIN , 62ANALOG_STICK_NEUTRAL , 63ANALOG_STICK_MAX , 64outputs 65 ); 66 67if (inputs .mod_y ) { 68if (directions .diagonal ) { 69outputs .leftStickX = ANALOG_STICK_NEUTRAL + (directions .x * 70 ); 70// outputs.leftStickY = 71// ANALOG_STICK_NEUTRAL + (directions.y * 76); 72 }else if (directions .horizontal ) { 73outputs .leftStickX = ANALOG_STICK_NEUTRAL + (directions .x * 35 ); 74 }else if (directions .vertical ) { 75outputs .leftStickY = ANALOG_STICK_NEUTRAL + (directions .y * 76 ); 76 } 77 }else if (directions .diagonal ) { 78// Good speed flip angle with no mods. 79outputs .leftStickX = ANALOG_STICK_NEUTRAL + (directions .x * 70 ); 80 } 81 82// Shut off right stick when using dpad layer. 83if (inputs .mod_x && inputs .mod_y ) { 84outputs .rightStickX = ANALOG_STICK_NEUTRAL ; 85outputs .rightStickY = ANALOG_STICK_NEUTRAL ; 86 } 87 88// Nunchuk overrides left stick. 89if (inputs .nunchuk_connected ) { 90outputs .leftStickX = inputs .nunchuk_x ; 91outputs .leftStickY = inputs .nunchuk_y ; 92 } 93}