package org.lwjgl.input; /** * An event occuring on a controller. * * @author Kevin Glass */ class ControllerEvent { /** Indicates the event was caused by a button */ public static final int BUTTON = 1; /** Indicates the event was caused by a axis */ public static final int AXIS = 2; /** Indicates the event was caused by a pov X */ public static final int POVX = 3; /** Indicates the event was caused by a pov Y */ public static final int POVY = 4; /** The controller generating the event */ private Controller source; /** The index of the input (axis or button) that generated the event */ private int index; /** Type of control that generated the event */ private int type; /** True if this event was caused by the x axis */ private boolean xaxis; /** True if this event was caused by the y axis */ private boolean yaxis; /** * Create a new event * * @param source The source of the event * @param type The type of control generating this event * @param index The index of the input that generated the event * @param xaxis True if this event was caused by the x-axis * @param yaxis True if this event was caused by the y-axis */ public ControllerEvent(Controller source,int type,int index,boolean xaxis,boolean yaxis) { this.source = source; this.type = type; this.index = index; this.xaxis = xaxis; this.yaxis = yaxis; } /** * Get the controller that generated this event * * @return The controller that generated this event */ public Controller getSource() { return source; } /** * Get the index of the control generating this event * * @return The index of the control generating this event */ public int getControlIndex() { return index; } /** * Check if this event was generated by a button * * @return True if this event was generated by a button */ public boolean isButton() { return type == BUTTON; } /** * Check if this event was generated by a axis * * @return True if this event was generated by a axis */ public boolean isAxis() { return type == AXIS; } /** * Check if this event was generated by a pov * * @return True if this event was generated by a pov */ public boolean isPovY() { return type == POVY; } /** * * Check if this event was generated by a pov * * @return True if this event was generated by a pov */ public boolean isPovX() { return type == POVX; } /** * Check if this event was caused by the X axis * * @return True if this event was caused by the X axis */ public boolean isXAxis() { return xaxis; } /** * Check if this event was caused by the Y axis * * @return True if this event was caused by the Y axis */ public boolean isYAxis() { return yaxis; } /* * @see java.lang.Object#toString() */ public String toString() { return "["+source+" type="+type+" xaxis="+xaxis+" yaxis="+yaxis+"]"; } }