Package net.java.games.input
Class AbstractController
java.lang.Object
net.java.games.input.AbstractController
- All Implemented Interfaces:
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
ConstructorsModifierConstructorDescriptionprotectedAbstractController(String name, Component[] components, Controller[] children, Rumbler[] rumblers) Protected constructor for a controller containing the specified axes, child controllers, and rumblers -
Method Summary
Modifier and TypeMethodDescriptionfinal ComponentReturns a single component based on its identifier, or null if no component with the specified type could be found.final Component[]Returns the components on this controller, in order of assignment priority.final Controller[]Returns the controllers connected to make up this controller, or an empty array if this controller contains no child controllers.final EventQueueGet the device event queuefinal StringgetName()Returns a human-readable name for this Controller.protected abstract booleangetNextDeviceEvent(Event event) intReturns the zero-based port number for this Controller.Returns the port type for this Controller.final Rumbler[]Returns the rumblers for sending feedback to this controller, or an empty array if there are no rumblers on this controller.getType()Returns the type of the Controller.booleanpoll()Polls axes for data.protected voidprotected voidsetDeviceEventQueueSize(int size) Plugins override this method to adjust their internal event queue sizefinal voidsetEventQueueSize(int size) Creates a new EventQueue.toString()Returns a non-localized string description of this controller.
-
Constructor Details
-
AbstractController
protected AbstractController(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 controllercomponents- components for the controllerchildren- child controllers for the controllerrumblers- rumblers for the controller
-
-
Method Details
-
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:
getControllersin interfaceController
-
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:
getComponentsin interfaceController
-
getComponent
Returns a single component based on its identifier, or null if no component with the specified type could be found.- Specified by:
getComponentin interfaceController
-
getRumblers
Returns the rumblers for sending feedback to this controller, or an empty array if there are no rumblers on this controller.- Specified by:
getRumblersin interfaceController
-
getPortType
Returns the port type for this Controller.- Specified by:
getPortTypein interfaceController- Returns:
- PortType.UNKNOWN by default, can be overridden
-
getPortNumber
public int getPortNumber()Returns the zero-based port number for this Controller.- Specified by:
getPortNumberin interfaceController- Returns:
- 0 by default, can be overridden
-
getName
Returns a human-readable name for this Controller.- Specified by:
getNamein interfaceController
-
toString
Returns a non-localized string description of this controller. -
getType
Returns the type of the Controller.- Specified by:
getTypein interfaceController
-
setEventQueueSize
public final void setEventQueueSize(int size) Creates a new EventQueue. Events in old queue are lost.- Specified by:
setEventQueueSizein interfaceController
-
setDeviceEventQueueSize
Plugins override this method to adjust their internal event queue size- Throws:
IOException
-
getEventQueue
Description copied from interface:ControllerGet the device event queue- Specified by:
getEventQueuein interfaceController
-
getNextDeviceEvent
- Throws:
IOException
-
pollDevice
- Throws:
IOException
-
poll
public boolean poll()Description copied from interface:ControllerPolls axes for data. Returns false if the controller is no longer valid. Polling reflects the current state of the device when polled.- Specified by:
pollin interfaceController
-