fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
0098001
gram
1#include "modes/Melee20Button.hpp" 2 3//wider wavedash angle 4 5#define ANALOG_STICK_MIN (128-112) 6#define ANALOG_STICK_NEUTRAL 128 7#define ANALOG_STICK_MAX (128+112) 8 9Melee20Button::Melee20Button() : ControllerMode() { 10} 11 12void Melee20Button::SetConfig(GameModeConfig &config, const MeleeOptions options) { 13 InputMode::SetConfig(config); 14 _options = options; 15} 16 17void Melee20Button::HandleSocd(InputState &inputs) { 18 //force neutral socd 19 if (inputs.lf3 && inputs.lf1) { 20 inputs.lf3 = false; 21 inputs.lf1 = false; 22 } 23 if (inputs.lf2 && inputs.rf4) { 24 inputs.lf2 = false; 25 inputs.rf4 = false; 26 } 27 if (inputs.rt3 && inputs.rt5) { 28 inputs.rt3 = false; 29 inputs.rt5 = false; 30 } 31 if (inputs.rt2 && inputs.rt4) { 32 inputs.rt2 = false; 33 inputs.rt4 = false; 34 } 35 InputMode::HandleSocd(inputs); 36} 37 38void Melee20Button::UpdateDigitalOutputs(const InputState &inputs, OutputState &outputs) { 39 outputs.a = inputs.rt1; 40 outputs.b = inputs.rf1; 41 outputs.x = inputs.rf2; 42 outputs.y = inputs.rf6; 43 outputs.buttonR = inputs.rf3; 44 if (inputs.nunchuk_connected) { 45 outputs.triggerLDigital = inputs.nunchuk_z; 46 } else { 47 outputs.triggerLDigital = inputs.lf4; 48 } 49 outputs.triggerRDigital = inputs.rf5; 50 outputs.start = inputs.mb1; 51 52 // Activate D-Pad layer by holding Mod X + Mod Y or Nunchuk C button. 53 if ((inputs.lt1 && inputs.lt2) || inputs.nunchuk_c) { 54 outputs.dpadUp = inputs.rt4; 55 outputs.dpadDown = inputs.rt2; 56 outputs.dpadLeft = inputs.rt3; 57 outputs.dpadRight = inputs.rt5; 58 } 59 60 if (inputs.mb3) 61 outputs.dpadLeft = true; 62 if (inputs.mb2) 63 outputs.dpadRight = true; 64} 65 66void Melee20Button::UpdateAnalogOutputs(const InputState &inputs, OutputState &outputs) { 67 // Coordinate calculations to make modifier handling simpler. 68 UpdateDirections( 69 inputs.lf3, // Left 70 inputs.lf1, // Right 71 inputs.lf2, // Down 72 inputs.rf4, // Up 73 inputs.rt3, // C-Left 74 inputs.rt5, // C-Right 75 inputs.rt2, // C-Down 76 inputs.rt4, // C-Up 77 ANALOG_STICK_MIN, 78 ANALOG_STICK_NEUTRAL, 79 ANALOG_STICK_MAX, 80 outputs 81 ); 82 83 const bool shield_button_pressed = inputs.lf4 || inputs.rf5 || inputs.rf7 || inputs.rf8; 84 if (directions.diagonal) { 85 // q1/2 = 7000 7000 86 outputs.leftStickX = 128 + (directions.x * 56); 87 outputs.leftStickY = 128 + (directions.y * 61); 88 // L, R, LS, and MS + q3/4 = 7000 6875 (For vanilla shield drop. Gives 44.5 89 // degree wavedash). Also used as default q3/4 diagonal if crouch walk option select is 90 // enabled. 91 if (directions.y == -1 && (shield_button_pressed || _options.crouch_walk_os)) { 92 outputs.leftStickX = 128 + (directions.x * 61); 93 outputs.leftStickY = 128 + (directions.y * 56); 94 } 95 } 96 97 /* Mod X */ 98 if (inputs.lt1) { 99 // MX + Horizontal (even if shield is held) = 6625 = 53 100 if (directions.horizontal) { 101 outputs.leftStickX = 128 + (directions.x * 53); 102 } 103 // MX + Vertical (even if shield is held) = 5375 = 43 104 // y=-0.5500 (44) is solo nana ice block, so we reduce this by one 105 // MX + Vertical (even if shield is held) = 5250 = 42 106 if (directions.vertical) { 107 outputs.leftStickY = 128 + (directions.y * 42); 108 } 109 if (directions.diagonal && shield_button_pressed) { 110 // Use custom airdodge angle if set, otherwise B0XX standard default. 111 if (_options.has_custom_airdodge) { 112 outputs.leftStickX = 128 + (directions.x * _options.custom_airdodge.x); 113 outputs.leftStickY = 128 + (directions.y * _options.custom_airdodge.y); 114 } else { 115 if (!inputs.rf1) { 116 // MX + L, R, LS, and MS + q1/2/3/4 = 117 // 6375 3750 - 24.84 deg - 54 25 (will be overridden for LR digital) 118 outputs.leftStickX = 128 + (directions.x * 54); 119 outputs.leftStickY = 128 + (directions.y * 25); 120 } else { 121 // Extended angle to have magnitude similarity for DI 122 // 9000 4250 - 25.28 deg - 72 34 (will be overridden for LR digital but remain rim) 123 outputs.leftStickX = 128 + (directions.x * 72); 124 outputs.leftStickY = 128 + (directions.y * 34); 125 } 126 } 127 } 128 129 /* Up B angles */ 130 if (directions.diagonal && !shield_button_pressed) { 131 if (!inputs.rf1) { 132 // 7250 3125 - 23.32deg - 58 25 - modX 133 // 7000 3625 - 27.38deg - 56 29 - modX + cDown 134 // 6625 4125 - 31.91deg - 53 33 - modX + cLeft 135 // 6375 4625 - 35.96deg - 51 37 - modX + cUp 136 // 6125 5125 - 39.92deg - 49 41 - modX + cRight 137 outputs.leftStickX = 128 + (directions.x * 58); 138 outputs.leftStickY = 128 + (directions.y * 25); 139 if (inputs.rt2) { 140 outputs.leftStickX = 128 + (directions.x * 56); 141 outputs.leftStickY = 128 + (directions.y * 29); 142 } 143 if (inputs.rt3) { 144 outputs.leftStickX = 128 + (directions.x * 53); 145 outputs.leftStickY = 128 + (directions.y * 33); 146 } 147 if (inputs.rt4) { 148 outputs.leftStickX = 128 + (directions.x * 51); 149 outputs.leftStickY = 128 + (directions.y * 37); 150 } 151 if (inputs.rt5) { 152 outputs.leftStickX = 128 + (directions.x * 49); 153 outputs.leftStickY = 128 + (directions.y * 41); 154 } 155 } else { 156 /* Extended Up B Angles */ 157 // 9125 3875 - 23.01deg - 73 31 - modX + B 158 // 8750 4500 - 27.22deg - 70 36 - modX + B + cDown 159 // 8500 5250 - 31.70deg - 68 42 - modX + B + cLeft 160 // 7250 5250 - 35.91deg - 58 42 - modX + B + cUp 161 // 6375 5250 - 39.47deg - 51 42 - modX + B + cRight 162 outputs.leftStickX = 128 + (directions.x * 73); 163 outputs.leftStickY = 128 + (directions.y * 31); 164 if (inputs.rt2) { 165 outputs.leftStickX = 128 + (directions.x * 70); 166 outputs.leftStickY = 128 + (directions.y * 36); 167 } 168 if (inputs.rt3) { 169 outputs.leftStickX = 128 + (directions.x * 68); 170 outputs.leftStickY = 128 + (directions.y * 42); 171 } 172 if (inputs.rt4) { 173 outputs.leftStickX = 128 + (directions.x * 58); 174 outputs.leftStickY = 128 + (directions.y * 42); 175 } 176 if (inputs.rt5) { 177 outputs.leftStickX = 128 + (directions.x * 51); 178 outputs.leftStickY = 128 + (directions.y * 42); 179 } 180 } 181 } 182 183 // Angled fsmash 184 if (directions.cx != 0) { 185 // 8500 5250 = 68 42 186 outputs.rightStickX = 128 + (directions.cx * 68); 187 outputs.rightStickY = 128 + (directions.y * 42); 188 } 189 } 190 191 /* Mod Y */ 192 if (inputs.lt2) { 193 // MY + Horizontal (even if shield is held) = 3375 = 27 194 if (directions.horizontal) { 195 outputs.leftStickX = 128 + (directions.x * 27); 196 } 197 // MY + Vertical (even if shield is held) = 7375 = 59 198 if (directions.vertical) { 199 outputs.leftStickY = 128 + (directions.y * 59); 200 } 201 if (directions.diagonal && shield_button_pressed) { 202 // MY + L, R, LS, and MS + q1/2 = 4750 8750 = 38 70 203 outputs.leftStickX = 128 + (directions.x * 38); 204 outputs.leftStickY = 128 + (directions.y * 70); 205 // MY + L, R, LS, and MS + q3/4 = 5000 8500 = 40 68 206 if (directions.y == -1) { 207 outputs.leftStickX = 128 + (directions.x * 40); 208 outputs.leftStickY = 128 + (directions.y * 68); 209 } 210 } 211 212 // Turnaround neutral B nerf 213 if (inputs.rf1) { 214 outputs.leftStickX = 128 + (directions.x * 80); 215 } 216 217 /* Up B angles */ 218 if (directions.diagonal && !shield_button_pressed) { 219 if (!inputs.rf1) { 220 // 3250 7625 - 23.09deg - 26 61 - modY 221 // 3625 7000 - 27.38deg - 29 56 - modY + cDown 222 // 4500 6875 - 33.21deg - 36 55 - modY + cLeft (this is shield drop straight down but the cstick will buffer) 223 // 5125 7000 - 36.21deg - 41 56 - modY + cUp 224 // 5750 7125 - 38.90deg - 46 57 - modY + cRight 225 outputs.leftStickX = 128 + (directions.x * 26); 226 outputs.leftStickY = 128 + (directions.y * 61); 227 if (inputs.rt2) { 228 outputs.leftStickX = 128 + (directions.x * 29); 229 outputs.leftStickY = 128 + (directions.y * 56); 230 } 231 if (inputs.rt3) { 232 //outputs.leftStickX = 128 + (directions.x * 35); 233 //outputs.leftStickY = 128 + (directions.y * 56); 234 outputs.leftStickX = 128 + (directions.x * 36); 235 outputs.leftStickY = 128 + (directions.y * 55); 236 } 237 if (inputs.rt4) { 238 outputs.leftStickX = 128 + (directions.x * 41); 239 outputs.leftStickY = 128 + (directions.y * 56); 240 } 241 if (inputs.rt5) { 242 outputs.leftStickX = 128 + (directions.x * 46); 243 outputs.leftStickY = 128 + (directions.y * 57); 244 } 245 } else { 246 /* Extended Up B Angles */ 247 // 3875 9125 - 23.01deg - 31 73 - modY + B 248 // 4625 8750 - 27.86deg - 37 70 - modY + B + cDown 249 // 5375 8250 - 33.08deg - 42 68 - modY + B + cLeft 250 // 5750 7875 - 36.14deg - 46 63 - modY + B + cUp 251 // 5750 7125 - 38.90deg - 46 57 - modY + B + cRight 252 outputs.leftStickX = 128 + (directions.x * 31); 253 outputs.leftStickY = 128 + (directions.y * 73); 254 if (inputs.rt2) { 255 outputs.leftStickX = 128 + (directions.x * 37); 256 outputs.leftStickY = 128 + (directions.y * 70); 257 } 258 if (inputs.rt3) { 259 outputs.leftStickX = 128 + (directions.x * 43); 260 outputs.leftStickY = 128 + (directions.y * 66); 261 } 262 if (inputs.rt4) { 263 outputs.leftStickX = 128 + (directions.x * 46); 264 outputs.leftStickY = 128 + (directions.y * 63); 265 } 266 if (inputs.rt5) { 267 outputs.leftStickX = 128 + (directions.x * 46); 268 outputs.leftStickY = 128 + (directions.y * 57); 269 } 270 } 271 } 272 } 273 274 // C-stick ASDI Slideoff angle overrides any other C-stick modifiers (such as 275 // angled fsmash). 276 if (directions.cx != 0 && directions.cy != 0) { 277 // 5250 8500 = 42 68 278 outputs.rightStickX = 128 + (directions.cx * 42); 279 outputs.rightStickY = 128 + (directions.cy * 68); 280 } 281 282 /* 283 // Horizontal SOCD overrides X-axis modifiers (for ledgedash maximum jump 284 // trajectory). 285 if (!_options.disable_ledgedash_socd_override && _horizontal_socd && !directions.vertical) { 286 outputs.leftStickX = 128 + (directions.x * 80); 287 } 288 */ 289 290 if (inputs.rf7) { 291 outputs.triggerRAnalog = 49; 292 } 293 if (inputs.rf8) { 294 outputs.triggerRAnalog = 94; 295 } 296 297 if (outputs.triggerLDigital) { 298 outputs.triggerLAnalog = 140; 299 } 300 if (outputs.triggerRDigital) { 301 outputs.triggerRAnalog = 140; 302 } 303 304 // Shut off C-stick when using D-Pad layer. 305 if ((inputs.lt1 && inputs.lt2) || inputs.nunchuk_c) { 306 outputs.rightStickX = 128; 307 outputs.rightStickY = 128; 308 } 309 310 /* 311 // Nunchuk overrides left stick. 312 if (inputs.nunchuk_connected) { 313 outputs.leftStickX = inputs.nunchuk_x; 314 outputs.leftStickY = inputs.nunchuk_y; 315 } 316 */ 317}