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

java.lang.Object
  extended by org.jagatoo.input.handlers.InputHandler<A>
Direct Known Subclasses:
ListeningInputHandler

public abstract class InputHandler<A extends InputAction>
extends java.lang.Object

This is the abstract base class for all InputHandlers.

And InputHandler should be used instead of simple input-listener-code, if continous movements are to be applied to objects, that obviously need the current input-state, but not reactions of state-changes.

The InputHandler keeps instances of InputBindingsManager and InputStatesManager and uses them to manage input-states.


Field Summary
static int CONTROLLERS_SUSPENDED
           
static int FIRST_USER_SUSPEND_FLAG
           
static int KEYBOARD_SUSPENDED
           
static int MOUSE_BUTTONS_SUSPENDED
           
static int MOUSE_MOVEMENT_SUSPENDED
           
static int MOUSE_WHEEL_SUSPENDED
           
protected  int suspendMask
           
 
Constructor Summary
InputHandler(InputBindingsManager<A> bindingsManager)
           
 
Method Summary
 boolean areControllersSuspended()
           
 void attachToSourceWindow(InputSourceWindow inputSourceWindow)
          Attaches this InputHandler to a certain InputSourceWindow.
protected  InputStatesManager createInputStatesManager(InputBindingsManager<A> bindingsManager)
           
 InputSourceWindow getAttachedSourceWindow()
           
 InputBindingsManager<A> getBindingsManager()
           
 InputSystem getInputSystem()
          
 InputStatesManager getStatesManager()
           
 int getSuspendMask()
           
 boolean isKeyboardSuspended()
           
 boolean isMouseButtonsSuspended()
           
 boolean isMouseMovementSuspended()
           
 boolean isMouseSmoothingEnabled()
           
 boolean isMouseSuspended()
           
 boolean isMouseWheelSuspended()
           
 boolean isSuspended()
           
 void setControllersSuspended(boolean suspended)
           
 void setInputSystem(InputSystem inputSystem)
          
 void setKeyboardSuspended(boolean suspended)
           
 void setMouseButtonsSuspended(boolean suspended)
           
 void setMouseMovementSuspended(boolean suspended)
           
 void setMouseSmoothingEnabled(boolean enabled)
          Enables or disables mouse-smoothing.
 void setMouseSuspended(boolean suspended)
           
 void setMouseWheelSuspended(boolean suspended)
           
 void setSuspended(boolean suspended)
          Suspends or resumes this InputHandler.
 boolean setSuspendMask(int suspendMask)
          Suspends or resumes this InputHandler.
 void update(long nanoTime)
          This method is called by the InputSystem (each frame) to update the InputHandler.
abstract  void update(long nanoSeconds, float seconds, long nanoFrame, float frameSeconds)
          This method is called by the InputSystem (each frame) to update the InputHandler.
protected  void updateInputStates(long nanoTime)
          Must be invoked each frame (if not keyboard is suspended).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MOUSE_MOVEMENT_SUSPENDED

public static final int MOUSE_MOVEMENT_SUSPENDED
See Also:
Constant Field Values

MOUSE_BUTTONS_SUSPENDED

public static final int MOUSE_BUTTONS_SUSPENDED
See Also:
Constant Field Values

MOUSE_WHEEL_SUSPENDED

public static final int MOUSE_WHEEL_SUSPENDED
See Also:
Constant Field Values

KEYBOARD_SUSPENDED

public static final int KEYBOARD_SUSPENDED
See Also:
Constant Field Values

CONTROLLERS_SUSPENDED

public static final int CONTROLLERS_SUSPENDED
See Also:
Constant Field Values

FIRST_USER_SUSPEND_FLAG

public static final int FIRST_USER_SUSPEND_FLAG
See Also:
Constant Field Values

suspendMask

protected int suspendMask
Constructor Detail

InputHandler

public InputHandler(InputBindingsManager<A> bindingsManager)
Method Detail

getBindingsManager

