Top Description Fields Constructors Methods
org.lwjgl.input

public Class Controllers

extends Object
Class Inheritance
Imports
java.util.ArrayList, net.java.games.input.ControllerEnvironment, org.lwjgl.LWJGLException

The collection of controllers currently connected.
Author
Kevin Glass

Field Summary

Modifier and TypeField and Description
private static int
controllerCount

The number of controllers

private static ArrayList<JInputController>
controllers

The controllers available

private static boolean
created

Whether controllers were created

private static ControllerEvent
event

The current event

private static ArrayList<ControllerEvent>
events

The current list of events

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
addEvent(ControllerEvent
The event to add to the list
event
)

Add an event to the stack of events that have been caused

public static void
clearEvents()

Clear any events stored for the controllers in this set

public static void
create()

Initialise the controllers collection

private static void
createController(Controller
The controller to add
c
)

Utility to create a controller based on its potential sub-controllers

public static void
destroy()

Destroys any resources used by the controllers

public static Controller

Returns:

The controller requested
getController
(int
The index of the controller to retrieve
index
)

Get a controller from the collection

public static int

Returns:

The number of controllers available
getControllerCount
()

Retrieve a count of the number of controllers

public static boolean

Returns:

True if button was down, or false if released
getEventButtonState
()

Gets the state of the button that generated the current event

public static int

Returns:

The index of the control that cause the current event
getEventControlIndex
()

Get the index of the control that caused the current event

public static long

Returns:

The timestamp assigned to the current event
getEventNanoseconds
()

Get the timestamp assigned to the current event

public static Controller

Returns:

The source of the current event
getEventSource
()

Get the source of the current event

public static float

Returns:

The value on a x axis of the current event
getEventXAxisValue
()

Get the value on an X axis of the current event

public static float

Returns:

The value on a y axis of the current event
getEventYAxisValue
()

Get the value on an Y axis of the current event

public static boolean

Returns:

True if Controllers has been created
isCreated
()

public static boolean

Returns:

True if the current event was caused by a axis
isEventAxis
()

Check if the current event was caused by a axis

public static boolean

Returns:

True if the current event was caused by a button
isEventButton
()

Check if the current event was caused by a button

public static boolean

Returns:

True if the current event was caused by the POV x-axis
isEventPovX
()

Check if the current event was cause by the POV x-axis

public static boolean

Returns:

True if the current event was caused by the POV x-axis
isEventPovY
()

Check if the current event was cause by the POV x-axis

public static boolean

Returns:

True if the current event was cause by movement on the x-axis
isEventXAxis
()

Check if the current event was caused by movement on the x-axis

public static boolean

Returns:

True if the current event was caused by movement on the y-axis
isEventYAxis
()

Check if the current event was caused by movement on the y-axis

public static boolean

Returns:

True if there is still an event to process
next
()

Move to the next event that has been stored.

public static void
poll()

Poll the controllers available.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

controllerCountback to summary
private static int controllerCount

The number of controllers

controllersback to summary
private static ArrayList<JInputController> controllers

The controllers available

createdback to summary
private static boolean created

Whether controllers were created

eventback to summary
private static ControllerEvent event

The current event

eventsback to summary
private static ArrayList<ControllerEvent> events

The current list of events

Constructor Detail

Controllersback to summary
public Controllers()

Method Detail

addEventback to summary
pack-priv static void addEvent(ControllerEvent event)

Add an event to the stack of events that have been caused

Parameters
event:ControllerEvent

The event to add to the list

clearEventsback to summary
public static void clearEvents()

Clear any events stored for the controllers in this set

createback to summary
public static void create() throws LWJGLException

Initialise the controllers collection

Exceptions
LWJGLException:
Indicates a failure to initialise the controller library.
createControllerback to summary
private static void createController(Controller c)

Utility to create a controller based on its potential sub-controllers

Parameters
c:Controller

The controller to add

destroyback to summary
public static void destroy()

Destroys any resources used by the controllers

getControllerback to summary
public static Controller getController(int index)

Get a controller from the collection

Parameters
index:int

The index of the controller to retrieve

Returns:Controller

The controller requested

getControllerCountback to summary
public static int getControllerCount()

Retrieve a count of the number of controllers

Returns:int

The number of controllers available

getEventButtonStateback to summary
public static boolean getEventButtonState()

Gets the state of the button that generated the current event

Returns:boolean

True if button was down, or false if released

getEventControlIndexback to summary
public static int getEventControlIndex()

Get the index of the control that caused the current event

Returns:int

The index of the control that cause the current event

getEventNanosecondsback to summary
public static long getEventNanoseconds()

Get the timestamp assigned to the current event

Returns:long

The timestamp assigned to the current event

getEventSourceback to summary
public static Controller getEventSource()

Get the source of the current event

Returns:Controller

The source of the current event

getEventXAxisValueback to summary
public static float getEventXAxisValue()

Get the value on an X axis of the current event

Returns:float

The value on a x axis of the current event

getEventYAxisValueback to summary
public static float getEventYAxisValue()

Get the value on an Y axis of the current event

Returns:float

The value on a y axis of the current event

isCreatedback to summary
public static boolean isCreated()
Returns:boolean

True if Controllers has been created

isEventAxisback to summary
public static boolean isEventAxis()

Check if the current event was caused by a axis

Returns:boolean

True if the current event was caused by a axis

isEventButtonback to summary
public static boolean isEventButton()

Check if the current event was caused by a button

Returns:boolean

True if the current event was caused by a button

isEventPovXback to summary
public static boolean isEventPovX()

Check if the current event was cause by the POV x-axis

Returns:boolean

True if the current event was caused by the POV x-axis

isEventPovYback to summary
public static boolean isEventPovY()

Check if the current event was cause by the POV x-axis

Returns:boolean

True if the current event was caused by the POV x-axis

isEventXAxisback to summary
public static boolean isEventXAxis()

Check if the current event was caused by movement on the x-axis

Returns:boolean

True if the current event was cause by movement on the x-axis

isEventYAxisback to summary
public static boolean isEventYAxis()

Check if the current event was caused by movement on the y-axis

Returns:boolean

True if the current event was caused by movement on the y-axis

nextback to summary
public static boolean next()

Move to the next event that has been stored.

Returns:boolean

True if there is still an event to process

pollback to summary
public static void poll()

Poll the controllers available. This will both update their state and generate events that must be cleared.