Path: blob/master/SLICK_HOME/src/org/newdawn/slick/command/ControllerControl.java
1456 views
package org.newdawn.slick.command;12/**3* A control describing input provided from a controller. This allows controls to be4* mapped to game pad inputs.5*6* @author joverton7*/8abstract class ControllerControl implements Control {9/** Indicates a button was pressed */10protected static final int BUTTON_EVENT = 0;11/** Indicates left was pressed */12protected static final int LEFT_EVENT = 1;13/** Indicates right was pressed */14protected static final int RIGHT_EVENT = 2;15/** Indicates up was pressed */16protected static final int UP_EVENT = 3;17/** Indicates down was pressed */18protected static final int DOWN_EVENT = 4;1920/** The type of event we're looking for */21private int event;22/** The index of the button we're waiting for */23private int button;24/** The index of the controller we're waiting on */25private int controllerNumber;2627/**28* Create a new controller control29*30* @param controllerNumber The index of the controller to react to31* @param event The event to react to32* @param button The button index to react to on a BUTTON event33*/34protected ControllerControl(int controllerNumber, int event, int button) {35this.event = event;36this.button = button;37this.controllerNumber = controllerNumber;38}3940/**41* @see java.lang.Object#equals(java.lang.Object)42*/43public boolean equals(Object o) {44if(o == null)45return false;46if(!(o instanceof ControllerControl))47return false;4849ControllerControl c = (ControllerControl)o;5051return c.controllerNumber == controllerNumber && c.event == event && c.button == button;52}5354/**55* @see java.lang.Object#hashCode()56*/57public int hashCode() {58return event + button + controllerNumber;59}60}616263