org.jagatoo.input.handlers
Class ListeningInputHandler<A extends InputAction>

java.lang.Object
  extended by org.jagatoo.input.handlers.InputHandler<A>
      extended by org.jagatoo.input.handlers.ListeningInputHandler<A>
All Implemented Interfaces:
ControllerListener, InputListener, InputStateListener, KeyboardListener, MouseListener, MouseStopListener

public abstract class ListeningInputHandler<A extends InputAction>
extends InputHandler<A>
implements InputListener, InputStateListener

This is a simple InputHandler extension, that additionally implements InputListener and InputStateListener and keeps empty-stub-implementations of these methods like an adapter. It is automatically added as listener to the InputSystem. So you don't have to care about that in any way. (Just override the empty method stubs for the event methods.)


Field Summary
 
Fields inherited from class org.jagatoo.input.handlers.InputHandler
CONTROLLERS_SUSPENDED, FIRST_USER_SUSPEND_FLAG, KEYBOARD_SUSPENDED, MOUSE_BUTTONS_SUSPENDED, MOUSE_MOVEMENT_SUSPENDED, MOUSE_WHEEL_SUSPENDED, suspendMask
 
Constructor Summary
ListeningInputHandler(InputBindingsManager<A> bindingsManager)
           
 
Method Summary
 long getMouseStopDelay()
          
 void onControllerAxisChanged(ControllerAxisChangedEvent e, ControllerAxis axis, float axisDelta)
          
 void onControllerButtonPressed(ControllerButtonPressedEvent e, ControllerButton button)
          
 void onControllerButtonReleased(ControllerButtonReleasedEvent e, ControllerButton button)
          
 void onControllerButtonStateChanged(ControllerButtonEvent e, ControllerButton button, boolean state)
          
 void onInputStateChanged(InputEvent e, DeviceComponent comp, int delta, int state)
          This event is fired, if an input device of any kind changed its state.
 void onKeyPressed(KeyPressedEvent e, Key key)
          Used by implementing input classes to process a key pressed event.
 void onKeyReleased(KeyReleasedEvent e, Key key)
          Used by implementing input classes to process a key released event.
 void onKeyStateChanged(KeyStateEvent e, Key key, boolean state)
          Used by implementing input classes to process a key state changed event.
 void onKeyTyped(KeyTypedEvent e, char keyChar)
          Used by implementing input classes to process a key typed event.
 void onMouseButtonClicked(MouseButtonClickedEvent e, MouseButton button, int clickCount)
          Invoked when a button click was registered by the mouse device.
 void onMouseButtonPressed(MouseButtonPressedEvent e, MouseButton button)
          Invoked when a button press was registered by the mouse device.
 void onMouseButtonReleased(MouseButtonReleasedEvent e, MouseButton button)
          Invoked when a button release was registered by the mouse device.
 void onMouseButtonStateChanged(MouseButtonEvent e, MouseButton button, boolean state)
          Invoked when a button state-change was registered by the mouse device.
 void onMouseMoved(MouseMovedEvent e, int x, int y, int dx, int dy)
          Invoked when a change of the mouse's position was registered by the mouse device while in non-exclusive mode.
 void onMouseStopped(MouseStoppedEvent e, int x, int y)
          Invoked when a change of the mouse's position has not been registered for a certain amount of time.
 void onMouseWheelMoved(MouseWheelEvent e, int wheelDelta)
          Invoked when the mouse wheel has been moved
 void setInputSystem(InputSystem inputSystem)
          
 
Methods inherited from class org.jagatoo.input.handlers.InputHandler
areControllersSuspended, attachToSourceWindow, createInputStatesManager, getAttachedSourceWindow, getBindingsManager, getInputSystem, getStatesManager, getSuspendMask, isKeyboardSuspended, isMouseButtonsSuspended, isMouseMovementSuspended, isMouseSmoothingEnabled, isMouseSuspended, isMouseWheelSuspended, isSuspended, setControllersSuspended, setKeyboardSuspended, setMouseButtonsSuspended, setMouseMovementSuspended, setMouseSmoothingEnabled, setMouseSuspended, setMouseWheelSuspended, setSuspended, setSuspendMask, update, update, updateInputStates
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListeningInputHandler

public ListeningInputHandler(InputBindingsManager<A> bindingsManager)
Method Detail

onKeyPressed

public void onKeyPressed(KeyPressedEvent e,
                         Key key)
Used by implementing input classes to process a key pressed event. This method is generally invoked by Keyboard.

Specified by:
onKeyPressed in interface KeyboardListener
Parameters:
e - the KeyboardEvent, with all assotiated information

onKeyReleased

public void onKeyReleased(KeyReleasedEvent e,
                          Key key)
