Top Description Fields Constructors Methods
net.java.games.input

public abstract Class AbstractController

extends Object
implements Controller
Class Inheritance
All Implemented Interfaces
net.java.games.input.Controller
Known Direct Subclasses
net.java.games.input.Keyboard, net.java.games.input.Mouse
Imports
java.io.IOException, java.util.HashMap, .Map

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

Field Summary

Modifier and TypeField and Description
private final Controller[]
children

Array of child controllers

private final Component[]
components

Array of components

private static final Event
private EventQueue
pack-priv static final int
private final Map<Component.Identifier, Component>
id_to_components

Map from Component.Identifiers to Components

private final String
name

Human-readable name for this Controller

private final Rumbler[]
rumblers

Array of rumblers

Constructor Summary

AccessConstructor and Description
protected
AbstractController(String
name for the controller
name
,
Component[]
components for the controller
components
,
Controller[]
child controllers for the controller
children
,
Rumbler[]
rumblers for the controller
rumblers
)

Protected constructor for a controller containing the specified axes, child controllers, and rumblers

Method Summary

Modifier and TypeMethod and Description
public final Component
getComponent(Component.Identifier id)

Implements net.java.games.input.Controller.getComponent.

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

Implements net.java.games.input.Controller.getComponents.

Returns the components on this controller, in order of assignment priority.
public final Controller[]
getControllers()

Implements net.java.games.input.Controller.getControllers.

Returns the controllers connected to make up this controller, or an empty array if this controller contains no child controllers.
public final EventQueue
getEventQueue()

Implements net.java.games.input.Controller.getEventQueue.

Get the device event queue
public final String
getName()

Implements net.java.games.input.Controller.getName.

Returns a human-readable name for this Controller.
protected abstract boolean
public int

Returns:

0 by default, can be overridden
getPortNumber
()

Implements net.java.games.input.Controller.getPortNumber.

Returns the zero-based port number for this Controller.
public Controller.PortType

Returns:

PortType.UNKNOWN by default, can be overridden
getPortType
()

Implements net.java.games.input.Controller.getPortType.

Returns the port type for this Controller.
public final Rumbler[]
getRumblers()

Implements net.java.games.input.Controller.getRumblers.

Returns the rumblers for sending feedback to this controller, or an empty array if there are no rumblers on this controller.
public Controller.Type
getType()

Implements net.java.games.input.Controller.getType.

Returns the type of the Controller.
public synchronized boolean
poll()

Implements net.java.games.input.Controller.poll.

Polls axes for data.
protected void
protected void
setDeviceEventQueueSize(int size)

Plugins override this method to adjust their internal event queue size

public final void
setEventQueueSize(int size)

Implements net.java.games.input.Controller.setEventQueueSize.

Creates a new EventQueue.
public String
toString()

Overrides java.lang.Object.toString.

Returns a non-localized string description of this controller.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

childrenback to summary
private final Controller[] children

Array of child controllers

componentsback to summary
private final Component[] components

Array of components

eventback to summary
private static final Event event
event_queueback to summary
private EventQueue event_queue
EVENT_QUEUE_DEPTHback to summary
pack-priv static final int EVENT_QUEUE_DEPTH
id_to_componentsback to summary
private final Map<Component.Identifier, Component> id_to_components

Map from Component.Identifiers to Components

nameback to summary
private final String name

Human-readable name for this Controller

rumblersback to summary
private final Rumbler[] rumblers

Array of rumblers

Constructor Detail

AbstractControllerback to summary
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:String

name for the controller

components:Component[]

components for the controller

children:Controller[]

child controllers for the controller

rumblers:Rumbler[]

rumblers for the controller

Method Detail

getComponentback to summary
public final Component getComponent(Component.Identifier id)

Implements net.java.games.input.Controller.getComponent.

Returns a single component based on its identifier, or null if no component with the specified type could be found.

getComponentsback to summary
public final Component[] getComponents()

Implements net.java.games.input.Controller.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).

getControllersback to summary
public final Controller[] getControllers()

Implements net.java.games.input.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.).

getEventQueueback to summary
public final EventQueue getEventQueue()

Implements net.java.games.input.Controller.getEventQueue.

Doc from net.java.games.input.Controller.getEventQueue.

Get the device event queue

getNameback to summary
public final String getName()

Implements net.java.games.input.Controller.getName.

Returns a human-readable name for this Controller.

getNextDeviceEventback to summary
protected abstract boolean getNextDeviceEvent(Event event) throws IOException
getPortNumberback to summary
public int getPortNumber()

Implements net.java.games.input.Controller.getPortNumber.

Returns the zero-based port number for this Controller.

Returns:int

0 by default, can be overridden

getPortTypeback to summary
public Controller.PortType getPortType()

Implements net.java.games.input.Controller.getPortType.

Returns the port type for this Controller.

Returns:Controller.PortType

PortType.UNKNOWN by default, can be overridden

getRumblersback to summary
public final Rumbler[] getRumblers()

Implements net.java.games.input.Controller.getRumblers.

Returns the rumblers for sending feedback to this controller, or an empty array if there are no rumblers on this controller.

getTypeback to summary
public Controller.Type getType()

Implements net.java.games.input.Controller.getType.

Returns the type of the Controller.

pollback to summary
public synchronized boolean poll()

Implements net.java.games.input.Controller.poll.

Doc from net.java.games.input.Controller.poll.

Polls axes for data. Returns false if the controller is no longer valid. Polling reflects the current state of the device when polled.

pollDeviceback to summary
protected void pollDevice() throws IOException
setDeviceEventQueueSizeback to summary
protected void setDeviceEventQueueSize(int size) throws IOException

Plugins override this method to adjust their internal event queue size

setEventQueueSizeback to summary
public final void setEventQueueSize(int size)

Implements net.java.games.input.Controller.setEventQueueSize.

Creates a new EventQueue. Events in old queue are lost.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a non-localized string description of this controller.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object