001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package org.wpilib.driverstation;
006
007import org.wpilib.driverstation.internal.DriverStationBackend;
008
009/**
010 * A default implementation of UserControls that provides Gamepad instances for each of the 6
011 * joystick ports provided by the DS.
012 */
013public class DefaultUserControls implements UserControls {
014  private final Gamepad[] m_gamepads;
015
016  /** Constructs a DefaultUserControls instance with Gamepads for each port. */
017  public DefaultUserControls() {
018    m_gamepads = new Gamepad[DriverStationBackend.JOYSTICK_PORTS];
019    for (int i = 0; i < m_gamepads.length; i++) {
020      m_gamepads[i] = new Gamepad(i);
021    }
022  }
023
024  /**
025   * Returns the Gamepad instance for the specified port.
026   *
027   * @param port The joystick port number.
028   * @return The Gamepad instance for the given port.
029   */
030  public Gamepad getGamepad(int port) {
031    return m_gamepads[port];
032  }
033}