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

public abstract Class ControllerEnvironment

extends Object
Class Inheritance
Known Direct Subclasses
net.java.games.input.DefaultControllerEnvironment
Imports
java.util.ArrayList, .Iterator, java.util.logging.Level, java.util.logging.Logger

A ControllerEnvironment represents a collection of controllers that are physically or logically linked. By default, this corresponds to the environment for the local machine.

In this reference implementation, this class can also be used to register controllers with the default environment as "plug-ins". A plug-in is created by subclassing ControllerEnvironment with a class that has a public no-argument constructor, implements the net.java.games.util.plugins.Plugin interface and has a name ending in "Plugin". (See net.java.games.input.DirectInputEnvironmentPlugin in the DXplugin part of the source tree for an example.) When the DefaultControllerEnvrionment is instanced it uses the plugin library to look for Plugins in both [java.home]/lib/controller and [user.dir]/controller. This allows controller plugins to be installed either globally for the entire Java environment or locally for just one particular Java app. For more information on the organization of plugins within the controller root directories, see net.java.games.util.plugins.Plugins (Note the plural -- "Plugins" not "Plugin" which is just a marker interface.)

Field Summary

Modifier and TypeField and Description
protected final ArrayList<ControllerListener>
controllerListeners

List of controller listeners

private static ControllerEnvironment
defaultEnvironment

The default controller environment

Constructor Summary

AccessConstructor and Description
protected
ControllerEnvironment()

Protected constructor for subclassing.

Method Summary

Modifier and TypeMethod and Description
public void
addControllerListener(ControllerListener l)

Adds a listener for controller state change events.

protected void
fireControllerAdded(Controller c)

Creates and sends an event to the controller listeners that a controller has been added.

protected void
fireControllerRemoved(Controller c)

Creates and sends an event to the controller listeners that a controller has been lost.

public abstract Controller[]
getControllers()

Returns a list of all controllers available to this environment, or an empty array if there are no controllers in this environment.

public static ControllerEnvironment
getDefaultEnvironment()

Returns the default environment for input controllers.

public abstract boolean
isSupported()

Returns the isSupported status of this environment.

pack-priv static void
log(String msg)

public void
removeControllerListener(ControllerListener l)

Removes a listener for controller state change events.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

controllerListenersback to summary
protected final ArrayList<ControllerListener> controllerListeners

List of controller listeners

defaultEnvironmentback to summary
private static ControllerEnvironment defaultEnvironment

The default controller environment

Constructor Detail

ControllerEnvironmentback to summary
protected ControllerEnvironment()

Protected constructor for subclassing.

Method Detail

addControllerListenerback to summary
public void addControllerListener(ControllerListener l)

Adds a listener for controller state change events.

fireControllerAddedback to summary
protected void fireControllerAdded(Controller c)

Creates and sends an event to the controller listeners that a controller has been added.

fireControllerRemovedback to summary
protected void fireControllerRemoved(Controller c)

Creates and sends an event to the controller listeners that a controller has been lost.

getControllersback to summary
public abstract Controller[] getControllers()

Returns a list of all controllers available to this environment, or an empty array if there are no controllers in this environment.

getDefaultEnvironmentback to summary
public static ControllerEnvironment getDefaultEnvironment()

Returns the default environment for input controllers. This usually corresponds to the environment for the local machine.

isSupportedback to summary
public abstract boolean isSupported()

Returns the isSupported status of this environment. What makes an environment supported or not is up to the particular plugin, but may include OS or available hardware.

logback to summary
pack-priv static void log(String msg)
removeControllerListenerback to summary
public void removeControllerListener(ControllerListener l)

Removes a listener for controller state change events.