package org.robockets.buttonmanager;

import java.util.ArrayList;

import edu.wpi.first.wpilibj.Joystick;

/**
 * The main class that people will interact with
 * when creating buttons.
 * This class should only be used statically.
 */
public class ButtonManager {
	private static ArrayList<Joystick> joysticks = new ArrayList<Joystick>();
	private static ArrayList<Button> boundButtons = new ArrayList<Button>();
	
	/**
	 * A static method to add a joystick for use with binding buttons to.
	 * All joysticks must be added through this method so that buttons can
	 * be bound.
	 * @param joystick a joystick object
	 */
	public static void addJoystick(Joystick joystick) {
		joysticks.add(joystick);
	}
	
	/**
	 * An overloaded static method for addJoystick.
	 * @param port the port of the new joystick
	 */
	public static void addJoystick(int port) {
		addJoystick(new Joystick(port));
	}
	
	/**
	 * A static method to get a specific joystick.
	 * @param number the port of the joystick
	 * @return a joystick object
	 */
	public static Joystick getJoystick(int number) {
		return joysticks.get(number);
	}
	
	/**
	 * A static method to get the state of a button.
	 * @param joystick the joystick port that the button is on
	 * @param button the button number
	 * @return the state of the button
	 */
	public static boolean getButtonState(int joystick, int button) {
		return getJoystick(joystick).getRawButton(button);
	}
	
	/**
	 * A static method to bind a new button.
	 * @param button an object with Button as a superclass
	 */
	public static void addButton(Button button) {
		boundButtons.add(button);
	}

	/**
	 * A static method that is used by ButtonThead to check each bound button.
	 */
	protected static void checkButtons() {
		for (int i = 0; i < boundButtons.size(); i++) {
			boundButtons.get(i).check();
		}
	}
}

@@ -258,16 +258,49 @@
 nager %7B%0A
+%09%0A%09private static Thread thread;%0A
 %09private
@@ -439,32 +439,204 @@
 tton%3E();%0A%09%0A%09/**%0A
+%09 * Call only once in robotInit. Starts the ButtonManager thread.%0A%09 */%0A%09public static void start() %7B%0A%09%09thread = new Thread(new ButtonThread());%0A%09%09thread.start();%0A%09%7D%0A%09%0A%09/**%0A
 %09 * A static met

Add start button thread method to ButtonManager