How do you change between input layouts?

(another edit)

I put this in “Troubleshooting - GUI” because that seemed to be the best fit, since it’s not GUI but it is UI. It appears to me now that this should have gone in “Troubleshooting - General” Is there a way to move it over there?

(/another edit)



(edit)

I just finally found something that answers part of my question. KeyInputEvent, RawInputListener, and InputManager.addRawInputListener(). These answer the first part.



Now the coupled issue still remains. I have a line with getInputManager().clearMappings() to clear out all the mappings so that I can re-add different mappings; I wanted to do this every time I switch from one keyboard layout to another layout.



jMonkeyPlatform IDE flags that line as being in error, it says that InputManager does not have a clearMappings() method, but I can see it in the documentation! If I try to compile, I do in fact get the same error, that it cannot find the clearMappings() symbol in InputManager. What the heck!?



What is the suggested way to switch back and forth between keyboard layouts? If it is what I am doing, then does anyone have any ideas why I am getting this incorrect error? If it is not what I am doing, then what is suggested instead? Is there a way to change the inputManager that Application is using? As I said before, I see a getInputManager() but not a setInputManager().



(/edit)



(The following is the post I had before I made this edit. I will leave it for context.)



I have two different situations which both call for detecting a key the user has pressed which does not have an action associated with it. First is letting the user remap keys, and second is letting the user type in some text.



At the moment I am making an object which registers an event for every single key, for example…

pre type="java"
getInputManager().addMapping(“0”, new KeyTrigger(KeyInput.KEY_0));


getInputManager().addMapping(“1”, new KeyTrigger(KeyInput.KEY_1));


getInputManager().addMapping(“2”, new KeyTrigger(KeyInput.KEY_2));


getInputManager().addMapping(“3”, new KeyTrigger(KeyInput.KEY_3));


… etc.
/pre



And I noticed that the onAction does not report modifier keys (control, shift, alt) either, so I am adding support for that too.



I also want players to be able to remap keys, which I suppose would also require me to register every single key but to make a different ActionListener to handle it.



These things are done SO often in games that I would think that there would be built-in support for it, but I cannot find any such support anywhere. Does everyone end up continually reinventing this wheel, or am I missing something? Is there some way (other than the silly way I’m starting to do it now) to get an ActionListener or related object that will just report on key codes that are entered instead of manually registered action text strings that are tied to triggers?



And then, to switch to the new remapped keys, or to change back and forth between a text entry mode and a normal input mode, I was going to call inputManager.clearMappings() then re-add the new mappings, but jMonkeyPlatform is telling me that the InputManager class does not have a clearMappings() method, contrary to what the documentation says. I then thought about creating multiple InputManager objects and swapping them, but Application does not have a setInputManager(), only a getInputManager(). So how are we supposed to change the controls?



So to recap:

  1. Is there a decent way to handle arbitrary keyboard input?
  2. How are we supposed to switch between input control layouts?