public InputBindingsManager<A> getBindingsManager()

getStatesManager

public InputStatesManager getStatesManager()

setMouseSmoothingEnabled

public void setMouseSmoothingEnabled(boolean enabled)
Enables or disables mouse-smoothing.

Parameters:
enabled -

isMouseSmoothingEnabled

public final boolean isMouseSmoothingEnabled()
Returns:
if mouse-smoothing is enabled.

setSuspendMask

public boolean setSuspendMask(int suspendMask)
Suspends or resumes this InputHandler.

Parameters:
suspendMask -
See Also:
MOUSE_MOVEMENT_SUSPENDED, MOUSE_BUTTONS_SUSPENDED, MOUSE_WHEEL_SUSPENDED, KEYBOARD_SUSPENDED, If an InputHandler is suspended, it will ignore any input.

getSuspendMask

public final int getSuspendMask()
Returns:
the suspendMask.
See Also:
MOUSE_MOVEMENT_SUSPENDED, MOUSE_BUTTONS_SUSPENDED, MOUSE_WHEEL_SUSPENDED, KEYBOARD_SUSPENDED, If an InputHandler is suspended, it will ignore any input.

setMouseMovementSuspended

public final void setMouseMovementSuspended(boolean suspended)

isMouseMovementSuspended

public final boolean isMouseMovementSuspended()

setMouseButtonsSuspended

public final void setMouseButtonsSuspended(boolean suspended)

isMouseButtonsSuspended

public final boolean isMouseButtonsSuspended()

setMouseWheelSuspended

public final void setMouseWheelSuspended(boolean suspended)

isMouseWheelSuspended

public final boolean isMouseWheelSuspended()

setMouseSuspended

public final void setMouseSuspended(boolean suspended)

isMouseSuspended

public final boolean isMouseSuspended()

setKeyboardSuspended

public final void setKeyboardSuspended(boolean suspended)

isKeyboardSuspended

public final boolean isKeyboardSuspended()

setControllersSuspended

public final void setControllersSuspended(boolean suspended)

areControllersSuspended

public final boolean areControllersSuspended()

attachToSourceWindow

public void attachToSourceWindow(InputSourceWindow inputSourceWindow)
Attaches this InputHandler to a certain InputSourceWindow. If this is not null, then the InputHandler will only receive input events, if the given InputSourceWindow's InputSourceWindow.receivesInputEvents() method returns true.

Parameters:
inputSourceWindow -

getAttachedSourceWindow

public final InputSourceWindow getAttachedSourceWindow()
Parameters:
inputSourceWindow -
Returns:
the attached InputSourceWindow. If this is not null, then the InputHandler will only receive input events, if the given InputSourceWindow's InputSourceWindow.receivesInputEvents() method returns true.

setSuspended

public void setSuspended(boolean suspended)
Suspends or resumes this InputHandler.

If an InputHandler is suspended, it will ignore any input.

Parameters:
suspended -

isSuspended

public final boolean isSuspended()
Returns:
if this InputHandler is currently suspended.

If an InputHandler is suspended, it will ignore any input.

updateInputStates

protected void updateInputStates(long nanoTime)
Must be invoked each frame (if not keyboard is suspended).


update

public abstract void update(long nanoSeconds,
                            float seconds,
                            long nanoFrame,
                            float frameSeconds)
                     throws InputSystemException
This method is called by the InputSystem (each frame) to update the InputHandler.

Parameters:
nanoSeconds -
seconds -
nanoFrame -
frameSeconds -
Throws:
InputSystemException

update

public final void update(long nanoTime)
                  throws InputSystemException
This method is called by the InputSystem (each frame) to update the InputHandler.

Parameters:
nanoTime -
Throws:
InputSystemException

setInputSystem

public void setInputSystem(InputSystem inputSystem)


getInputSystem

public final InputSystem getInputSystem()


createInputStatesManager

protected InputStatesManager createInputStatesManager(InputBindingsManager<A> bindingsManager)