fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
007edc4
v0.1.0
1#include "modes/FgcMode.hpp" 2 3#define ANALOG_STICK_MIN 0 4#define ANALOG_STICK_NEUTRAL 128 5#define ANALOG_STICK_MAX 255 6 7FgcMode ::FgcMode (socd::SocdType horizontal_socd , socd::SocdType vertical_socd ) { 8_socd_pair_count = 6 ; 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 ::down ,& InputState ::mod_x ,vertical_socd }, 18 socd::SocdPair {& InputState ::down ,& InputState ::up2 ,vertical_socd }, 19 socd::SocdPair {& InputState ::down ,& InputState ::c_up ,vertical_socd }, 20 }; 21} 22 23void FgcMode ::UpdateDigitalOutputs (InputState & inputs ,OutputState & outputs ) { 24// Directions 25outputs .dpadLeft = inputs .left ; 26outputs .dpadRight = inputs .right ; 27outputs .dpadDown = inputs .down ; 28outputs .dpadUp = inputs .mod_x || inputs .up2 || inputs .c_up ; 29 30// L3 & R3 31outputs .leftStickClick = inputs .l || inputs .c_left ; 32outputs .rightStickClick = inputs .a ; 33 34// Menu keys 35outputs .start = inputs .start ; 36outputs .select = inputs .select ; 37outputs .home = inputs .home ; 38 39// Activate select/home by holding Mod Y 40if ((inputs .mod_y )) { 41outputs .select = inputs .midshield ; 42outputs .home = inputs .start ; 43 } 44 45// Right hand bottom row 46outputs .a = inputs .b ; 47outputs .b = inputs .x ; 48outputs .triggerRDigital = inputs .z ; 49outputs .triggerLDigital = inputs .up ; 50 51// Right hand top row 52outputs .x = inputs .r ; 53outputs .y = inputs .y ; 54outputs .buttonR = inputs .lightshield ; 55outputs .buttonL = inputs .midshield ; 56 57// Turns off Start / LB when holding Mod Y 58if ((inputs .mod_y )) { 59outputs .start = false; 60outputs .buttonL = false; 61// Turn off DPad 62outputs .dpadLeft = false; 63outputs .dpadRight = false; 64outputs .dpadDown = false; 65outputs .dpadUp = false; 66outputs .leftStickClick = false; 67 } 68} 69 70void FgcMode ::UpdateAnalogOutputs (InputState & inputs ,OutputState & outputs ) { 71outputs .leftStickX = 128 ; 72outputs .leftStickY = 128 ; 73outputs .rightStickX = 128 ; 74outputs .rightStickY = 128 ; 75outputs .triggerLAnalog = outputs .triggerLDigital ?255 :0 ; 76outputs .triggerRAnalog = outputs .triggerRDigital ?255 :0 ; 77 78//Hold Mod Y to use analog input. 79if ((inputs .mod_y )) { 80UpdateDirections ( 81inputs .left , 82inputs .right , 83inputs .down , 84inputs .up2 , 85inputs .c_left , 86inputs .c_right , 87inputs .c_down , 88inputs .c_up , 89ANALOG_STICK_MIN , 90ANALOG_STICK_NEUTRAL , 91ANALOG_STICK_MAX , 92outputs ); 93 } 94}