net.java.games.input
Class AbstractController

java.lang.Object
  extended by net.java.games.input.AbstractController
All Implemented Interfaces:
Controller
Direct Known Subclasses:
Keyboard, Mouse

public abstract class AbstractController
extends java.lang.Object
implements Controller

An AbstractController is a skeleton implementation of a controller that contains a fixed number of axes, controllers, and rumblers.


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.java.games.input.Controller
Controller.PortType, Controller.Type
 
Constructor Summary
protected AbstractController(java.lang.String name, Component[] components, Controller[] children, Rumbler[] rumblers)
          Protected constructor for a controller containing the specified axes, child controllers, and rumblers
 
Method Summary
 Component getComponent(Component.Identifier id)
          Returns a single component based on its identifier, or null if no component with the specified type could be found.
 Component[] getComponents()
          Returns the components on this controller, in order of assignment priority.
 Controller[] getControllers()
          Returns the controllers connected to make up this controller, or an empty array if this controller contains no child controllers.
 EventQueue getEventQueue()
          Get the device event queue
 java.lang.String getName()
          Returns a human-readable name for this Controller.
protected abstract  boolean getNextDeviceEvent(Event event)
           
 int getPortNumber()
          Returns the zero-based port number for this Controller.
 Controller.PortType getPortType()
          Returns the port type for this Controller.
 Rumbler[] getRumblers()
          Returns the rumblers for sending feedback to this controller, or an empty array if there are no rumblers on this controller.
 Controller.Type getType()
          Returns the type of the Controller.
 boolean poll()
          Polls axes for data.
protected  void pollDevice()
           
protected  void setDeviceEventQueueSize(int size)
          Plugins override this method to adjust their internal event queue size
 void setEventQueueSize(int size)
          Creates a new EventQueue.
 java.lang.String toString()
          Returns a non-localized string description of this controller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractController

protected AbstractController(java.lang.String name,
                             Component[] components,
                             Controller[] children,
                             Rumbler[] rumblers)
Protected constructor for a controller containing the specified axes, child controllers, and rumblers

Parameters:
name - name for the controller
components - components for the controller
children - child controllers for the controller
rumblers - rumblers for the controller
Method Detail

getControllers

public final Controller[] getControllers()
Returns the controllers connected to make up this controller, or an empty array if this controller contains no child controllers. The objects in the array are returned in order of assignment priority (primary stick, secondary buttons, etc.).

Specified by:
getControllers in interface Controller

getComponents

public final Component[] getComponents()
Returns the components on this controller, in order of assignment priority. For example, the button controller on a mouse returns an array containing the primary or leftmost mouse button, followed by the secondary or rightmost mouse button (if present), followed by the middle mouse button (if present). The array returned is an empty array if this controller contains no components (such as a logical grouping of child controllers).

Specified by:
getComponents in interface Controller

getComponent

public final Component getComponent(Component.Identifier id)
Returns a single component based on its identifier, or null if no component with the specified type could be found.

Specified by:
getComponent in interface Controller

getRumblers

public final Rumbler[] getRumblers()
Returns the rumblers for sending feedback to this controller, or an empty array if there are no rumblers on this controller.

Specified by:
getRumblers in interface Controller

getPortType

public Controller.PortType getPortType()
Returns the port type for this Controller.

Specified by:
getPortType in interface Controller
Returns:
PortType.UNKNOWN by default, can be overridden

getPortNumber

public int getPortNumber()
Returns the zero-based port number for this Controller.

Specified by:
getPortNumber in interface Controller
Returns:
0 by default, can be overridden

getName

public final java.lang.String getName()
Returns a human-readable name for this Controller.

Specified by:
getName in interface Controller

toString

public java.lang.String toString()
Returns a non-localized string description of this controller.

Overrides:
toString in class java.lang.Object

getType

public Controller.Type getType()
Returns the type of the Controller.

Specified by:
getType in interface Controller

setEventQueueSize

public final void setEventQueueSize(int size)
Creates a new EventQueue. Events in old queue are lost.

Specified by:
setEventQueueSize in interface Controller

setDeviceEventQueueSize

protected void setDeviceEventQueueSize(int size)
                                throws java.io.IOException
Plugins override this method to adjust their internal event queue size

Throws:
java.io.IOException

getEventQueue

public final EventQueue getEventQueue()
Description copied from interface: Controller
Get the device event queue

Specified by:
getEventQueue in interface Controller

getNextDeviceEvent

protected abstract boolean getNextDeviceEvent(Event event)
                                       throws java.io.IOException
Throws:
java.io.IOException

pollDevice

protected void pollDevice()
                   throws java.io.IOException
Throws:
java.io.IOException

poll

public boolean poll()
Description copied from interface: Controller
Polls axes for data. Returns false if the controller is no longer valid. Polling reflects the current state of the device when polled.

Specified by:
poll in interface Controller