| 1 | #include "Library/Controller/InputFunction.h" |
| 2 | |
| 3 | #include <controller/seadControllerMgr.h> |
| 4 | |
| 5 | #include "Library/Controller/PadReplayFunction.h" |
| 6 | #include "Library/Controller/ReplayController.h" |
| 7 | |
| 8 | namespace al { |
| 9 | |
| 10 | inline sead::ControllerBase* getController(s32 port) { |
| 11 | if (port == -1) |
| 12 | port = getMainControllerPort(); |
| 13 | |
| 14 | if (isValidReplayController(port)) |
| 15 | return getReplayController(port); |
| 16 | |
| 17 | return sead::ControllerMgr::instance()->getController(port); |
| 18 | } |
| 19 | |
| 20 | bool isPadTrigger(s32 port, s32 button) { |
| 21 | return getController(port)->isTrig(mask: button); |
| 22 | } |
| 23 | |
| 24 | bool isPadTriggerA(s32 port) { |
| 25 | return isPadTrigger(port, button: 1); |
| 26 | } |
| 27 | |
| 28 | bool isPadTriggerB(s32 port) { |
| 29 | return isPadTrigger(port, button: 1 << 1); |
| 30 | } |
| 31 | |
| 32 | bool isPadTriggerX(s32 port) { |
| 33 | return isPadTrigger(port, button: 1 << 3); |
| 34 | } |
| 35 | |
| 36 | bool isPadTriggerY(s32 port) { |
| 37 | return isPadTrigger(port, button: 1 << 4); |
| 38 | } |
| 39 | |
| 40 | bool isPadTriggerZL(s32 port) { |
| 41 | return isPadTrigger(port, button: 1 << 2); |
| 42 | } |
| 43 | |
| 44 | bool isPadTriggerZR(s32 port) { |
| 45 | return isPadTrigger(port, button: 1 << 5); |
| 46 | } |
| 47 | |
| 48 | bool isPadTriggerL(s32 port) { |
| 49 | return isPadTrigger(port, button: 1 << 13); |
| 50 | } |
| 51 | |
| 52 | bool isPadTriggerR(s32 port) { |
| 53 | return isPadTrigger(port, button: 1 << 14); |
| 54 | } |
| 55 | |
| 56 | bool isPadTrigger1(s32 port) { |
| 57 | return isPadTrigger(port, button: 1 << 7); |
| 58 | } |
| 59 | |
| 60 | bool isPadTrigger2(s32 port) { |
| 61 | return isPadTrigger(port, button: 1 << 6); |
| 62 | } |
| 63 | |
| 64 | bool isPadTriggerUp(s32 port) { |
| 65 | return isPadTrigger(port, button: 1 << 16); |
| 66 | } |
| 67 | |
| 68 | bool isPadTriggerDown(s32 port) { |
| 69 | return isPadTrigger(port, button: 1 << 17); |
| 70 | } |
| 71 | |
| 72 | bool isPadTriggerLeft(s32 port) { |
| 73 | return isPadTrigger(port, button: 1 << 18); |
| 74 | } |
| 75 | |
| 76 | bool isPadTriggerRight(s32 port) { |
| 77 | return isPadTrigger(port, button: 1 << 19); |
| 78 | } |
| 79 | |
| 80 | bool isPadTriggerLeftUp(s32 port) { |
| 81 | return isPadHoldLeftUp(port) && (getController(port)->isTrig(mask: 0x50000)); |
| 82 | } |
| 83 | |
| 84 | bool isPadTriggerLeftDown(s32 port) { |
| 85 | return isPadHoldLeftDown(port) && (getController(port)->isTrig(mask: 0x60000)); |
| 86 | } |
| 87 | |
| 88 | bool isPadTriggerRightUp(s32 port) { |
| 89 | return isPadHoldRightUp(port) && (getController(port)->isTrig(mask: 0x90000)); |
| 90 | } |
| 91 | |
| 92 | bool isPadTriggerRightDown(s32 port) { |
| 93 | return isPadHoldRightDown(port) && (getController(port)->isTrig(mask: 0xA0000)); |
| 94 | } |
| 95 | |
| 96 | bool isPadTriggerHome(s32 port) { |
| 97 | return isPadTrigger(port, button: 1 << 8); |
| 98 | } |
| 99 | |
| 100 | bool isPadTriggerStart(s32 port) { |
| 101 | return isPadTrigger(port, button: 1 << 11); |
| 102 | } |
| 103 | |
| 104 | bool isPadTriggerSelect(s32 port) { |
| 105 | return isPadTrigger(port, button: 1 << 12); |
| 106 | } |
| 107 | |
| 108 | bool isPadTriggerPlus(s32 port) { |
| 109 | return isPadTrigger(port, button: 1 << 10); |
| 110 | } |
| 111 | |
| 112 | bool isPadTriggerMinus(s32 port) { |
| 113 | return isPadTrigger(port, button: 1 << 9); |
| 114 | } |
| 115 | |
| 116 | bool isPadTriggerTouch() { |
| 117 | return isPadTrigger(port: getTouchPanelPort(), button: 1 << 15); |
| 118 | } |
| 119 | |
| 120 | bool isPadTriggerUpLeftStick(s32 port) { |
| 121 | return isPadTrigger(port, button: 1 << 20); |
| 122 | } |
| 123 | |
| 124 | bool isPadTriggerDownLeftStick(s32 port) { |
| 125 | return isPadTrigger(port, button: 1 << 21); |
| 126 | } |
| 127 | |
| 128 | bool isPadTriggerLeftLeftStick(s32 port) { |
| 129 | return isPadTrigger(port, button: 1 << 22); |
| 130 | } |
| 131 | |
| 132 | bool isPadTriggerRightLeftStick(s32 port) { |
| 133 | return isPadTrigger(port, button: 1 << 23); |
| 134 | } |
| 135 | |
| 136 | bool isPadTriggerUpRightStick(s32 port) { |
| 137 | return isPadTrigger(port, button: 1 << 24); |
| 138 | } |
| 139 | |
| 140 | bool isPadTriggerDownRightStick(s32 port) { |
| 141 | return isPadTrigger(port, button: 1 << 25); |
| 142 | } |
| 143 | |
| 144 | bool isPadTriggerLeftRightStick(s32 port) { |
| 145 | return isPadTrigger(port, button: 1 << 26); |
| 146 | } |
| 147 | |
| 148 | bool isPadTriggerRightRightStick(s32 port) { |
| 149 | return isPadTrigger(port, button: 1 << 27); |
| 150 | } |
| 151 | |
| 152 | bool isPadTriggerAnyABXY(s32 port) { |
| 153 | return isPadTriggerA(port) || isPadTriggerB(port) || isPadTriggerX(port) || isPadTriggerY(port); |
| 154 | } |
| 155 | |
| 156 | bool isPadTriggerAny(s32 port) { |
| 157 | return isPadTrigger(port, button: 0xFFF7FFF); |
| 158 | } |
| 159 | |
| 160 | bool isPadTriggerLeftStick(s32 port) { |
| 161 | return isPadTrigger(port, button: 0xF00000); |
| 162 | } |
| 163 | |
| 164 | bool isPadTriggerRightStick(s32 port) { |
| 165 | return isPadTrigger(port, button: 0xF000000); |
| 166 | } |
| 167 | |
| 168 | bool isPadTriggerPressLeftStick(s32 port) { |
| 169 | return isPadTrigger1(port); |
| 170 | } |
| 171 | |
| 172 | bool isPadTriggerPressRightStick(s32 port) { |
| 173 | return isPadTrigger2(port); |
| 174 | } |
| 175 | |
| 176 | inline bool isPadRepeat(s32 port, s32 button) { |
| 177 | return getController(port)->isTrigWithRepeat(mask: button); |
| 178 | } |
| 179 | |
| 180 | bool isPadRepeatA(s32 port) { |
| 181 | return isPadRepeat(port, button: 1); |
| 182 | } |
| 183 | |
| 184 | bool isPadRepeatB(s32 port) { |
| 185 | return isPadRepeat(port, button: 1 << 1); |
| 186 | } |
| 187 | |
| 188 | bool isPadRepeatX(s32 port) { |
| 189 | return isPadRepeat(port, button: 1 << 3); |
| 190 | } |
| 191 | |
| 192 | bool isPadRepeatY(s32 port) { |
| 193 | return isPadRepeat(port, button: 1 << 4); |
| 194 | } |
| 195 | |
| 196 | bool isPadRepeatZL(s32 port) { |
| 197 | return isPadRepeat(port, button: 1 << 2); |
| 198 | } |
| 199 | |
| 200 | bool isPadRepeatZR(s32 port) { |
| 201 | return isPadRepeat(port, button: 1 << 5); |
| 202 | } |
| 203 | |
| 204 | bool isPadRepeatL(s32 port) { |
| 205 | return isPadRepeat(port, button: 1 << 13); |
| 206 | } |
| 207 | |
| 208 | bool isPadRepeatR(s32 port) { |
| 209 | return isPadRepeat(port, button: 1 << 14); |
| 210 | } |
| 211 | |
| 212 | bool isPadRepeat1(s32 port) { |
| 213 | return isPadRepeat(port, button: 1 << 7); |
| 214 | } |
| 215 | |
| 216 | bool isPadRepeat2(s32 port) { |
| 217 | return isPadRepeat(port, button: 1 << 6); |
| 218 | } |
| 219 | |
| 220 | bool isPadRepeatUp(s32 port) { |
| 221 | return isPadRepeat(port, button: 1 << 16); |
| 222 | } |
| 223 | |
| 224 | bool isPadRepeatDown(s32 port) { |
| 225 | return isPadRepeat(port, button: 1 << 17); |
| 226 | } |
| 227 | |
| 228 | bool isPadRepeatLeft(s32 port) { |
| 229 | return isPadRepeat(port, button: 1 << 18); |
| 230 | } |
| 231 | |
| 232 | bool isPadRepeatRight(s32 port) { |
| 233 | return isPadRepeat(port, button: 1 << 19); |
| 234 | } |
| 235 | |
| 236 | bool isPadRepeatHome(s32 port) { |
| 237 | return isPadRepeat(port, button: 1 << 8); |
| 238 | } |
| 239 | |
| 240 | bool isPadRepeatStart(s32 port) { |
| 241 | return isPadRepeat(port, button: 1 << 11); |
| 242 | } |
| 243 | |
| 244 | bool isPadRepeatSelect(s32 port) { |
| 245 | return isPadRepeat(port, button: 1 << 12); |
| 246 | } |
| 247 | |
| 248 | bool isPadRepeatPlus(s32 port) { |
| 249 | return isPadRepeat(port, button: 1 << 10); |
| 250 | } |
| 251 | |
| 252 | bool isPadRepeatMinus(s32 port) { |
| 253 | return isPadRepeat(port, button: 1 << 9); |
| 254 | } |
| 255 | |
| 256 | bool isPadRepeatTouch() { |
| 257 | return isPadRepeat(port: getTouchPanelPort(), button: 1 << 15); |
| 258 | } |
| 259 | |
| 260 | bool isPadRepeatUpLeftStick(s32 port) { |
| 261 | return isPadRepeat(port, button: 1 << 20); |
| 262 | } |
| 263 | |
| 264 | bool isPadRepeatDownLeftStick(s32 port) { |
| 265 | return isPadRepeat(port, button: 1 << 21); |
| 266 | } |
| 267 | |
| 268 | bool isPadRepeatLeftLeftStick(s32 port) { |
| 269 | return isPadRepeat(port, button: 1 << 22); |
| 270 | } |
| 271 | |
| 272 | bool isPadRepeatRightLeftStick(s32 port) { |
| 273 | return isPadRepeat(port, button: 1 << 23); |
| 274 | } |
| 275 | |
| 276 | bool isPadRepeatUpRightStick(s32 port) { |
| 277 | return isPadRepeat(port, button: 1 << 24); |
| 278 | } |
| 279 | |
| 280 | bool isPadRepeatDownRightStick(s32 port) { |
| 281 | return isPadRepeat(port, button: 1 << 25); |
| 282 | } |
| 283 | |
| 284 | bool isPadRepeatLeftRightStick(s32 port) { |
| 285 | return isPadRepeat(port, button: 1 << 26); |
| 286 | } |
| 287 | |
| 288 | bool isPadRepeatRightRightStick(s32 port) { |
| 289 | return isPadRepeat(port, button: 1 << 27); |
| 290 | } |
| 291 | |
| 292 | bool isPadHoldPressLeftStick(s32 port) { |
| 293 | return isPadHold1(port); |
| 294 | } |
| 295 | |
| 296 | bool isPadHoldPressRightStick(s32 port) { |
| 297 | return isPadHold2(port); |
| 298 | } |
| 299 | |
| 300 | bool isPadHold(s32 port, s32 button) { |
| 301 | return getController(port)->isHold(mask: button); |
| 302 | } |
| 303 | |
| 304 | bool isPadHoldA(s32 port) { |
| 305 | return isPadHold(port, button: 1); |
| 306 | } |
| 307 | |
| 308 | bool isPadHoldB(s32 port) { |
| 309 | return isPadHold(port, button: 1 << 1); |
| 310 | } |
| 311 | |
| 312 | bool isPadHoldX(s32 port) { |
| 313 | return isPadHold(port, button: 1 << 3); |
| 314 | } |
| 315 | |
| 316 | bool isPadHoldY(s32 port) { |
| 317 | return isPadHold(port, button: 1 << 4); |
| 318 | } |
| 319 | |
| 320 | bool isPadHoldZL(s32 port) { |
| 321 | return isPadHold(port, button: 1 << 2); |
| 322 | } |
| 323 | |
| 324 | bool isPadHoldZR(s32 port) { |
| 325 | return isPadHold(port, button: 1 << 5); |
| 326 | } |
| 327 | |
| 328 | bool isPadHoldL(s32 port) { |
| 329 | return isPadHold(port, button: 1 << 13); |
| 330 | } |
| 331 | |
| 332 | bool isPadHoldR(s32 port) { |
| 333 | return isPadHold(port, button: 1 << 14); |
| 334 | } |
| 335 | |
| 336 | bool isPadHold1(s32 port) { |
| 337 | return isPadHold(port, button: 1 << 7); |
| 338 | } |
| 339 | |
| 340 | bool isPadHold2(s32 port) { |
| 341 | return isPadHold(port, button: 1 << 6); |
| 342 | } |
| 343 | |
| 344 | bool isPadHoldUp(s32 port) { |
| 345 | return isPadHold(port, button: 1 << 16); |
| 346 | } |
| 347 | |
| 348 | bool isPadHoldDown(s32 port) { |
| 349 | return isPadHold(port, button: 1 << 17); |
| 350 | } |
| 351 | |
| 352 | bool isPadHoldLeft(s32 port) { |
| 353 | return isPadHold(port, button: 1 << 18); |
| 354 | } |
| 355 | |
| 356 | bool isPadHoldRight(s32 port) { |
| 357 | return isPadHold(port, button: 1 << 19); |
| 358 | } |
| 359 | |
| 360 | bool isPadHoldLeftUp(s32 port) { |
| 361 | return getController(port)->isHoldAll(mask: 0x50000); |
| 362 | } |
| 363 | |
| 364 | bool isPadHoldLeftDown(s32 port) { |
| 365 | return getController(port)->isHoldAll(mask: 0x60000); |
| 366 | } |
| 367 | |
| 368 | bool isPadHoldRightUp(s32 port) { |
| 369 | return getController(port)->isHoldAll(mask: 0x90000); |
| 370 | } |
| 371 | |
| 372 | bool isPadHoldRightDown(s32 port) { |
| 373 | return getController(port)->isHoldAll(mask: 0xA0000); |
| 374 | } |
| 375 | |
| 376 | bool isPadHoldHome(s32 port) { |
| 377 | return isPadHold(port, button: 1 << 8); |
| 378 | } |
| 379 | |
| 380 | bool isPadHoldStart(s32 port) { |
| 381 | return isPadHold(port, button: 1 << 11); |
| 382 | } |
| 383 | |
| 384 | bool isPadHoldSelect(s32 port) { |
| 385 | return isPadHold(port, button: 1 << 12); |
| 386 | } |
| 387 | |
| 388 | bool isPadHoldPlus(s32 port) { |
| 389 | return isPadHold(port, button: 1 << 10); |
| 390 | } |
| 391 | |
| 392 | bool isPadHoldMinus(s32 port) { |
| 393 | return isPadHold(port, button: 1 << 9); |
| 394 | } |
| 395 | |
| 396 | bool isPadHoldAny(s32 port) { |
| 397 | return isPadHold(port, button: 0xFFF7FFF); |
| 398 | } |
| 399 | |
| 400 | bool isPadHoldAnyWithoutStick(s32 port) { |
| 401 | return isPadHold(port, button: 0xF7FFF); |
| 402 | } |
| 403 | |
| 404 | bool isPadHoldTouch() { |
| 405 | return isPadHold(port: getTouchPanelPort(), button: 1 << 15); |
| 406 | } |
| 407 | |
| 408 | bool isPadHoldUpLeftStick(s32 port) { |
| 409 | return isPadHold(port, button: 1 << 20); |
| 410 | } |
| 411 | |
| 412 | bool isPadHoldDownLeftStick(s32 port) { |
| 413 | return isPadHold(port, button: 1 << 21); |
| 414 | } |
| 415 | |
| 416 | bool isPadHoldLeftLeftStick(s32 port) { |
| 417 | return isPadHold(port, button: 1 << 22); |
| 418 | } |
| 419 | |
| 420 | bool isPadHoldRightLeftStick(s32 port) { |
| 421 | return isPadHold(port, button: 1 << 23); |
| 422 | } |
| 423 | |
| 424 | bool isPadHoldUpRightStick(s32 port) { |
| 425 | return isPadHold(port, button: 1 << 24); |
| 426 | } |
| 427 | |
| 428 | bool isPadHoldDownRightStick(s32 port) { |
| 429 | return isPadHold(port, button: 1 << 25); |
| 430 | } |
| 431 | |
| 432 | bool isPadHoldLeftRightStick(s32 port) { |
| 433 | return isPadHold(port, button: 1 << 26); |
| 434 | } |
| 435 | |
| 436 | bool isPadHoldRightRightStick(s32 port) { |
| 437 | return isPadHold(port, button: 1 << 27); |
| 438 | } |
| 439 | |
| 440 | bool isPadHoldLeftStick(s32 port) { |
| 441 | return isPadHold(port, button: 0xF00000); |
| 442 | } |
| 443 | |
| 444 | bool isPadHoldRightStick(s32 port) { |
| 445 | return isPadHold(port, button: 0xF000000); |
| 446 | } |
| 447 | |
| 448 | inline bool isPadRelease(s32 port, s32 button) { |
| 449 | return getController(port)->isRelease(mask: button); |
| 450 | } |
| 451 | |
| 452 | bool isPadReleaseA(s32 port) { |
| 453 | return isPadRelease(port, button: 1); |
| 454 | } |
| 455 | |
| 456 | bool isPadReleaseB(s32 port) { |
| 457 | return isPadRelease(port, button: 1 << 1); |
| 458 | } |
| 459 | |
| 460 | bool isPadReleaseX(s32 port) { |
| 461 | return isPadRelease(port, button: 1 << 3); |
| 462 | } |
| 463 | |
| 464 | bool isPadReleaseY(s32 port) { |
| 465 | return isPadRelease(port, button: 1 << 4); |
| 466 | } |
| 467 | |
| 468 | bool isPadReleaseZL(s32 port) { |
| 469 | return isPadRelease(port, button: 1 << 2); |
| 470 | } |
| 471 | |
| 472 | bool isPadReleaseZR(s32 port) { |
| 473 | return isPadRelease(port, button: 1 << 5); |
| 474 | } |
| 475 | |
| 476 | bool isPadReleaseL(s32 port) { |
| 477 | return isPadRelease(port, button: 1 << 13); |
| 478 | } |
| 479 | |
| 480 | bool isPadReleaseR(s32 port) { |
| 481 | return isPadRelease(port, button: 1 << 14); |
| 482 | } |
| 483 | |
| 484 | bool isPadRelease1(s32 port) { |
| 485 | return isPadRelease(port, button: 1 << 7); |
| 486 | } |
| 487 | |
| 488 | bool isPadRelease2(s32 port) { |
| 489 | return isPadRelease(port, button: 1 << 6); |
| 490 | } |
| 491 | |
| 492 | bool isPadReleaseUp(s32 port) { |
| 493 | return isPadRelease(port, button: 1 << 16); |
| 494 | } |
| 495 | |
| 496 | bool isPadReleaseDown(s32 port) { |
| 497 | return isPadRelease(port, button: 1 << 17); |
| 498 | } |
| 499 | |
| 500 | bool isPadReleaseLeft(s32 port) { |
| 501 | return isPadRelease(port, button: 1 << 18); |
| 502 | } |
| 503 | |
| 504 | bool isPadReleaseRight(s32 port) { |
| 505 | return isPadRelease(port, button: 1 << 19); |
| 506 | } |
| 507 | |
| 508 | bool isPadReleaseHome(s32 port) { |
| 509 | return isPadRelease(port, button: 1 << 8); |
| 510 | } |
| 511 | |
| 512 | bool isPadReleaseStart(s32 port) { |
| 513 | return isPadRelease(port, button: 1 << 11); |
| 514 | } |
| 515 | |
| 516 | bool isPadReleaseSelect(s32 port) { |
| 517 | return isPadRelease(port, button: 1 << 12); |
| 518 | } |
| 519 | |
| 520 | bool isPadReleasePlus(s32 port) { |
| 521 | return isPadRelease(port, button: 1 << 10); |
| 522 | } |
| 523 | |
| 524 | bool isPadReleaseMinus(s32 port) { |
| 525 | return isPadRelease(port, button: 1 << 9); |
| 526 | } |
| 527 | |
| 528 | bool isPadReleaseTouch() { |
| 529 | return isPadRelease(port: getTouchPanelPort(), button: 1 << 15); |
| 530 | } |
| 531 | |
| 532 | bool isPadReleaseUpLeftStick(s32 port) { |
| 533 | return isPadRelease(port, button: 1 << 20); |
| 534 | } |
| 535 | |
| 536 | bool isPadReleaseDownLeftStick(s32 port) { |
| 537 | return isPadRelease(port, button: 1 << 21); |
| 538 | } |
| 539 | |
| 540 | bool isPadReleaseLeftLeftStick(s32 port) { |
| 541 | return isPadRelease(port, button: 1 << 22); |
| 542 | } |
| 543 | |
| 544 | bool isPadReleaseRightLeftStick(s32 port) { |
| 545 | return isPadRelease(port, button: 1 << 23); |
| 546 | } |
| 547 | |
| 548 | bool isPadReleaseUpRightStick(s32 port) { |
| 549 | return isPadRelease(port, button: 1 << 24); |
| 550 | } |
| 551 | |
| 552 | bool isPadReleaseDownRightStick(s32 port) { |
| 553 | return isPadRelease(port, button: 1 << 25); |
| 554 | } |
| 555 | |
| 556 | bool isPadReleaseLeftRightStick(s32 port) { |
| 557 | return isPadRelease(port, button: 1 << 26); |
| 558 | } |
| 559 | |
| 560 | bool isPadReleaseRightRightStick(s32 port) { |
| 561 | return isPadRelease(port, button: 1 << 27); |
| 562 | } |
| 563 | |
| 564 | const sead::Vector2f& getLeftStick(s32 port) { |
| 565 | return getController(port)->getLeftStick(); |
| 566 | } |
| 567 | |
| 568 | const sead::Vector2f& getRightStick(s32 port) { |
| 569 | return getController(port)->getRightStick(); |
| 570 | } |
| 571 | |
| 572 | void getPadCrossDir(sead::Vector2f* vec, s32 port) { |
| 573 | vec->x = 0; |
| 574 | vec->y = 0; |
| 575 | if (isPadHoldUp(port)) |
| 576 | vec->y = 1; |
| 577 | if (isPadHoldDown(port)) |
| 578 | vec->y = -1; |
| 579 | if (isPadHoldLeft(port)) |
| 580 | vec->x = -1; |
| 581 | if (isPadHoldRight(port)) |
| 582 | vec->x = 1; |
| 583 | } |
| 584 | |
| 585 | void getPadCrossDirSideways(sead::Vector2f* vec, s32 port) { |
| 586 | vec->x = 0; |
| 587 | vec->y = 0; |
| 588 | if (isPadHoldUp(port)) |
| 589 | vec->x = -1; |
| 590 | if (isPadHoldDown(port)) |
| 591 | vec->x = 1; |
| 592 | if (isPadHoldLeft(port)) |
| 593 | vec->y = -1; |
| 594 | if (isPadHoldRight(port)) |
| 595 | vec->y = 1; |
| 596 | } |
| 597 | |
| 598 | void calcTouchScreenPos(sead::Vector2f* vec) { |
| 599 | vec->set(getController(port: getTouchPanelPort())->getPointer()); |
| 600 | } |
| 601 | |
| 602 | void calcTouchLayoutPos(sead::Vector2f*) {} |
| 603 | |
| 604 | bool isTouchPosInRect(const sead::Vector2f& rect_pos, const sead::Vector2f& size) { |
| 605 | sead::Vector2f pos; |
| 606 | calcTouchScreenPos(vec: &pos); |
| 607 | return rect_pos.x <= pos.x && pos.x < rect_pos.x + size.x && rect_pos.y <= pos.y && |
| 608 | pos.y < rect_pos.y + size.y; |
| 609 | } |
| 610 | |
| 611 | void setPadRepeat(s32 a1, s32 a2, s32 a3, s32 port) { |
| 612 | getController(port)->setPadRepeat(mask: a1, delay_frame: a2, pulse_frame: a3); |
| 613 | } |
| 614 | |
| 615 | s32 getPlayerControllerPort(s32 playerNo) { |
| 616 | auto* manager = sead::ControllerMgr::instance(); |
| 617 | sead::Controller* controller = manager->getControllerByOrder( |
| 618 | id: sead::ControllerDefine::ControllerId::cController_Npad, index: playerNo); |
| 619 | return manager->findControllerPort(controller); |
| 620 | } |
| 621 | |
| 622 | s32 getTouchPanelPort() { |
| 623 | auto* manager = sead::ControllerMgr::instance(); |
| 624 | sead::Controller* controller = manager->getControllerByOrder( |
| 625 | id: sead::ControllerDefine::ControllerId::cController_PadTouch, index: 0); |
| 626 | return manager->findControllerPort(controller); |
| 627 | } |
| 628 | |
| 629 | s32 getMainControllerPort() { |
| 630 | return getPlayerControllerPort(playerNo: 0); |
| 631 | } |
| 632 | |
| 633 | s32 getMainJoyPadDoublePort() { |
| 634 | return getMainControllerPort(); |
| 635 | } |
| 636 | |
| 637 | s32 getMainJoyPadSingleRightPort() { |
| 638 | return 1; |
| 639 | } |
| 640 | |
| 641 | s32 getMainJoyPadSingleLeftPort() { |
| 642 | return 2; |
| 643 | } |
| 644 | |
| 645 | } // namespace al |
| 646 | |