MCPcopy
hub / github.com/KilledByAPixel/LittleJS / getNavigationOtherDirection

Method getNavigationOtherDirection

plugins/uiSystem.js:579–594  ·  view source on GitHub ↗

Get other axis navigation direction from gamepad or keyboard * @return {Vector2}

()

Source from the content-addressed store, hash-verified

577 /** Get other axis navigation direction from gamepad or keyboard
578 * @return {Vector2} */
579 getNavigationOtherDirection()
580 {
581 if (uiSystem.navigationDirection === 2)
582 return 0; // other direction disabled
583
584 const vertical = uiSystem.navigationDirection === 1;
585 if (isUsingGamepad)
586 {
587 const stick = gamepadStick(0, gamepadPrimary);
588 const dpad = gamepadDpad(gamepadPrimary);
589 return !vertical ? (stick.y || dpad.y) : (stick.x || dpad.x);
590 }
591 const back = !vertical ? 'ArrowUp' : 'ArrowLeft';
592 const forward = !vertical ? 'ArrowDown' : 'ArrowRight';
593 return keyIsDown(back) ? -1 : keyIsDown(forward) ? 1 : 0;
594 }
595
596 /** Get if navigation button was pressed from gamepad or keyboard
597 * @return {boolean} */

Callers 1

updateMethod · 0.80

Calls 3

gamepadStickFunction · 0.85
gamepadDpadFunction · 0.85
keyIsDownFunction · 0.85

Tested by

no test coverage detected