org.deken.game.input
Class Actions

java.lang.Object
  extended by org.deken.game.input.Actions

public class Actions
extends java.lang.Object

Title: Actions

Description: Keeps tracks of inputs from the mouse and keyboards and delegates them to listeners.

Copyright: Copyright (c) Oct 23, 2013

Version:
1.0
Author:
Gary Deken

Field Summary
static int ANY_KEY_ID
           
static int NUM_KEY_CODES
           
static int NUM_MOUSE_CODES
           
 
Constructor Summary
Actions()
           
Actions(InputAction[] keySingleActions, InputAction anyKeyActions, InputMouseAction[] mouseActions)
           
 
Method Summary
 boolean addAnyKeyListener(InputListener listener)
           
 boolean addMouseButtonListener(InputMouseListener listener, InputMonitor.Mouse mouseEnum)
          Takes an InputMouseListener and adds it to a mouse button action, to be notified when the mouse button is pressed.
 boolean addMouseMotionListener(InputMouseListener listener)
          Takes an InputMouseListener and adds it to a mouse move action, to be notified when the mouse is moved.
 boolean addSingleKeyListener(InputListener listener, int keyCode)
          Takes an InputListener and adds it to a single key action, to be notified when the key is pressed.
 void clearAction(InputAction inputAction)
          Deprecated. Not Used
 void clearMouseAction(InputMouseAction inputMouseAction)
          Deprecated. Not Used
 void clearSingleKey(int keyCode)
          Deprecated. Not Used
 InputAction getAnyKeyActions()
          Deprecated. Not Used
 KeyPollMonitor getKeyPollMonitor()
          Returns this instance of the KeyPollMonitor for Objects to use.
protected  InputAction getKeySingleAction(int keyCode)
          Gets the InputAction that is linked to this single key event.
protected  InputMouseAction getMouseAction(int mouseCode)
          Returns the InputMouseAction for the mouseCode
 void mapToMouse(InputMouseAction inputAction, InputMonitor.Mouse mouseEnum)
          Deprecated. Not used
 boolean removeAnyKeyListener(InputListener listener)
          Removes an InputListener from the AnyKeyAction
 boolean removeMouseListener(InputMouseListener listener, InputMonitor.Mouse mouseEnum)
          This removes an InputMouseListener from the MouseList, for the Mouse enum entered.
 boolean removeSingleKeyListener(InputListener listener, int keyCode)
          This removes an InputListener from the Single Key List, for the key code entered.
 void resetAllInputActions()
          Resets all the InputActions.
 void unwireInputListener(int keyID, InputListener inputListener)
          Wires in a key Listener into this action.
 void unwireInputMouseListener(InputMonitor.Mouse mouseAction, InputMouseListener inputMouseListener)
          Wires in a Mouse Listener into this action.
 void wireInputListener(int keyID, InputListener inputListener)
          Wires in a key Listener into this action.
 void wireInputMouseListener(InputMonitor.Mouse mouseAction, InputMouseListener inputMouseListener)
          Wires in a Mouse Listener into this action.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANY_KEY_ID

public static final int ANY_KEY_ID
See Also:
Constant Field Values

NUM_KEY_CODES

public static final int NUM_KEY_CODES
See Also:
Constant Field Values

NUM_MOUSE_CODES

public static final int NUM_MOUSE_CODES
See Also:
Constant Field Values
Constructor Detail

Actions

public Actions()

Actions

public Actions(InputAction[] keySingleActions,
               InputAction anyKeyActions,
               InputMouseAction[] mouseActions)
Method Detail

addAnyKeyListener

public boolean addAnyKeyListener(InputListener listener)
Parameters:
listener -
Returns:
if successful

addSingleKeyListener

public boolean addSingleKeyListener(InputListener listener,
                                    int keyCode)
Takes an InputListener and adds it to a single key action, to be notified when the key is pressed.

