fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
0098001
gram
1#include "modes/Melee20Button.hpp" 2 3//legacy 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 = 6375 3750 = 51 30 117 outputs.leftStickX = 128 + (directions.x * 51); 118 outputs.leftStickY = 128 + (directions.y * 30); 119 } else { 120 // Extended angle to have magnitude similarity for DI 121 // 8500 5125 - 31.09 deg - 68 41 122 outputs.leftStickX = 128 + (directions.x * 68); 123 outputs.leftStickY = 128 + (directions.y * 41); 124 } 125 } 126 } 127 128 /* Up B angles */ 129 if (directions.diagonal && !shield_button_pressed) { 130 if (!inputs.rf1) { 131 // 7250 3125 - 23.32deg - 58 25 - modX 132 // 7000 3625 - 27.38deg - 56 29 - modX + cDown 133 // 6625 4125 - 31.91deg - 53 33 - modX + cLeft 134 // 6375 4625 - 35.96deg - 51 37 - modX + cUp 135 // 6125 5125 - 39.92deg - 49 41 - modX + cRight 136 outputs.leftStickX = 128 + (directions.x * 58); 137 outputs.leftStickY = 128 + (directions.y * 25); 138 if (inputs.rt2) { 139 outputs.leftStickX = 128 + (directions.x * 56); 140 outputs.leftStickY = 128 + (directions.y * 29); 141 } 142 if (inputs.rt3) { 143 outputs.leftStickX = 128 + (directions.x * 53); 144 outputs.leftStickY = 128 + (directions.y * 33); 145 } 146 if (inputs.rt4) { 147 outputs.leftStickX = 128 + (directions.x * 51); 148 outputs.leftStickY = 128 + (directions.y * 37); 149 } 150 if (inputs.rt5) { 151 outputs.leftStickX = 128 + (directions.x * 49); 152 outputs.leftStickY = 128 + (directions.y * 41); 153 } 154 } else { 155 /* Extended Up B Angles */ 156 // 9125 3875 - 23.01deg - 73 31 - modX + B 157 // 8750 4500 - 27.22deg - 70 36 - modX + B + cDown 158 // 8500 5250 - 31.70deg - 68 42 - modX + B + cLeft 159 // 7250 5250 - 35.91deg - 58 42 - modX + B + cUp 160 // 6375 5250 - 39.47deg - 51 42 - modX + B + cRight 161 outputs.leftStickX = 128 + (directions.x * 73); 162 outputs.leftStickY = 128 + (directions.y * 31); 163 if (inputs.rt2) { 164 outputs.leftStickX = 128 + (directions.x * 70); 165 outputs.leftStickY = 128 + (directions.y * 36); 166 } 167 if (inputs.rt3) { 168 outputs.leftStickX = 128 + (directions.x * 68); 169 outputs.leftStickY = 128 + (directions.y * 42); 170 } 171 if (inputs.rt4) { 172 outputs.leftStickX = 128 + (directions.x * 58); 173 outputs.leftStickY = 128 + (directions.y * 42); 174 } 175 if (inputs.rt5) { 176 outputs.leftStickX = 128 + (directions.x * 51); 177 outputs.leftStickY = 128 + (directions.y * 42); 178 } 179 } 180 } 181 182 // Angled fsmash 183 if (directions.cx != 0) { 184 // 8500 5250 = 68 42 185 outputs.rightStickX = 128 + (directions.cx * 68); 186 outputs.rightStickY = 128 + (directions.y * 42); 187 } 188 } 189 190 /* Mod Y */ 191 if (inputs.lt2) { 192 // MY + Horizontal (even if shield is held) = 3375 = 27 193 if (directions.horizontal) { 194 outputs.leftStickX = 128 + (directions.x * 27); 195 } 196 // MY + Vertical (even if shield is held) = 7375 = 59 197 if (directions.vertical) { 198 outputs.leftStickY = 128 + (directions.y * 59); 199 } 200 if (directions.diagonal && shield_button_pressed) { 201 // MY + L, R, LS, and MS + q1/2 = 4750 8750 = 38 70 202 outputs.leftStickX = 128 + (directions.x * 38); 203 outputs.leftStickY = 128 + (directions.y * 70); 204 // MY + L, R, LS, and MS + q3/4 = 5000 8500 = 40 68 205 if (directions.y == -1) { 206 outputs.leftStickX = 128 + (directions.x * 40); 207 outputs.leftStickY = 128 + (directions.y * 68); 208 } 209 } 210 211 // Turnaround neutral B nerf 212 if (inputs.rf1) { 213 outputs.leftStickX = 128 + (directions.x * 80); 214 } 215 216 /* Up B angles */ 217 if (directions.diagonal && !shield_button_pressed) { 218 if (!inputs.rf1) { 219 // 3250 7625 - 23.09deg - 26 61 - modY 220 // 3625 7000 - 27.38deg - 29 56 - modY + cDown 221 // 4500 6875 - 33.21deg - 36 55 - modY + cLeft (this is shield drop straight down but the cstick will buffer) 222 // 5125 7000 - 36.21deg - 41 56 - modY + cUp 223 // 5750 7125 - 38.90deg - 46 57 - modY + cRight 224 outputs.leftStickX = 128 + (directions.x * 26); 225 outputs.leftStickY = 128 + (directions.y * 61); 226 if (inputs.rt2) { 227 outputs.leftStickX = 128 + (directions.x * 29); 228 outputs.leftStickY = 128 + (directions.y * 56); 229 } 230 if (inputs.rt3) { 231 //outputs.leftStickX = 128 + (directions.x * 35); 232 //outputs.leftStickY = 128 + (directions.y * 56); 233 outputs.leftStickX = 128 + (directions.x * 36); 234 outputs.leftStickY = 128 + (directions.y * 55); 235 } 236 if (inputs.rt4) { 237 outputs.leftStickX = 128 + (directions.x * 41); 238 outputs.leftStickY = 128 + (directions.y * 56); 239 } 240 if (inputs.rt5) { 241 outputs.leftStickX = 128 + (directions.x * 46); 242 outputs.leftStickY = 128 + (directions.y * 57); 243 } 244 } else { 245 /* Extended Up B Angles */ 246 // 3875 9125 - 23.01deg - 31 73 - modY + B 247 // 4625 8750 - 27.86deg - 37 70 - modY + B + cDown 248 // 5375 8250 - 33.08deg - 42 68 - modY + B + cLeft 249 // 5750 7875 - 36.14deg - 46 63 - modY + B + cUp 250 // 5750 7125 - 38.90deg - 46 57 - modY + B + cRight 251 outputs.leftStickX = 128 + (directions.x * 31); 252 outputs.leftStickY = 128 + (directions.y * 73); 253 if (inputs.rt2) { 254 outputs.leftStickX = 128 + (directions.x * 37); 255 outputs.leftStickY = 128 + (directions.y * 70); 256 } 257 if (inputs.rt3) { 258 outputs.leftStickX = 128 + (directions.x * 43); 259 outputs.leftStickY = 128 + (directions.y * 66); 260 } 261 if (inputs.rt4) { 262 outputs.leftStickX = 128 + (directions.x * 46); 263 outputs.leftStickY = 128 + (directions.y * 63); 264 } 265 if (inputs.rt5) { 266 outputs.leftStickX = 128 + (directions.x * 46); 267 outputs.leftStickY = 128 + (directions.y * 57); 268 } 269 } 270 } 271 } 272 273 // C-stick ASDI Slideoff angle overrides any other C-stick modifiers (such as 274 // angled fsmash). 275 if (directions.cx != 0 && directions.cy != 0) { 276 // 5250 8500 = 42 68 277 outputs.rightStickX = 128 + (directions.cx * 42); 278 outputs.rightStickY = 128 + (directions.cy * 68); 279 } 280 281 /* 282 // Horizontal SOCD overrides X-axis modifiers (for ledgedash maximum jump 283 // trajectory). 284 if (!_options.disable_ledgedash_socd_override && _horizontal_socd && !directions.vertical) { 285 outputs.leftStickX = 128 + (directions.x * 80); 286 } 287 */ 288 289 if (inputs.rf7) { 290 outputs.triggerRAnalog = 49; 291 } 292 if (inputs.rf8) { 293 outputs.triggerRAnalog = 94; 294 } 295 296 if (outputs.triggerLDigital) { 297 outputs.triggerLAnalog = 140; 298 } 299 if (outputs.triggerRDigital) { 300 outputs.triggerRAnalog = 140; 301 } 302 303 // Shut off C-stick when using D-Pad layer. 304 if ((inputs.lt1 && inputs.lt2) || inputs.nunchuk_c) { 305 outputs.rightStickX = 128; 306 outputs.rightStickY = 128; 307 } 308 309 /* 310 // Nunchuk overrides left stick. 311 if (inputs.nunchuk_connected) { 312 outputs.leftStickX = inputs.nunchuk_x; 313 outputs.leftStickY = inputs.nunchuk_y; 314 } 315 */ 316}