package org.robockets.buttonmanager;

import java.util.ArrayList;

import edu.wpi.first.wpilibj.Joystick;

public class ButtonManager {
	public static ArrayList<Joystick> joysticks = new ArrayList<Joystick>();
	public static ArrayList<Button> boundButtons = new ArrayList<Button>();
	
	public static void addJoystick(int port) {
		joysticks.add(new Joystick(port));
	}
	
	public static Joystick getJoystick(int number) {
		return joysticks.get(number);
	}
	
	public static boolean getButtonState(int joystick, int button) {
		return getJoystick(joystick).getRawButton(button);
	}
	
	public static void addButton(Button button) {
		boundButtons.add(button);
	}
	
	public static void checkButtons() {
		for (int i = 0; i < boundButtons.size(); i++) {
			boundButtons.get(i).check();
		}
	}
}

@@ -100,16 +100,169 @@
 stick;%0A%0A
+/**%0A * The main class that people will interact with%0A * when creating buttons.%0A * This class should only be used statically.%0A * @author jakekinsella%0A */%0A
 public c
@@ -284,21 +284,22 @@
 ger %7B%0A%09p
-ublic
+rivate
  static 
@@ -359,21 +359,22 @@
 k%3E();%0A%09p
-ublic
+rivate
  static 
@@ -433,16 +433,221 @@
 n%3E();%0A%09%0A
+%09/**%0A%09 * A static method to add a joystick for use with binding buttons to.%0A%09 * All joysticks must be added through this method so that buttons can%0A%09 * be bound.%0A%09 * @param joystick a joystick object%0A%09 */%0A
 %09public 
@@ -674,16 +674,25 @@
 ick(
-int port
+Joystick joystick
 ) %7B%0A
@@ -711,120 +711,620 @@
 add(
-new Joystick(port));%0A%09%7D%0A%09%0A%09public static Joystick getJoystick(int number) %7B%0A%09%09return joysticks.get(number);%0A%09%7D%0A%09
+joystick);%0A%09%7D%0A%09%0A%09/**%0A%09 * An overloaded static method for addJoystick.%0A%09 * @param port the port of the new joystick%0A%09 */%0A%09public static void addJoystick(int port) %7B%0A%09%09addJoystick(new Joystick(port));%0A%09%7D%0A%09%0A%09/**%0A%09 * A static method to get a specific joystick.%0A%09 * @param number the port of the joystick%0A%09 * @return a joystick object%0A%09 */%0A%09public static Joystick getJoystick(int number) %7B%0A%09%09return joysticks.get(number);%0A%09%7D%0A%09%0A%09/**%0A%09 * A static method to get the state of a button%0A%09 * @param joystick the joystick port that the button is on%0A%09 * @param button the button number%0A%09 * @return the state of the button%0A%09 */
 %0A%09pu
@@ -1436,32 +1436,139 @@
 n(button);%0A%09%7D%0A%09%0A
+%09/**%0A%09 * A static method to bind a new button%0A%09 * @param button an object with Button as a superclass%0A%09 */%0A
 %09public static v
@@ -1633,17 +1633,19 @@
 %0A%09%7D%0A
-%09
 %0A%09p
-ublic
+rotected
  sta

Clean up some code and add javadoc comments to ButtonManager