|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jme.input.InputHandler
public class InputHandler
InputHandler handles mouse, key and other inputs. Actions can be subscribed for specific event triggers.
InputActionInterface.performAction(InputActionEvent) is invoked within the update(float) method whenever the
trigger criterias match. For a usage example see TestInputHandler. InputHandler is also used to decouple event
occurence and action invocation (see ActionTrigger) - an event may occur in another thread (e.g. polling
thread) but the action is still invoked in the thread that is calling the update(float) method.
You can add custom devices via the addDevice(InputHandlerDevice) method.
| Field Summary | |
|---|---|
static int |
AXIS_ALL
int value for representing all axes (wildcard). |
static int |
AXIS_NONE
int value for representing no axis. |
static int |
BUTTON_ALL
int value for representing all buttons/keys (wildcard). |
static int |
BUTTON_NONE
int value for representing no button/key. |
static String |
DEVICE_ALL
Wildcard device name for all devices. |
static String |
DEVICE_KEYBOARD
Device name of the keyboard. |
static String |
DEVICE_MOUSE
Device name of the mouse. |
| Constructor Summary | |
|---|---|
InputHandler()
Creates a new input handler. |
|
| Method Summary | |
|---|---|
void |
addAction(InputActionInterface inputAction,
String triggerCommand,
boolean allowRepeats)
Adds an input action to be invoked by this handler during update. |
void |
addAction(InputActionInterface inputAction,
String triggerCommand,
int keyCode,
boolean allowRepeats)
Registeres a single key as command in KeyBindingManager and adds an input
action to be invoked by this handler during update. |
void |
addAction(InputActionInterface action,
String deviceName,
int button,
int axis,
boolean allowRepeats)
Adds an input action to be invoked on deviceName button or axis events. |
void |
addAction(InputAction action,
SyntheticAxis eventHandler,
boolean allowRepeats)
Adds an input action to be invoked on events for the given synthetic axis. |
void |
addAction(InputAction action,
SyntheticButton eventHandler,
boolean allowRepeats)
Adds an input action to be invoked on events for the given synthetic button. |
void |
addAction(MouseInputAction mouseAction)
Adds a mouse input action to be invoked each frame. |
static void |
addDevice(InputHandlerDevice device)
Add a device to the InputHandlers. |
boolean |
addToAttachedHandlers(InputHandler value)
Attach a handler which should be updated in this handlers update method. |
void |
clearActions()
Clears all actions currently registered. |
static boolean |
getBooleanProp(HashMap<String,Object> props,
String key,
boolean defaultVal)
|
static Collection<InputHandlerDevice> |
getDevices()
|
static float |
getFloatProp(HashMap<String,Object> props,
String key,
float defaultVal)
|
InputHandler |
getFromAttachedHandlers(int index)
Get an element from the attachedHandlers association. |
static int |
getIntProp(HashMap<String,Object> props,
String key,
int defaultVal)
|
static Object |
getObjectProp(HashMap<String,Object> props,
String key,
Object defaultVal)
|
InputHandler |
getParent()
Query parent handler. |
boolean |
isEnabled()
|
void |
removeAction(InputActionInterface inputAction)
Removes a keyboard input action from the list of keyActions that are polled during update. |
void |
removeAction(String triggerCommand)
Removes a keyboard input action from the list of keyActions that are polled during update. |
void |
removeAllActions()
Removes all actions and triggers from this handler. |
void |
removeAllFromAttachedHandlers()
|
boolean |
removeFromAttachedHandlers(InputHandler value)
|
void |
setActionSpeed(float speed)
Sets the speed of all actions currently registered with this handler to the given value. |
void |
setActionSpeed(float speed,
String trigger)
|
void |
setEnabled(boolean value)
Enable/disable the handler: disabled handler do not invoke actions and do not update attached handlers. |
void |
setEnabledOfAttachedHandlers(boolean enabled)
enabled/disables all attached handlers but this handler keeps its status. |
int |
sizeOfAttachedHandlers()
|
void |
update(float time)
Checks all actions to see if they should be invoked. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEVICE_MOUSE
addAction(com.jme.input.action.InputActionInterface,String,int,int,boolean),
Constant Field Valuespublic static final String DEVICE_KEYBOARD
addAction(com.jme.input.action.InputActionInterface,String,int,int,boolean),
Constant Field Valuespublic static final String DEVICE_ALL
addAction(com.jme.input.action.InputActionInterface,String,int,int,boolean),
Constant Field Valuespublic static final int BUTTON_NONE
addAction(com.jme.input.action.InputActionInterface,String,int,int,boolean),
Constant Field Valuespublic static final int BUTTON_ALL
addAction(com.jme.input.action.InputActionInterface,String,int,int,boolean),
Constant Field Valuespublic static final int AXIS_NONE
addAction(com.jme.input.action.InputActionInterface,String,int,int,boolean),
Constant Field Valuespublic static final int AXIS_ALL
addAction(com.jme.input.action.InputActionInterface,String,int,int,boolean),
Constant Field Values| Constructor Detail |
|---|
public InputHandler()
| Method Detail |
|---|
public void setActionSpeed(float speed)
speed - The new speed for all currently registered actions.InputAction.setSpeed(float)
public void setActionSpeed(float speed,
String trigger)
public void addAction(InputActionInterface inputAction,
String triggerCommand,
boolean allowRepeats)
inputAction - the input action to be addedtriggerCommand - the command to trigger this action (registered with KeyBindingManager), if null
the action is invoked on each call of update(float)allowRepeats - true to invoke the action every call of update the trigger is lit, false to invoke
public void addAction(InputActionInterface inputAction,
String triggerCommand,
int keyCode,
boolean allowRepeats)
KeyBindingManager and adds an input
action to be invoked by this handler during update.
inputAction - the input action to be addedtriggerCommand - the command to trigger this action, may not be null (unlike in
addAction(com.jme.input.action.InputActionInterface,String,boolean))keyCode - the keyCode to register at KeyBindingManager for the commandallowRepeats - true to invoke the action every call of update the trigger is lit, false to invoke
public void addAction(InputAction action,
SyntheticButton eventHandler,
boolean allowRepeats)
InputActionEvent.getTrigger* methods.
action - the input action to be addedallowRepeats - false to invoke action once for each button down, true to invoke each frame while theeventHandler - button
public void addAction(InputAction action,
SyntheticAxis eventHandler,
boolean allowRepeats)
InputActionEvent.getTrigger* methods.
action - the input action to be addedallowRepeats - false to invoke action once for each button down, true to invoke each frame while theeventHandler - axispublic void addAction(MouseInputAction mouseAction)
addAction(com.jme.input.action.InputActionInterface,String,int,int,boolean) to add actions that
are invoked on mouse events.
mouseAction - The input action to be addedpublic static Collection<InputHandlerDevice> getDevices()
public static void addDevice(InputHandlerDevice device)
DEVICE_ALL before device was added will not receive device events).
device - new deviceInputHandlerDevice
public void addAction(InputActionInterface action,
String deviceName,
int button,
int axis,
boolean allowRepeats)
InputActionEvent.getTrigger* methods.
action - the input action to be addeddeviceName - name of the deviceName: DEVICE_MOUSE, DEVICE_KEYBOARD,
a joystick name or DEVICE_ALLbutton - index of the button that triggers this event, BUTTON_NONE for no button,
BUTTON_ALL for all buttons. (for keyboad deviceName this is a key code).
If DEVICE_ALL is specified button will not be interpreted as key code, thus
keyboard input is only regarded if BUTTON_ALL is specified inthis case.axis - index of the axis that triggers this event, AXIS_NONE for no axis,
AXIS_ALL for all axesallowRepeats - false to invoke action once for each button down, true to invoke each frame while thepublic void removeAction(InputActionInterface inputAction)
inputAction - The action to remove.public void removeAction(String triggerCommand)
triggerCommand - the command that should be removedpublic void removeAllActions()
public void clearActions()
public void update(float time)
InputActionInterface.performAction(InputActionEvent) is called on the action with the given time.
isEnabled() and return immediately if it evaluates to false.
InputHandlerDevices.
time - The time to pass to every action that is active.addAction(com.jme.input.action.InputActionInterface,String,boolean)
public static float getFloatProp(HashMap<String,Object> props,
String key,
float defaultVal)
public static int getIntProp(HashMap<String,Object> props,
String key,
int defaultVal)
public static boolean getBooleanProp(HashMap<String,Object> props,
String key,
boolean defaultVal)
public static Object getObjectProp(HashMap<String,Object> props,
String key,
Object defaultVal)
public boolean isEnabled()
public void setEnabled(boolean value)
value - true to enable the handler, false to disable the handlerpublic void setEnabledOfAttachedHandlers(boolean enabled)
enabled - true to enable all attached handlers, false to disable thempublic boolean addToAttachedHandlers(InputHandler value)
value - handler to attach
public InputHandler getFromAttachedHandlers(int index)
index - index of element to be retrieved
public void removeAllFromAttachedHandlers()
public boolean removeFromAttachedHandlers(InputHandler value)
public int sizeOfAttachedHandlers()
public InputHandler getParent()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||