org.jagatoo.input.managers
Class InputBindingsManager<A extends InputAction>

java.lang.Object
  extended by org.jagatoo.input.managers.InputBindingsManager<A>
Direct Known Subclasses:
InputBindingsAdapter

public class InputBindingsManager<A extends InputAction>
extends java.lang.Object

This is a generic input-bindings manager.


Field Summary
protected  DeviceComponent[][] boundKeys
           
protected static int NUM_KEY_SETS
           
 
Constructor Summary
InputBindingsManager(int numCommands)
           
 
Method Summary
 void addInputBindingListener(InputBindingListener<A> l)
           
 InputBindingsSet bind(DeviceComponent comp, A action)
          Binds a key to a specific InputAction at the fist free InputBindingsSet or InputBindingsSet.PRIMARY.
 InputBindingsSet bind(DeviceComponent comp, A action, InputBindingsSet set)
          Binds a key to a specific InputAction.
 A getBoundAction(DeviceComponent comp)
           
 A getBoundAction(DeviceComponent comp, InputBindingsSet set)
           
 java.util.Collection<A> getBoundActions()
           
 void getBoundActions(DeviceComponent[] components, InputAction[] result)
           
 DeviceComponent getBoundComponent(A action, InputBindingsSet set)
           
 java.util.Set<DeviceComponent> getBoundInputComponents()
           
 int getBoundInputComponents(DeviceComponent[] result)
           
 java.util.Map<DeviceComponent,A> getInputBindingsMap()
           
 int getNumActions()
           
protected  void notifyBound(DeviceComponent key, InputBindingsSet set, A action)
           
protected  void notifyUnbound(DeviceComponent key, InputBindingsSet set, A action)
           
 void removeInputBindingListener(InputBindingListener<A> l)
           
 void set(InputBindingsManager<? extends A> bindings)
          Sets the key-bindings Map with the KeyCodes mapped to InputActions.
 void set(InputBindingsManager<? extends A> bindings, boolean clearBefore)
          Sets the key-bindings Map with the KeyCodes mapped to InputActions.
 void setInputBindings(java.util.Map<DeviceComponent,? extends A> inputBindings)
          Sets the key-bindings Map with the KeyCodes mapped to InputActions.
 void setInputBindings(java.util.Map<DeviceComponent,? extends A> inputBindings, boolean clearBefore)
          Sets the key-bindings Map with the KeyCodes mapped to InputActions.
 DeviceComponent unbind(A action)
          Unbinds a key from a specific KeyCommand.
 A unbind(DeviceComponent comp)
          Unbinds a specific key.
 void unbindAll()
          Clears the key bindings Map.
 void unbindAll(InputBindingsSet set)
          Clears the key bindings Map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUM_KEY_SETS

protected static final int NUM_KEY_SETS

boundKeys

protected final DeviceComponent[][] boundKeys
Constructor Detail

InputBindingsManager

public InputBindingsManager(int numCommands)
Method Detail

addInputBindingListener

public final void addInputBindingListener(InputBindingListener<A> l)

removeInputBindingListener

public final void removeInputBindingListener(InputBindingListener<A> l)

notifyBound

protected final void notifyBound(DeviceComponent key,
                                 InputBindingsSet set,
                                 A action)

notifyUnbound

protected final void notifyUnbound(DeviceComponent key,
                                   InputBindingsSet set,
                                   A action)

getNumActions

public final int getNumActions()

getBoundInputComponents

public final java.util.Set<DeviceComponent> getBoundInputComponents()

getBoundInputComponents

public final int getBoundInputComponents(DeviceComponent[] result)

getBoundActions

public final java.util.Collection<A> getBoundActions()

getBoundActions

public final void getBoundActions(DeviceComponent[] components,
                                  InputAction[] result)

unbind

public final A unbind(DeviceComponent comp)
Unbinds a specific key.

Parameters:
comp - the component to unbind
Returns:
the InputAction, this key was previously bound to

unbind

public final DeviceComponent unbind(A action)
Unbinds a key from a specific KeyCommand.

Parameters:
action - the InputAction to un-map from its key
Returns:
the key, that was previously bound to this command.

getBoundAction

public final A getBoundAction(DeviceComponent comp,
                              InputBindingsSet set)
Parameters:
comp - the key of the requested InputAction
set - the InputBindingsSet (may be null for an arbitrary set)
Returns:
the InputAction, that is currently bound to the given key.

getBoundAction

public final A getBoundAction(DeviceComponent comp)
Parameters:
comp - the key of the requested InputAction
Returns:
the InputAction, that is currently bound to the given key.

getBoundComponent

public final DeviceComponent getBoundComponent(A action,
                                               InputBindingsSet set)
Parameters:
action -
set -
Returns:
the key, the given action is bound to.

bind

public final InputBindingsSet bind(DeviceComponent comp,
                                   A action,
                                   InputBindingsSet set)
Binds a key to a specific InputAction.

Parameters:
comp - the key to bind
action - the InputAction to map to the given key
set - the InputBindingsSet the key is to be bound at. (may be null to take the next free set or the PRIMARY)
Returns:
the InputBindingsSet, the key has been bound at.

bind

public final InputBindingsSet bind(DeviceComponent comp,
                                   A action)
Binds a key to a specific InputAction at the fist free InputBindingsSet or InputBindingsSet.PRIMARY.

Parameters:
comp - the key to bind
action - the InputAction to map to the given key
Returns:
the InputBindingsSet, the key has been bound at.

unbindAll

public final void unbindAll(InputBindingsSet set)
Clears the key bindings Map.

Parameters:
set -

unbindAll

public final void unbindAll()
Clears the key bindings Map.


setInputBindings

public final void setInputBindings(java.util.Map<DeviceComponent,? extends A> inputBindings,
                                   boolean clearBefore)
Sets the key-bindings Map with the KeyCodes mapped to InputActions.


setInputBindings

public final void setInputBindings(java.util.Map<DeviceComponent,? extends A> inputBindings)
Sets the key-bindings Map with the KeyCodes mapped to InputActions.


getInputBindingsMap

public java.util.Map<DeviceComponent,A> getInputBindingsMap()
Returns:
a Map with the KeyCodes mapped to InputActions.

set

public final void set(InputBindingsManager<? extends A> bindings,
                      boolean clearBefore)
Sets the key-bindings Map with the KeyCodes mapped to InputActions.


set

public final void set(InputBindingsManager<? extends A> bindings)
Sets the key-bindings Map with the KeyCodes mapped to InputActions.