2005-06-29 22:11:15 +02:00
|
|
|
package org.lwjgl.input;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* An event occuring on a controller.
|
|
|
|
|
*
|
|
|
|
|
* @author Kevin Glass
|
|
|
|
|
*/
|
2005-06-29 22:38:21 +02:00
|
|
|
class ControllerEvent {
|
2005-06-29 22:11:15 +02:00
|
|
|
/** 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;
|
2006-11-17 09:08:21 +01:00
|
|
|
/** The time stamp of this event */
|
|
|
|
|
private long timeStamp;
|
2005-06-29 22:11:15 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new event
|
|
|
|
|
*
|
|
|
|
|
* @param source The source of the event
|
2006-11-17 09:08:21 +01:00
|
|
|
* @param timeStamp The time stamp given for this event
|
2005-06-29 22:11:15 +02:00
|
|
|
* @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
|
|
|
|
|
*/
|
2006-11-17 09:08:21 +01:00
|
|
|
public ControllerEvent(Controller source,long timeStamp, int type,int index,boolean xaxis,boolean yaxis) {
|
2005-06-29 22:11:15 +02:00
|
|
|
this.source = source;
|
2006-11-17 09:08:21 +01:00
|
|
|
this.timeStamp = timeStamp;
|
2005-06-29 22:11:15 +02:00
|
|
|
this.type = type;
|
|
|
|
|
this.index = index;
|
|
|
|
|
this.xaxis = xaxis;
|
|
|
|
|
this.yaxis = yaxis;
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-17 09:08:21 +01:00
|
|
|
/**
|
|
|
|
|
* 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;
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-29 22:11:15 +02:00
|
|
|
/**
|
|
|
|
|
* 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+"]";
|
|
|
|
|
}
|
|
|
|
|
}
|