I don’t believe that the current InputManager handles modifiers (Shift, Control, Alt, Meta). I hacked into InputManager.java and added that capability - once for all. For example, you can use numpad3 and numpad4, for left and right strafing and use Control numpad3 and Control numpad4 for left and right turn. The old interface is still intact. The change required me to add a field to the (private) Mapping class and then test it before calling onAction(). Also, while testing I discovered that if you let up a modifier key with another key pressed, it doesn’t turn off when you let the key up (because the modifiers have changed). Ergo, I added a list to keep track of the current actions and send them a isPressed=false when you change the modifiers. If you’re rotating and you let the Control key up, it will turn off rotating thrust (not rotating momentum).
It works on three levels.
You can 1) use it without modifiers like the old interface (only calling onAction(String, boolean, float)). Or you can 2) use it with basic modifiers, Shift, Control, etc., (onAction(String, boolean, int, float)) or you can 3) use it to check individule modifier keys like LeftShift or RightShift, LeftControl or RightControl. You can use the modifier keys with the joystick, mouse, and tablet, too.
To try it out or use it, I have an InputManagerModifiersTest.
- Make a new project, i.e. \Modifiers
- Copy the sources from C:\Program Files\jmonkeyplatform\jmonkeyplatform\libs\jMonkeyEngine3-sources.zip into your \Modifiers project/s, src directory. Put my InputManager.java into the com.jme3.input directory and then open Main.java and compile. You’ll have to modify all the classes that have onAction() in them. The compiler will tell you what files to fix. See below for a list.
- Make a new folder in a JME\libs\JME3-core.dir.
Copy com, Common, Interface, Jme3tools into JME\libs\JME-core.dir. Then in your other projects, refer to JME\libs\JME3-core.dir. If you set the InputManager.java setEcho(true), it will print debug info and show you what it’s thinking. If you have menus and you hit the Alt key, you may have to hit Alt-Esc or Alt-Tab.
I have everything on Github.
Files to be modified
\controls\ActionListener.java
\input\ChaseCamera.java
\input\FlyByCamera.java
(I hope that this isn’t too over the top for the developers. If it is, all you can do is cancel my account…)