lwjgl2-arm64/src/java/org/lwjgl/input/ControllerEvent.java
Kevin Glass 007fe5999e Updated Controllers event queue to make use of the new JInput
event queue, including adding getEventNanoseconds() to the 
Controllers interface. TestControllers against Logitech pad on
Win32 confirms that no behaviour changes are evident.
2006-11-17 08:08:21 +00:00

139 lines
3.2 KiB
Java

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;
/** The time stamp of this event */
private long timeStamp;
/**
* Create a new event
*
* @param source The source of the event
* @param timeStamp The time stamp given for this 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,long timeStamp, int type,int index,boolean xaxis,boolean yaxis) {
this.source = source;
this.timeStamp = timeStamp;
this.type = type;
this.index = index;
this.xaxis = xaxis;
this.yaxis = yaxis;
}
/**
* Get the time stamp given for this event. As with nanoTime()
* this value means nothing other than giving ordering
*
* @return The time stamp given for this event
*/
public long getTimeStamp() {
return timeStamp;
}
/**
* 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+"]";
}
}