joyX method

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

Gets the current X-axis value of a specified joystick on a given gamepad port.

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

Returns the X-axis value, typically ranging from -1.0 (left) to 1.0 (right). Returns 0.0 if the port or joystick is invalid.

Implementation

double joyX(int port, Joystick joystick) {
  int index = joystick.index;
  if (port < 0 || port >= _input.length) return 0.0;
  if (index < 0 || index >= _input[port].xAxis.length) return 0.0;
  return _input[port].xAxis[index];
}