Masking input at Binding


is it possible and how to do it, to mask the input of Bindings with modifier keys? Ie. I want to activate two different GameControls depending if I press F4 or Alt+F4, or I want different mouse actions to occur if I keep LShift down.


Well you could do this:

KeyBindingManager.getKeyBindingManager().set( "toggle_mode", new int[] {KeyInput.KEY_SPACE, KeyInput.KEY_LSHIFT } );

But there seems to be problem with it (at least IMO) in that both keys must be released/pressed (cant hold l_shift and press/release space); at least on OSX.

OR if you are using LWJGL (or at least including it) you can use:

Keyboard.isKeyDown( Keyboard.KEY_LSHIFT );

To detect if the l_shift key is down...


thank you for the effort to answer, however:

Solution no.1 is meant to work with InputHandler input framework (correct me if I'm wrong). We are using GameControlManager and I would like not to use two input systems if possible, as mentioned in question (Binding was refering to implementation of com.jme.input.controls.Binding interface).

Solution no.2 would work, but we try to keep underlying rendering/input/audio implementations abstract (since JME tries to abstract them itself and does it pretty well), and my original question was more aiming to more detailed problem.

This is an pseudo-example of how would I like it to work.

GameControl exitControl = gameControlManager.addControl(Controls.CID_EXIT);
exitControl.addBinding(new KeyboardBinding(KeyInput.KEY_F4 | KeyInput.MOD_LALT);


exitControl.addBinding(new KeyboardBinding(KeyInput.KEY_F4, KeyInput.MOD_LALT);

You can also check java.awt.event.KeyEvent and java.awt.event.InputEvent for reference of how Sun solved it.
Is this theoretically possible to achieve, even if code for this does not exists yet? If its not possible, I'm thinking of creating decorator-binding which will allow decorated binding to return value different than 0.0F only if configured modifier keys are pressed. Both implementations are offered to you as patches when I'm done.

All that mentioned, some keys are missing from KeyInput constant list. For example, numpad + - * /, and both Alt keys. Is there any reason for it (platform independence)?


Hm :frowning: bump?