fork/GramFirmware

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

Skywalker1127Added Up2 as taunt togglea4cb19b

v0.1.1
5.4 KiB165 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(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::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
17void RivalsOfAether::UpdateDigitalOutputs(InputState &inputs, OutputState &outputs) {
18    outputs.a = inputs.a;
19    outputs.b = inputs.b;
20    outputs.x = inputs.x;
21    outputs.y = inputs.y;
22    outputs.buttonR = inputs.z;
23    if (inputs.nunchuk_connected) {
24        // Lightshield with C button.
25        if (inputs.nunchuk_c) {
26            outputs.triggerLAnalog = 49;
27        }
28        outputs.triggerLDigital = inputs.nunchuk_z;
29    } else {
30        outputs.triggerLDigital = inputs.l;
31    }
32    outputs.triggerRDigital = inputs.r;
33    outputs.start = inputs.start;
34    outputs.select = inputs.select;
35    outputs.home = inputs.home;
36    outputs.leftStickClick = inputs.lightshield;
37    outputs.rightStickClick = inputs.midshield;
38
39    // Activate D-Pad layer by holding Mod X + Mod Y.
40    if (inputs.mod_x && inputs.mod_y || inputs.up2) {
41        outputs.dpadUp = inputs.c_up;
42        outputs.dpadDown = inputs.c_down;
43        outputs.dpadLeft = inputs.c_left;
44        outputs.dpadRight = inputs.c_right;
45    }
46}
47
48void RivalsOfAether::UpdateAnalogOutputs(InputState &inputs, OutputState &outputs) {
49    // Coordinate calculations to make modifier handling simpler.
50    UpdateDirections(
51        inputs.left,
52        inputs.right,
53        inputs.down,
54        inputs.up,
55        inputs.c_left,
56        inputs.c_right,
57        inputs.c_down,
58        inputs.c_up,
59        ANALOG_STICK_MIN,
60        ANALOG_STICK_NEUTRAL,
61        ANALOG_STICK_MAX,
62        outputs
63    );
64
65    bool shield_button_pressed = inputs.l || inputs.r;
66
67
68    // 48 total DI angles, 24 total Up b angles, 16 total airdodge angles
69
70    if (inputs.mod_x) {
71        if (directions.horizontal) {
72            outputs.leftStickX = 128 + (directions.x * 66);
73            // MX Horizontal Tilts
74            if (inputs.a) {
75                outputs.leftStickX = 128 + (directions.x * 44);
76            }
77        }
78
79        if(directions.vertical) {
80            outputs.leftStickY = 128 + (directions.y * 44);
81            // MX Vertical Tilts
82            if (inputs.a) {
83                outputs.leftStickY = 128 + (directions.y * 67);
84            }
85        }
86
87        /* Extra DI, Air Dodge, and Up B angles */
88        if (directions.diagonal) {
89            outputs.leftStickX = 128 + (directions.x * 59);
90            outputs.leftStickY = 128 + (directions.y * 23);
91
92            // Angles just for DI and Up B
93            if (inputs.c_down) {
94                outputs.leftStickX = 128 + (directions.x * 49);
95                outputs.leftStickY = 128 + (directions.y * 24);
96            }
97
98            // Angles just for DI
99            if (inputs.c_left) {
100                outputs.leftStickX = 128 + (directions.x * 52);
101                outputs.leftStickY = 128 + (directions.y * 31);
102            }
103      
104            if (inputs.c_up) {
105                outputs.leftStickX = 128 + (directions.x * 49);
106                outputs.leftStickY = 128 + (directions.y * 35);
107            }
108     
109            if (inputs.c_right) {
110                outputs.leftStickX = 128 + (directions.x * 51);
111                outputs.leftStickY = 128 + (directions.y * 43);
112            }
113        }
114    }
115
116    if (inputs.mod_y) {
117        if (directions.horizontal) {
118            outputs.leftStickX = 128 + (directions.x * 44);
119        }
120
121        if(directions.vertical) {
122            outputs.leftStickY = 128 + (directions.y * 67);
123        }
124
125        /* Extra DI, Air Dodge, and Up B angles */
126        if (directions.diagonal) {
127            outputs.leftStickX = 128 + (directions.x * 44);
128            outputs.leftStickY = 128 + (directions.y * 113);
129
130            // Angles just for DI and Up B
131            if (inputs.c_down) {
132                outputs.leftStickX = 128 + (directions.x * 44);
133                outputs.leftStickY = 128 + (directions.y * 90);
134            }
135
136            // Angles just for DI
137            if (inputs.c_left) {
138                outputs.leftStickX = 128 + (directions.x * 44);
139                outputs.leftStickY = 128 + (directions.y * 74);
140            }
141      
142            if (inputs.c_up) {
143                outputs.leftStickX = 128 + (directions.x * 45);
144                outputs.leftStickY = 128 + (directions.y * 63);
145            }
146     
147            if (inputs.c_right) {
148                outputs.leftStickX = 128 + (directions.x * 47);
149                outputs.leftStickY = 128 + (directions.y * 57);
150            }
151        }
152    }
153
154    // Shut off C-stick when using D-Pad layer.
155    if (inputs.mod_x && inputs.mod_y || inputs.up2) {
156        outputs.rightStickX = 128;
157        outputs.rightStickY = 128;
158    }
159
160    // Nunchuk overrides left stick.
161    if (inputs.nunchuk_connected) {
162        outputs.leftStickX = inputs.nunchuk_x;
163        outputs.leftStickY = inputs.nunchuk_y;
164    }
165}