com.threerings.opengl.gui.event
Class ControllerEvent

java.lang.Object
  extended by java.util.EventObject
      extended by com.threerings.opengl.gui.event.Event
          extended by com.threerings.opengl.gui.event.InputEvent
              extended by com.threerings.opengl.gui.event.ControllerEvent
All Implemented Interfaces:
Serializable

public class ControllerEvent
extends InputEvent

Encapsulates the information associated with a controller (joystick, gamepad) event.

See Also:
Serialized Form

Field Summary
protected  int _controlIndex
          The index of the control (button or axis) that caused the event.
protected  int _type
          The type of the event.
protected  float _value
          The value of the axis.
protected  boolean _xAxis
          Whether or not the axis is the x axis.
protected  boolean _yAxis
          Whether or not the axis is the y axis.
static int CONTROLLER_MOVED
          An event generated when the controller is moved on an axis.
static int CONTROLLER_POV_X_MOVED
          An event generated when the controller's pov is moved on the x axis.
static int CONTROLLER_POV_Y_MOVED
          An event generated when the controller's pov is moved on the y axis.
static int CONTROLLER_PRESSED
          An event generated when a controller button is pressed.
static int CONTROLLER_RELEASED
          An event generated when a controller button is released.
 
Fields inherited from class com.threerings.opengl.gui.event.InputEvent
_modifiers, ALT_DOWN_MASK, BUTTON1_DOWN_MASK, BUTTON2_DOWN_MASK, BUTTON3_DOWN_MASK, CTRL_DOWN_MASK, META_DOWN_MASK, SHIFT_DOWN_MASK
 
Fields inherited from class com.threerings.opengl.gui.event.Event
_consumed, _when
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
ControllerEvent(Controller source, long when, int modifiers, int type, float value)
          Creates a new controller pov event.
ControllerEvent(Controller source, long when, int modifiers, int type, int controlIndex)
          Creates a new controller button event.
ControllerEvent(Controller source, long when, int modifiers, int type, int controlIndex, boolean xAxis, boolean yAxis, float value)
          Creates a new controller event.
 
Method Summary
 void dispatch(ComponentListener listener)
          Instructs this event to notify the supplied listener if they implement an interface appropriate to this event.
 int getControlIndex()
          Returns the index of the control (button or axis) that caused the event, or -1 if not caused by a button or axis.
 Controller getController()
          Returns a reference to the controller that caused the event.
 int getType()
          Returns the type of this event, one of CONTROLLER_PRESSED, {#link CONTROLLER_RELEASED}, etc.
 float getValue()
          Returns the value corresponding to the event.
 boolean isXAxis()
          Checks whether the event pertains to the x axis.
 boolean isYAxis()
          Checks whether the event pertains to the y axis.
protected  void toString(StringBuilder buf)
           
 
Methods inherited from class com.threerings.opengl.gui.event.InputEvent
getModifiers, isAltDown, isControlDown, isMetaDown, isShiftDown
 
Methods inherited from class com.threerings.opengl.gui.event.Event
consume, getWhen, isConsumed, propagateUpHierarchy, toString
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTROLLER_PRESSED

public static final int CONTROLLER_PRESSED
An event generated when a controller button is pressed.

See Also:
Constant Field Values

CONTROLLER_RELEASED

public static final int CONTROLLER_RELEASED
An event generated when a controller button is released.

See Also:
Constant Field Values

CONTROLLER_MOVED

public static final int CONTROLLER_MOVED
An event generated when the controller is moved on an axis.

See Also:
Constant Field Values

CONTROLLER_POV_X_MOVED

public static final int CONTROLLER_POV_X_MOVED
An event generated when the controller's pov is moved on the x axis.

See Also:
Constant Field Values

CONTROLLER_POV_Y_MOVED

public static final int CONTROLLER_POV_Y_MOVED
An event generated when the controller's pov is moved on the y axis.

See Also:
Constant Field Values

_type

protected int _type
The type of the event.


_controlIndex

protected int _controlIndex
The index of the control (button or axis) that caused the event.


_xAxis

protected boolean _xAxis
Whether or not the axis is the x axis.


_yAxis

protected boolean _yAxis
Whether or not the axis is the y axis.


_value

protected float _value
The value of the axis.

Constructor Detail

ControllerEvent

public ControllerEvent(Controller source,
                       long when,
                       int modifiers,
                       int type,
                       int controlIndex)
Creates a new controller button event.


ControllerEvent

public ControllerEvent(Controller source,
                       long when,
                       int modifiers,
                       int type,
                       float value)
Creates a new controller pov event.


ControllerEvent

public ControllerEvent(Controller source,
                       long when,
                       int modifiers,
                       int type,
                       int controlIndex,
                       boolean xAxis,
                       boolean yAxis,
                       float value)
Creates a new controller event.

Method Detail

getController

public Controller getController()
Returns a reference to the controller that caused the event.


getType

public int getType()
Returns the type of this event, one of CONTROLLER_PRESSED, {#link CONTROLLER_RELEASED}, etc.


getControlIndex

public int getControlIndex()
Returns the index of the control (button or axis) that caused the event, or -1 if not caused by a button or axis.


isXAxis

public boolean isXAxis()
Checks whether the event pertains to the x axis.


isYAxis

public boolean isYAxis()
Checks whether the event pertains to the y axis.


getValue

public float getValue()
Returns the value corresponding to the event.


dispatch

public void dispatch(ComponentListener listener)
Description copied from class: Event
Instructs this event to notify the supplied listener if they implement an interface appropriate to this event.

Overrides:
dispatch in class Event

toString

protected void toString(StringBuilder buf)
Overrides:
toString in class InputEvent