at.wisch.joystick
Class JoystickManager

java.lang.Object
  extended by at.wisch.joystick.JoystickManager

public class JoystickManager
extends java.lang.Object

The class JoystickManager. This is the main class for handling and recieving Joystick and FFJoystick objects.

Some methods of this class will throw FFJoystickException. Be aware that these are fatal errors. If these errors occur, neiter input, nor FF will work.

To get an introduction how to use this class, take a look at the sourcecode of JoystickInputDemo and JoystickForceDemo.

Author:
Martin Wischenbart
See Also:
JoystickInputDemo, JoystickForceDemo

Method Summary
static void close()
          Close the native JoystickManager subsystem.
static boolean disableJoystickEventPolling()
          Disable joystick input event polling.
static boolean enableJoystickEventPolling()
          Enable joystick input event polling.
static java.util.ArrayList<FFJoystick> getAllFFJoysticks()
          Gets an ArrayList containing all force feedback joysticks.
static java.util.ArrayList<Joystick> getAllJoysticks()
          Gets an ArrayList containing all joysticks.
static FFJoystick getFFJoystick()
          Gets a force feedback joystick.
static Joystick getJoystick()
          Gets a joystick.
static Joystick getJoystick(int joystickIndex)
          Gets a joystick with a certain index.
static void init()
          Initialize the native JoystickManager subsystem.
static boolean isEventPollingEnabled()
          Checks if event polling is enabled.
static void pauseAll()
          Pause all effects on all FF joysticks, that are currently playing.
static void reopenJoysticks()
          Reopen joysticks.
static void stopAllJoysticks()
          Stop all effects on all FF joysticks.
static void unpauseAll()
          Resume all effects on all FF joysticks, that were playing before they were paused.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

init

public static void init()
                 throws FFJoystickException
Initialize the native JoystickManager subsystem.

Throws:
FFJoystickException - During init() this is a fatal error. We will not be able to get joystick objects later on.

reopenJoysticks

public static void reopenJoysticks()
Reopen joysticks. If the connection to the joysticks was lost, e.g. because of another application, you can try to reopen the connection. This is especially helpful for FFJoysticks.


getJoystick

public static Joystick getJoystick()
                            throws JoystickManagerNotInitializedException,
                                   JoystickNotFoundException
Gets a joystick. If there are more than one joysticks connected, this will usually return the first one (i.e. the one with the lowest index).

Returns:
a Joystick object
Throws:
JoystickManagerNotInitializedException - The joystick manager was not initialized. You have to call init() first.
JoystickNotFoundException - No joystick was found.

getFFJoystick

public static FFJoystick getFFJoystick()
                                throws JoystickManagerNotInitializedException,
                                       JoystickNotFoundException
Gets a force feedback joystick. If there are more than one FF joysticks connected, this will usually return the first one (i.e. the one with the lowest index).

Returns:
a FFJoystick object
Throws:
JoystickManagerNotInitializedException - The joystick manager was not initialized. You have to call init() first.
JoystickNotFoundException - No force feedback joystick was found.

getJoystick

public static Joystick getJoystick(int joystickIndex)
                            throws JoystickManagerNotInitializedException,
                                   JoystickNotFoundException
Gets a joystick with a certain index.

Parameters:
joystickIndex - the joystick's index
Returns:
a Joystick object
Throws:
JoystickManagerNotInitializedException - The joystick manager was not initialized. You have to call init() first.
JoystickNotFoundException - There is no joystick with that joystickIndex in the collection.

getAllJoysticks

public static java.util.ArrayList<Joystick> getAllJoysticks()
                                                     throws JoystickManagerNotInitializedException
Gets an ArrayList containing all joysticks.

Returns:
an ArrayList of Joystick objects
Throws:
JoystickManagerNotInitializedException - The joystick manager was not initialized. You have to call init() first.

getAllFFJoysticks

public static java.util.ArrayList<FFJoystick> getAllFFJoysticks()
                                                         throws JoystickManagerNotInitializedException
Gets an ArrayList containing all force feedback joysticks.

Returns:
an ArrayList of FFJoystick objects
Throws:
JoystickManagerNotInitializedException - The joystick manager was not initialized. You have to call init() first.

pauseAll

public static void pauseAll()
Pause all effects on all FF joysticks, that are currently playing. (i.e. call FFJoystick.pause() on every FF joystick)


unpauseAll

public static void unpauseAll()
Resume all effects on all FF joysticks, that were playing before they were paused. (i.e. call FFJoystick.unpause() on every FF joystick)


stopAllJoysticks

public static void stopAllJoysticks()
Stop all effects on all FF joysticks. (i.e. call FFJoystick.stopAll() on every FF joystick)


isEventPollingEnabled

public static boolean isEventPollingEnabled()
Checks if event polling is enabled.

Returns:
true, if is event polling enabled. false, if disabled.

enableJoystickEventPolling

public static boolean enableJoystickEventPolling()
                                          throws JoystickManagerNotInitializedException,
                                                 FFJoystickException
Enable joystick input event polling. Once enabled, every input event will cause controllerEventOccured(event) to be called on all listeners that were previously registered using ControllerEventManager.

Returns:
true, if successful. false, otherwise.
Throws:
JoystickManagerNotInitializedException - The joystick manager was not initialized. You have to call init() first.
FFJoystickException - Another error occured, probably fatal. Event polling will not work.
See Also:
ControllerEventListener.controllerEventOccured(AdvancedControllerEvent), ControllerEventManager.addControllerEventListener(ControllerEventListener)

disableJoystickEventPolling

public static boolean disableJoystickEventPolling()
                                           throws FFJoystickException
Disable joystick input event polling.

Returns:
true, if successful. false, otherwise.
Throws:
FFJoystickException - the FF joystick exception

close

public static void close()
Close the native JoystickManager subsystem. All FF effects on all joysticks will be stopped first and event polling will be disabled.