org.deken.game.input
Class InputMonitor

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

public class InputMonitor
extends java.lang.Object

Title: InputMonitor

Description: Manager for handling user input from Mouse and Keyboard.

Copyright: Copyright (c) 2005

Version:
1.0
Author:
Gary Deken

Nested Class Summary
static class InputMonitor.Mouse
           
 
Method Summary
static boolean addAnyKeyListener(InputListener listener)
           
static boolean addMouseButtonListener(InputMouseListener listener, InputMonitor.Mouse mouseEnum)
          addMouseButtonListener Takes an InputMouseListener and adds it to a mouse button action, to be notified when the mouse button is pressed.
static boolean addMouseMotionListener(InputMouseListener listener)
          addMotionListener Takes an InputMouseListener and adds it to a mouse move action, to be notified when the mouse is moved.
static boolean addSingleKeyListener(InputListener listener, int keyCode)
          addKeyListener Takes an InputListener and adds it to a single key action, to be notified when the key is pressed.
 void clearMap(InputAction inputAction)
          Deprecated. Not used
 void clearSingleKey(int keyCode)
          Deprecated. Not used
static InputAction getInputActionForKey(int keyCode, java.lang.String name)
          getInputActionForKey Creates an InputAction with the given name and default key behavior, and maps it to the given key code.
static InputMouseAction getInputMouseActionForCode(InputMonitor.Mouse mouseEnum)
          getInputMouseActionForCode Creates an InputMouseAction with the given name and default behavior, and maps it to the given Mouse enum.
static InputMonitor getInstance()
          getInstance This class is a singleton, allowing inputs to be monitored by one object.
static InputMonitor getInstance(java.awt.Component component)
          getInstance This class is a singleton, allowing inputs to be monitored by one object.
 KeyPollMonitor getKeyPollMonitor()
           
 void mapToMouse(InputMouseAction inputAction, InputMonitor.Mouse mouseEnum)
          Deprecated. Not used
 void registerKeyMultiListener(InputListener inputListener)
          registerKeyMultiListener This registers a new InputListener to the KeyMulitList
 void removeActions()
          Removes the specific Actions, and restores the Global Actions.
static boolean removeAnyKeyListener(InputListener listener)
           
 void removeKeyMultiListener(InputListener inputListener)
          removeKeyMultiListener This removes an InputListener from the KeyMultiList.
static boolean removeMouseButtonListener(InputMouseListener listener, InputMonitor.Mouse mouseEnum)
          removeMouseButtonListener This removes an InputMouseListener from the MouseList, for the Mouse enum entered.
static boolean removeMouseMotionListener(InputMouseListener listener, InputMonitor.Mouse mouseEnum)
          removeMouseMotionListener This removes an InputMouseListener from the Mouse Motion List.
static boolean removeSingleKeyListener(InputListener listener, int keyCode)
          removeSingleKeyListener This removes an InputListener from the Single Key List, for the key code entered.
 void resetAllInputActions()
          resetAllInputActions Resets all Input actions as if they have not been activated.
 void setActions(Actions actions)
           
 void setSource(java.awt.Component component)
          setSource This needs to be set if the source of all event should come from a component within the Frame or Window.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static InputMonitor getInstance()
getInstance This class is a singleton, allowing inputs to be monitored by one object. The InputMonitor uses the AWT window as the source.

Returns:
InputMonitor

getInstance

public static InputMonitor getInstance(java.awt.Component component)
getInstance This class is a singleton, allowing inputs to be monitored by one object. The InputMonitor uses the passed in component as the source.

Parameters:
component - Component
Returns:
InputMonitor

addAnyKeyListener

public static boolean addAnyKeyListener(InputListener listener)

addSingleKeyListener

public static boolean addSingleKeyListener(InputListener listener,
                                           int keyCode)
addKeyListener 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:
boolean

addMouseButtonListener

public static boolean addMouseButtonListener(InputMouseListener listener,
                                             InputMonitor.Mouse mouseEnum)
addMouseButtonListener 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:
boolean

addMouseMotionListener

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

Parameters:
listener - InputMouseListener
Returns:
boolean

removeAnyKeyListener

public static boolean removeAnyKeyListener(InputListener listener)

removeSingleKeyListener

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

Parameters:
listener - InputListener
keyCode - int
Returns:
boolean

removeMouseButtonListener

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

Parameters:
listener - InputMouseListener
mouseEnum - Mouse
Returns:
boolean

removeMouseMotionListener

public static boolean removeMouseMotionListener(InputMouseListener listener,
                                                InputMonitor.Mouse mouseEnum)
removeMouseMotionListener This removes an InputMouseListener from the Mouse Motion List.

Parameters:
listener - InputMouseListener
mouseEnum - Mouse
Returns:
boolean

getInputActionForKey

public static InputAction getInputActionForKey(int keyCode,
                                               java.lang.String name)
getInputActionForKey Creates an InputAction with the given name and default key behavior, and maps it to the given key code.

Parameters:
keyCode - int Use KeyEvent to get key code.
name - String
Returns:
InputAction

getInputMouseActionForCode

public static InputMouseAction getInputMouseActionForCode(InputMonitor.Mouse mouseEnum)
getInputMouseActionForCode Creates an InputMouseAction with the given name and default behavior, and maps it to the given Mouse enum.

Parameters:
mouseEnum - Mouse
Returns:
InputMouseAction

clearMap

public void clearMap(InputAction inputAction)
Deprecated. Not used

clearMap clears all mapped keys and mouse actions to this InputAction.

Parameters:
inputAction - InputAction

clearSingleKey

public void clearSingleKey(int keyCode)
Deprecated. Not used

clearSingleKey This clears an InputAction from a single key.

Parameters:
keyCode - int

getKeyPollMonitor

public KeyPollMonitor getKeyPollMonitor()

mapToMouse

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

mapToMouse This maps an InputAction to a mouse code. The mouse codes are defined in the InputMonitor. If the mouse code already has an InputAction mapped to it, this will replace it with the new InputAction

Parameters:
inputAction - InputAction
mouseEnum - Mouse

registerKeyMultiListener

public void registerKeyMultiListener(InputListener inputListener)
registerKeyMultiListener This registers a new InputListener to the KeyMulitList

Parameters:
inputListener - InputListener

removeKeyMultiListener

public void removeKeyMultiListener(InputListener inputListener)
removeKeyMultiListener This removes an InputListener from the KeyMultiList.

Parameters:
inputListener - InputListener

removeActions

public void removeActions()
Removes the specific Actions, and restores the Global Actions.


resetAllInputActions

public void resetAllInputActions()
resetAllInputActions Resets all Input actions as if they have not been activated.


setActions

public void setActions(Actions actions)
Parameters:
actions -

setSource

public void setSource(java.awt.Component component)
setSource This needs to be set if the source of all event should come from a component within the Frame or Window.

Parameters:
component - Component