Used by implementing input classes to process a key released event. This method is generally invoked by Keyboard.

Specified by:
onKeyReleased in interface KeyboardListener
Parameters:
e - the KeyboardEvent, with all assotiated information

onKeyStateChanged

public void onKeyStateChanged(KeyStateEvent e,
                              Key key,
                              boolean state)
Used by implementing input classes to process a key state changed event. This method is generally invoked by Keyboard.

Specified by:
onKeyStateChanged in interface KeyboardListener
Parameters:
e - the KeyboardEvent, with all assotiated information

onKeyTyped

public void onKeyTyped(KeyTypedEvent e,
                       char keyChar)
Used by implementing input classes to process a key typed event. It is not the same as onKeyPressed or onKeyReleased since this even returns a char. It should be used e.g. for widgets which need a text input.

Specified by:
onKeyTyped in interface KeyboardListener
Parameters:
e - the KeyboardEvent, with all assotiated information

onMouseButtonPressed

public void onMouseButtonPressed(MouseButtonPressedEvent e,
                                 MouseButton button)
Invoked when a button press was registered by the mouse device.

Specified by:
onMouseButtonPressed in interface MouseListener
Parameters:
e - the MouseEvent with all assotiated data

onMouseButtonReleased

public void onMouseButtonReleased(MouseButtonReleasedEvent e,
                                  MouseButton button)
Invoked when a button release was registered by the mouse device.

Specified by:
onMouseButtonReleased in interface MouseListener
Parameters:
e - the MouseEvent with all assotiated data

onMouseButtonClicked

public void onMouseButtonClicked(MouseButtonClickedEvent e,
                                 MouseButton button,
                                 int clickCount)
Invoked when a button click was registered by the mouse device.

Specified by:
onMouseButtonClicked in interface MouseListener
Parameters:
e - the MouseEvent with all assotiated data

onMouseButtonStateChanged

public void onMouseButtonStateChanged(MouseButtonEvent e,
                                      MouseButton button,
                                      boolean state)
Invoked when a button state-change was registered by the mouse device.

Specified by:
onMouseButtonStateChanged in interface MouseListener
Parameters:
e - the MouseEvent with all assotiated data

onMouseMoved

public void onMouseMoved(MouseMovedEvent e,
                         int x,
                         int y,
                         int dx,
                         int dy)
Invoked when a change of the mouse's position was registered by the mouse device while in non-exclusive mode.

Specified by:
onMouseMoved in interface MouseListener
Parameters:
e - the MouseEvent with all assotiated data

onMouseWheelMoved

public void onMouseWheelMoved(MouseWheelEvent e,
                              int wheelDelta)
Invoked when the mouse wheel has been moved

Specified by:
onMouseWheelMoved in interface MouseListener
Parameters:
e - the MouseEvent with all assotiated data

getMouseStopDelay

public long getMouseStopDelay()

Specified by:
getMouseStopDelay in interface MouseStopListener
Returns:
the number of nano-seconds, the mouse needs to have stopped to fire this MouseStopListener.

onMouseStopped

public void onMouseStopped(MouseStoppedEvent e,
                           int x,
                           int y)
Invoked when a change of the mouse's position has not been registered for a certain amount of time.

Specified by:
onMouseStopped in interface MouseStopListener
Parameters:
e - the MouseStoppedEvent

onControllerAxisChanged

public void onControllerAxisChanged(ControllerAxisChangedEvent e,
                                    ControllerAxis axis,
                                    float axisDelta)

Specified by:
onControllerAxisChanged in interface ControllerListener

onControllerButtonPressed

public void onControllerButtonPressed(ControllerButtonPressedEvent e,
                                      ControllerButton button)

Specified by:
onControllerButtonPressed in interface ControllerListener

onControllerButtonReleased

public void onControllerButtonReleased(ControllerButtonReleasedEvent e,
                                       ControllerButton button)

Specified by:
onControllerButtonReleased in interface ControllerListener

onControllerButtonStateChanged

public void onControllerButtonStateChanged(ControllerButtonEvent e,
                                           ControllerButton button,
                                           boolean state)

Specified by:
onControllerButtonStateChanged in interface ControllerListener

onInputStateChanged

public void onInputStateChanged(InputEvent e,
                                DeviceComponent comp,
                                int delta,
                                int state)
This event is fired, if an input device of any kind changed its state.

Specified by:
onInputStateChanged in interface InputStateListener
Parameters:
e - the abstract event, that was triggered.
comp - the DeviceComponent, that is responsible for this event
delta - the delta information
state - the absolute state

setInputSystem

public void setInputSystem(InputSystem inputSystem)

Overrides:
setInputSystem in class InputHandler<A extends InputAction>