fork/GramFirmware

git clone https://git.julia.blue/fork/GramFirmware

CarVacrebase to configurator818d962

gram
4.9 KiB156 linesraw
1#include "modes/RivalsOfAether.hpp"
2
3#define ANALOG_STICK_MIN 28
4#define ANALOG_STICK_NEUTRAL 128
5#define ANALOG_STICK_MAX 228
6
7RivalsOfAether::RivalsOfAether() : ControllerMode() {}
8
9void RivalsOfAether::UpdateDigitalOutputs(const InputState &inputs, OutputState &outputs) {
10    outputs.a = inputs.rt1;
11    outputs.b = inputs.rf1;
12    outputs.x = inputs.rf2;
13    outputs.y = inputs.rf6;
14    outputs.buttonR = inputs.rf3;
15    if (inputs.nunchuk_connected) {
16        // Lightshield with C button.
17        if (inputs.nunchuk_c) {
18            outputs.triggerLAnalog = 49;
19        }
20        outputs.triggerLDigital = inputs.nunchuk_z;
21    } else {
22        outputs.triggerLDigital = inputs.lf4;
23    }
24    outputs.triggerRDigital = inputs.rf5;
25    outputs.start = inputs.mb1;
26    outputs.select = inputs.mb3;
27    outputs.home = inputs.mb2;
28    outputs.leftStickClick = inputs.rf7;
29    outputs.rightStickClick = inputs.rf8;
30
31    // Activate D-Pad layer by holding Mod X + Mod Y.
32    if (inputs.lt1 && inputs.lt2) {
33        outputs.dpadUp = inputs.rt4;
34        outputs.dpadDown = inputs.rt2;
35        outputs.dpadLeft = inputs.rt3;
36        outputs.dpadRight = inputs.rt5;
37    }
38}
39
40void RivalsOfAether::UpdateAnalogOutputs(const InputState &inputs, OutputState &outputs) {
41    // Coordinate calculations to make modifier handling simpler.
42    UpdateDirections(
43        inputs.lf3, // Left
44        inputs.lf1, // Right
45        inputs.lf2, // Down
46        inputs.rf4, // Up
47        inputs.rt3, // C-Left
48        inputs.rt5, // C-Right
49        inputs.rt2, // C-Down
50        inputs.rt4, // C-Up
51        ANALOG_STICK_MIN,
52        ANALOG_STICK_NEUTRAL,
53        ANALOG_STICK_MAX,
54        outputs
55    );
56
57    bool shield_button_pressed = inputs.lf4 || inputs.rf5;
58
59    // 48 total DI angles, 24 total Up b angles, 16 total airdodge angles
60
61    if (inputs.lt1) {
62        if (directions.horizontal) {
63            outputs.leftStickX = 128 + (directions.x * 66);
64            // MX Horizontal Tilts
65            if (inputs.rt1) {
66                outputs.leftStickX = 128 + (directions.x * 44);
67            }
68        }
69
70        if(directions.vertical) {
71            outputs.leftStickY = 128 + (directions.y * 44);
72            // MX Vertical Tilts
73            if (inputs.rt1) {
74                outputs.leftStickY = 128 + (directions.y * 67);
75            }
76        }
77
78        /* Extra DI, Air Dodge, and Up B angles */
79        if (directions.diagonal) {
80            outputs.leftStickX = 128 + (directions.x * 59);
81            outputs.leftStickY = 128 + (directions.y * 23);
82
83            // Angles just for DI and Up B
84            if (inputs.rt2) {
85                outputs.leftStickX = 128 + (directions.x * 49);
86                outputs.leftStickY = 128 + (directions.y * 24);
87            }
88
89            // Angles just for DI
90            if (inputs.rt3) {
91                outputs.leftStickX = 128 + (directions.x * 52);
92                outputs.leftStickY = 128 + (directions.y * 31);
93            }
94
95            if (inputs.rt4) {
96                outputs.leftStickX = 128 + (directions.x * 49);
97                outputs.leftStickY = 128 + (directions.y * 35);
98            }
99
100            if (inputs.rt5) {
101                outputs.leftStickX = 128 + (directions.x * 51);
102                outputs.leftStickY = 128 + (directions.y * 43);
103            }
104        }
105    }
106
107    if (inputs.lt2) {
108        if (directions.horizontal) {
109            outputs.leftStickX = 128 + (directions.x * 44);
110        }
111
112        if(directions.vertical) {
113            outputs.leftStickY = 128 + (directions.y * 67);
114        }
115
116        /* Extra DI, Air Dodge, and Up B angles */
117        if (directions.diagonal) {
118            outputs.leftStickX = 128 + (directions.x * 44);
119            outputs.leftStickY = 128 + (directions.y * 113);
120
121            // Angles just for DI and Up B
122            if (inputs.rt2) {
123                outputs.leftStickX = 128 + (directions.x * 44);
124                outputs.leftStickY = 128 + (directions.y * 90);
125            }
126
127            // Angles just for DI
128            if (inputs.rt3) {
129                outputs.leftStickX = 128 + (directions.x * 44);
130                outputs.leftStickY = 128 + (directions.y * 74);
131            }
132
133            if (inputs.rt4) {
134                outputs.leftStickX = 128 + (directions.x * 45);
135                outputs.leftStickY = 128 + (directions.y * 63);
136            }
137
138            if (inputs.rt5) {
139                outputs.leftStickX = 128 + (directions.x * 47);
140                outputs.leftStickY = 128 + (directions.y * 57);
141            }
142        }
143    }
144
145    // Shut off C-stick when using D-Pad layer.
146    if (inputs.lt1 && inputs.lt2) {
147        outputs.rightStickX = 128;
148        outputs.rightStickY = 128;
149    }
150
151    // Nunchuk overrides left stick.
152    if (inputs.nunchuk_connected) {
153        outputs.leftStickX = inputs.nunchuk_x;
154        outputs.leftStickY = inputs.nunchuk_y;
155    }
156}