Class InputMode
- All Implemented Interfaces:
com.jme3.app.state.AppState
,com.jme3.input.controls.ActionListener
,com.jme3.input.controls.InputListener
- Direct Known Subclasses:
DefaultInputMode
,DsEditInputMode
Modes may be temporarily suspended, in which the case the underlying app state remains enabled even though the mode is considered inactive.
The active mode maps hotkeys to actions and controls the appearance of the mouse pointer/cursor. Hotkeys can be mapped to signal actions, which cause multiple keys (shift or control keys, for exampled) to share a common modal function.
When a hotkey binding is live in the input manager, the hotkey is said to be "mapped". When an input mode is inactive, its hotkey bindings persist, allowing them to be altered, loaded, and saved even though they are unmapped.
Hotkeys are bound to action names. The input manager, however, stores "action strings". For non-signal actions, the action string is identical to the action name. For an action which updates a signal, the action name consists of "signal " followed by the name of the signal. In that case, a space and decimal keycode are appended to the action name generate a unique action string for each signal source.
Input modes are disabled at creation.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
action-string prefix for a combo actionstatic final String
action-string prefix for a signal actionFields inherited from class jme3utilities.SimpleAppState
assetManager, cam, flyCam, guiNode, guiViewPort, inputManager, renderManager, rootNode, simpleApplication, stateManager, viewPort
Fields inherited from class com.jme3.app.state.AbstractAppState
initialized
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
activate()
Activate this mode.void
addActionName
(String name) Add the specified action name without binding anything to it.void
Bind the named action to the specified key codes, but don't map it yet.void
Bind the named action to the named hotkey, but don't map it yet.void
Bind the named action to the specified Combo.void
Bind the named action to the specified hotkey, but don't map it yet.void
Bind the named action to the named hotkey, but don't map it yet.boolean
Test whether this input mode binds the specified hotkey.void
bindSignal
(String signalName, int... keyCodes) Bind the named signal to the specified key codes, but don't map it yet.void
bindSignal
(String signalName, String usHotkeyName) Bind the named signal to the named hotkey, but don't map it yet.Determine the path to the bindings asset.protected void
Deactivate this mode.protected abstract void
Add the default hotkey bindings: the bindings to be used if no custom bindings are found.findActionName
(Hotkey hotkey) Look up the action bound to a hotkey.static InputMode
Find an initialized mode by its short name.static InputMode
Access the active mode, if any.com.jme3.cursors.plugins.JmeCursor
Access the cursor for this mode, if any.void
initialize
(com.jme3.app.state.AppStateManager stateManager, com.jme3.app.Application application) Initialize this (disabled) mode prior to its first update.List all known action names.listCombos
(String actionName) Enumerate all combos bound to the named action.listHotkeysLocal
(String actionName) Enumerate all hotkeys bound to a named action.void
Load a set of hotkey bindings from the configuration asset.protected void
mapAll()
Map all Hotkey and Combo actions.static void
Disable the active input mode and resume the most recently suspended mode.boolean
Save all hotkey bindings to the configuration asset.void
setConfigPath
(String assetPath) Alter the path to the configuration asset for bindings.void
setCursor
(com.jme3.cursors.plugins.JmeCursor newCursor) Alter the mouse cursor for this uninitialized mode.void
setEnabled
(boolean newState) Enable or disable this mode.Determine the short-form name for this mode.static void
suspendAndActivate
(InputMode newMode) Save and suspend the active input mode (if any) and activate the specified mode.toString()
Represent this input mode as a text string.void
unbind
(int keyCode) Unbind the specified keyboard key.void
Unbind the specified hotkey.protected void
unmapAll()
Unmap all Hotkey and Combo actions.Methods inherited from class jme3utilities.ui.AcorusAppState
getActionApplication, getSignals, getSpeed
Methods inherited from class jme3utilities.SimpleAppState
refreshCachedFields, render, stateDetached
Methods inherited from class jme3utilities.NamedAppState
cleanup, getInfluence, hasInfluenceOver, influence, isEnabled, isInitialized, postRender, stateAttached, stopInfluencing, update
Methods inherited from class com.jme3.app.state.AbstractAppState
getId, setId
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.jme3.input.controls.ActionListener
onAction
-
Field Details
-
comboActionPrefix
action-string prefix for a combo action- See Also:
-
signalActionPrefix
action-string prefix for a signal action- See Also:
-
-
Constructor Details
-
InputMode
Instantiate a disabled, uninitialized mode.- Parameters:
name
- terse name for the mode (not null)
-
-
Method Details
-
addActionName
Add the specified action name without binding anything to it.- Parameters:
name
- action name (not null)
-
bind
Bind the named action to the specified Combo. Any existing binding for the Combo is removed.- Parameters:
actionName
- name of the action (not null)combo
- which Combo to bind (not null)
-
bind
Bind the named action to the specified hotkey, but don't map it yet. Any existing binding for the hotkey is removed.- Parameters:
actionName
- name of the action (not null)hotkey
- which hotkey to bind (not null)
-
bind
Bind the named action to the specified key codes, but don't map it yet. Any existing bindings for those keys are removed.- Parameters:
actionName
- the name of the action (not null)keyCodes
- key codes fromKeyInput
-
bind
Bind the named action to the named hotkey, but don't map it yet. Any existing binding for the hotkey is removed.- Parameters:
actionName
- the name of the action (not null)usHotkeyName
- the hotkey's US name (not null)
-
bindLocal
Bind the named action to the named hotkey, but don't map it yet. Any existing binding for the hotkey is removed.- Parameters:
actionName
- the name of the action (not null)localHotkeyName
- the hotkey's local name (not null)
-
binds
Test whether this input mode binds the specified hotkey.- Parameters:
hotkey
- hotkey to test (not null)- Returns:
- true if bound, otherwise false
-
bindSignal
Bind the named signal to the specified key codes, but don't map it yet. Any existing bindings for those keys are removed.- Parameters:
signalName
- the name of the signal (not null)keyCodes
- key codes fromKeyInput
-
bindSignal
Bind the named signal to the named hotkey, but don't map it yet. Any existing binding for the hotkey is removed.- Parameters:
signalName
- the name of the signal (not null)usHotkeyName
- the hotkey's US name (not null)
-
configPath
Determine the path to the bindings asset.- Returns:
- the current asset path (or null if the bindings are not loadable/savable)
-
findActionName
Look up the action bound to a hotkey.- Parameters:
hotkey
- (not null)- Returns:
- the hotkey's action name, or null if the hotkey isn't bound
-
findMode
Find an initialized mode by its short name.- Parameters:
shortName
- (not null)- Returns:
- pre-existing instance (or null if none)
-
getActiveMode
Access the active mode, if any.- Returns:
- the pre-existing instance (or null if none active)
-
getCursor
public com.jme3.cursors.plugins.JmeCursor getCursor()Access the cursor for this mode, if any.- Returns:
- the pre-existing instance (or null if hidden)
-
listActionNames
List all known action names.- Returns:
- a new list
-
listCombos
Enumerate all combos bound to the named action.- Parameters:
actionName
- the action name (not null)- Returns:
- a new collection of combos
-
listHotkeysLocal
Enumerate all hotkeys bound to a named action.- Parameters:
actionName
- the name of an action (not null)- Returns:
- a new collection of local names in lexicographic order
-
loadBindings
public void loadBindings()Load a set of hotkey bindings from the configuration asset. -
resumeLifo
public static void resumeLifo()Disable the active input mode and resume the most recently suspended mode. -
saveBindings
public boolean saveBindings()Save all hotkey bindings to the configuration asset.- Returns:
- true if successful, otherwise false
-
setConfigPath
Alter the path to the configuration asset for bindings.- Parameters:
assetPath
- the desired asset path (or null to make the bindings not loadable/savable)
-
setCursor
public void setCursor(com.jme3.cursors.plugins.JmeCursor newCursor) Alter the mouse cursor for this uninitialized mode.- Parameters:
newCursor
- new cursor, or null to hide the cursor when active
-
shortName
Determine the short-form name for this mode.- Returns:
- name (not null)
-
suspendAndActivate
Save and suspend the active input mode (if any) and activate the specified mode.- Parameters:
newMode
- the desired input mode, or null for none
-
unbind
Unbind the specified hotkey.- Parameters:
hotkey
- (not null)
-
unbind
public void unbind(int keyCode) Unbind the specified keyboard key.- Parameters:
keyCode
- the key code
-
activate
protected void activate()Activate this mode. -
deactivate
protected void deactivate()Deactivate this mode. -
defaultBindings
protected abstract void defaultBindings()Add the default hotkey bindings: the bindings to be used if no custom bindings are found. -
mapAll
protected void mapAll()Map all Hotkey and Combo actions. -
unmapAll
protected void unmapAll()Unmap all Hotkey and Combo actions. -
initialize
public void initialize(com.jme3.app.state.AppStateManager stateManager, com.jme3.app.Application application) Initialize this (disabled) mode prior to its first update.- Specified by:
initialize
in interfacecom.jme3.app.state.AppState
- Overrides:
initialize
in classAcorusAppState
- Parameters:
stateManager
- (not null)application
- (not null)
-
setEnabled
public void setEnabled(boolean newState) Enable or disable this mode.- Specified by:
setEnabled
in interfacecom.jme3.app.state.AppState
- Overrides:
setEnabled
in classjme3utilities.NamedAppState
- Parameters:
newState
- true to enable, false to disable
-
toString
Represent this input mode as a text string.- Overrides:
toString
in classjme3utilities.NamedAppState
- Returns:
- descriptive string of text (not null)
-