angle method

double angle(
  1. int port,
  2. Joystick joystick
)

Calculates the angle of a specified joystick on a given gamepad port.

The angle is in degrees, where 0 degrees is typically pointing upwards, 90 degrees is right, 180 is down, and 270 is left.

  • port: The gamepad port index (0 to MAX_PORTS - 1).
  • joystick: The Joystick (Left or Right) to query.

Returns the angle in degrees (0-359). If the joystick is centered (x=0, y=0), the angle might be consistently 90 degrees or another default depending on atan2Degree behavior.

Implementation

double angle(int port, Joystick joystick) {
  var x = joyX(port, joystick);
  var y = joyY(port, joystick);
  return (atan2Degree(y, x) + 360 + 90) % 360;
}