org.jagatoo.input.devices
Class InputDevice

java.lang.Object
  extended by org.jagatoo.input.devices.InputDevice
All Implemented Interfaces:
Enableable
Direct Known Subclasses:
Controller, Keyboard, Mouse

public abstract class InputDevice
extends java.lang.Object
implements Enableable

This is the (very) base-class for all input device implementations.
Instances can only be created/retrieved through an InputDeviceFactory.


Constructor Summary
InputDevice(InputSourceWindow sourceWindow, EventQueue eventQueue, java.lang.String name)
           
 
Method Summary
 void addInputStateListener(InputStateListener l)
          Adds a new InputStateListener to the list of notified instances.
abstract  void collectEvents(InputSystem is, EventQueue eventQueue, long nanoTime)
          Processes pending events from the system and places them into the EventQueue.
abstract  void consumePendingEvents(InputSystem is, EventQueue eventQueue, long nanoTime)
          Processes pending events from the system and simply wastes them.
abstract  void destroy()
          Destroys the InputDevice.
 boolean equals(java.lang.Object o)
          
 void fireStateEventsAndDoActions(InputEvent e, int delta, int state)
           
protected  EventQueue getEventQueue()
           
 java.lang.String getName()
           
 InputSourceWindow getSourceWindow()
           
abstract  int getState(DeviceComponent component)
          This method returns an abstract input-state for the given DeviceComponent.
 boolean hasInputStateListener()
           
 boolean isEnabled()
          
 void onDeviceRegistered(InputSystem inputSystem)
          This method is called by the InputSystem after the device has been completely and successfully registered.
 void onDeviceUnregistered(InputSystem inputSystem)
          This method is called by the InputSystem after the device has been completely and successfully deregistered.
 void removeInputStateListener(InputStateListener l)
          Removes an InputStateListener from the list of notified instances.
 void setEnabled(boolean enabled)
          Enables of disables this object.
abstract  void update(InputSystem is, EventQueue eventQueue, long nanoTime)
          Processes pending events from the system and directly fires them (notifes the listeners).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputDevice

public InputDevice(InputSourceWindow sourceWindow,
                   EventQueue eventQueue,
                   java.lang.String name)
            throws InputSystemException
Throws:
InputSystemException
Method Detail

getSourceWindow

public final InputSourceWindow getSourceWindow()
Returns:
the InputSourceWindow, this device is bound to.

getEventQueue

protected final EventQueue getEventQueue()

getName

public final java.lang.String getName()
Returns:
this Device's name.

onDeviceRegistered

public void onDeviceRegistered(InputSystem inputSystem)
                        throws InputSystemException
This method is called by the InputSystem after the device has been completely and successfully registered.

Parameters:
inputSystem -
Throws:
InputSystemException

onDeviceUnregistered

public void onDeviceUnregistered(InputSystem inputSystem)
                          throws InputSystemException
This method is called by the InputSystem after the device has been completely and successfully deregistered.

Parameters:
inputSystem -
Throws:
InputSystemException

getState

public abstract int getState(DeviceComponent component)
                      throws InputSystemRuntimeException
This method returns an abstract input-state for the given DeviceComponent. Note, that only supported components are accepted.

Parameters:
component -
Returns:
the current state of the given component on this device.
Throws:
InputSystemRuntimeException

equals

public boolean equals(java.lang.Object o)

Overrides:
equals in class java.lang.Object

setEnabled

public void setEnabled(boolean enabled)
Enables of disables this object.

Specified by:
setEnabled in interface Enableable

isEnabled

public final boolean isEnabled()

Specified by:
isEnabled in interface Enableable
Returns:
if this object is currently enabled.

hasInputStateListener

public final boolean hasInputStateListener()
Returns:
true, of at least one InputStateListener is currently registered.

addInputStateListener

public void addInputStateListener(InputStateListener l)
Adds a new InputStateListener to the list of notified instances.

Parameters:
l -

removeInputStateListener

public void removeInputStateListener(InputStateListener l)
Removes an InputStateListener from the list of notified instances.

Parameters:
l -

fireStateEventsAndDoActions

public void fireStateEventsAndDoActions(InputEvent e,
                                        int delta,
                                        int state)

consumePendingEvents

public abstract void consumePendingEvents(InputSystem is,
                                          EventQueue eventQueue,
                                          long nanoTime)
                                   throws InputSystemException
Processes pending events from the system and simply wastes them.
This method is invoked by the InputSystem when a new InputDevice is registered and instead of the update(InputSystem, EventQueue, long) method, if the device is disabled or its InputSourceWindow doesn't currently receive input events.

Parameters:
is -
eventQueue -
nanoTime -
Throws:
InputSystemException

collectEvents

public abstract void collectEvents(InputSystem is,
                                   EventQueue eventQueue,
                                   long nanoTime)
                            throws InputSystemException
Processes pending events from the system and places them into the EventQueue.
The events are not fired (listeners are not notified). They are fired when the update(InputSystem, EventQueue, long) method is invoked.

Parameters:
is -
eventQueue -
nanoTime -
Throws:
InputSystemException

update

public abstract void update(InputSystem is,
                            EventQueue eventQueue,
                            long nanoTime)
                     throws InputSystemException
Processes pending events from the system and directly fires them (notifes the listeners).
This method also flushes the EventQueue, if the previously called collectEvents(InputSystem, EventQueue, long) method placed events into it.

Parameters:
is -
eventQueue -
nanoTime -
Throws:
InputSystemException

destroy

public abstract void destroy()
                      throws InputSystemException
Destroys the InputDevice. This must be called when the InputDevice is unregistered.

Throws:
InputSystemException