fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
b54c384
v0.1.2
1#include "modes/FgcMode.hpp" 2 3#define ANALOG_STICK_MIN 28 4#define ANALOG_STICK_NEUTRAL 128 5#define ANALOG_STICK_MAX 228 6 7FgcMode ::FgcMode (socd::SocdType horizontal_socd , socd::SocdType vertical_socd ) { 8_socd_pair_count = 7 ; 9_socd_pairs = new socd::SocdPair [_socd_pair_count ]{ 10 socd::SocdPair {& InputState ::left ,& InputState ::right ,horizontal_socd }, 11/* Mod X override C-Up input if both are pressed. Without this, neutral SOCD doesn't work 12properly if Down and both Up buttons are pressed, because it first resolves Down + Mod X 13to set both as unpressed, and then it sees C-Up as pressed but not Down, so you get an up 14input instead of neutral. */ 15 socd::SocdPair {& InputState ::mod_x ,& InputState ::c_up , socd::SOCD_DIR1_PRIORITY }, 16 socd::SocdPair {& InputState ::mod_x ,& InputState ::up2 , socd::SOCD_DIR1_PRIORITY }, 17 socd::SocdPair {& InputState ::c_up ,& InputState ::up2 , socd::SOCD_DIR1_PRIORITY }, 18 socd::SocdPair {& InputState ::down ,& InputState ::mod_x ,vertical_socd }, 19 socd::SocdPair {& InputState ::down ,& InputState ::up2 ,vertical_socd }, 20 socd::SocdPair {& InputState ::down ,& InputState ::c_up ,vertical_socd }, 21 }; 22} 23 24void FgcMode ::UpdateDigitalOutputs (InputState & inputs ,OutputState & outputs ) { 25// Directions 26outputs .dpadLeft = inputs .left ; 27outputs .dpadRight = inputs .right ; 28outputs .dpadDown = inputs .down ; 29outputs .dpadUp = inputs .mod_x || inputs .up2 || inputs .c_up ; 30 31// L3 & R3 32outputs .leftStickClick = inputs .l || inputs .c_left ; 33outputs .rightStickClick = inputs .a ; 34 35// Menu keys 36outputs .start = inputs .start ; 37outputs .select = inputs .select ; 38outputs .home = inputs .home ; 39 40// Activate select/home by holding Mod Y 41if ((inputs .mod_y )) { 42outputs .select = inputs .midshield ; 43outputs .home = inputs .start ; 44 } 45 46// Right hand bottom row 47outputs .a = inputs .b ; 48outputs .b = inputs .x ; 49outputs .triggerRDigital = inputs .z ; 50outputs .triggerLDigital = inputs .up ; 51 52// Right hand top row 53outputs .x = inputs .r ; 54outputs .y = inputs .y ; 55outputs .buttonR = inputs .lightshield ; 56outputs .buttonL = inputs .midshield ; 57 58// Turns off Start / LB when holding Mod Y 59if ((inputs .mod_y )) { 60outputs .start = false; 61outputs .buttonL = false; 62// Turn off DPad 63outputs .dpadLeft = false; 64outputs .dpadRight = false; 65outputs .dpadDown = false; 66outputs .dpadUp = false; 67outputs .leftStickClick = false; 68 } 69} 70 71void FgcMode ::UpdateAnalogOutputs (InputState & inputs ,OutputState & outputs ) { 72outputs .leftStickX = 128 ; 73outputs .leftStickY = 128 ; 74outputs .rightStickX = 128 ; 75outputs .rightStickY = 128 ; 76outputs .triggerLAnalog = outputs .triggerLDigital ?255 :0 ; 77outputs .triggerRAnalog = outputs .triggerRDigital ?255 :0 ; 78 79//Hold Mod Y to use analog input. 80if ((inputs .mod_y )) { 81UpdateDirections ( 82inputs .left , 83inputs .right , 84inputs .down , 85inputs .up2 , 86inputs .c_left , 87inputs .c_right , 88inputs .c_down , 89inputs .c_up , 90ANALOG_STICK_MIN , 91ANALOG_STICK_NEUTRAL , 92ANALOG_STICK_MAX , 93outputs ); 94 } 95}