Parameters:
listener - InputListener
keyCode - int
Returns:
if successful use wireInputListener().

addMouseButtonListener

public boolean addMouseButtonListener(InputMouseListener listener,
                                      InputMonitor.Mouse mouseEnum)
Takes an InputMouseListener and adds it to a mouse button action, to be notified when the mouse button is pressed.

Parameters:
listener - InputMouseListener
mouseEnum - Mouse
Returns:
if successful use wireInputMouseActionForCode()

addMouseMotionListener

public boolean addMouseMotionListener(InputMouseListener listener)
Takes an InputMouseListener and adds it to a mouse move action, to be notified when the mouse is moved.

Parameters:
listener - InputMouseListener
Returns:
if successful use wireInputMouseActionForCode, using Mouse.MOVE_ANY

clearAction

public void clearAction(InputAction inputAction)
Deprecated. Not Used

clears all mapped keys and mouse actions to this InputAction.

Parameters:
inputAction - InputAction

clearMouseAction

public void clearMouseAction(InputMouseAction inputMouseAction)
Deprecated. Not Used

Parameters:
inputMouseAction -

clearSingleKey

public void clearSingleKey(int keyCode)
Deprecated. Not Used

This clears an InputAction from a single key.

Parameters:
keyCode - int

getAnyKeyActions

public InputAction getAnyKeyActions()
Deprecated. Not Used

Returns the InputAction when any key is pressed.

Returns:
InputAction

getKeyPollMonitor

public KeyPollMonitor getKeyPollMonitor()
Returns this instance of the KeyPollMonitor for Objects to use.

Returns:
KeyPollMonitor

mapToMouse

public void mapToMouse(InputMouseAction inputAction,
                       InputMonitor.Mouse mouseEnum)
Deprecated. Not used

Parameters:
inputAction -
mouseEnum -

removeAnyKeyListener

public boolean removeAnyKeyListener(InputListener listener)
Removes an InputListener from the AnyKeyAction

Parameters:
listener -
Returns:
if successful

removeSingleKeyListener

public boolean removeSingleKeyListener(InputListener listener,
                                       int keyCode)
This removes an InputListener from the Single Key List, for the key code entered.

Parameters:
listener - InputListener
keyCode - int
Returns:
if successful use unwireInputListener().

removeMouseListener

public boolean removeMouseListener(InputMouseListener listener,
                                   InputMonitor.Mouse mouseEnum)
This removes an InputMouseListener from the MouseList, for the Mouse enum entered.

Parameters:
listener - InputMouseListener
mouseEnum - Mouse
Returns:
if successful use unwireInputMouseListener()

resetAllInputActions

public void resetAllInputActions()
Resets all the InputActions.


unwireInputListener

public void unwireInputListener(int keyID,
                                InputListener inputListener)
Wires in a key Listener into this action.

Parameters:
keyID -
inputListener -

unwireInputMouseListener

public void unwireInputMouseListener(InputMonitor.Mouse mouseAction,
                                     InputMouseListener inputMouseListener)
Wires in a Mouse Listener into this action.

Parameters:
mouseAction -
inputMouseListener -

wireInputListener

public void wireInputListener(int keyID,
                              InputListener inputListener)
Wires in a key Listener into this action.

Parameters:
keyID -
inputListener -

wireInputMouseListener

public void wireInputMouseListener(InputMonitor.Mouse mouseAction,
                                   InputMouseListener inputMouseListener)
Wires in a Mouse Listener into this action.

Parameters:
mouseAction -
inputMouseListener -

getKeySingleAction

protected InputAction getKeySingleAction(int keyCode)
Gets the InputAction that is linked to this single key event.

Parameters:
int - keyCode
Returns:
InputAction

getMouseAction

protected InputMouseAction getMouseAction(int mouseCode)
Returns the InputMouseAction for the mouseCode

Parameters:
mouseCode -
Returns:
InputMouseAction