(Solved) Adding input handler to GameStates?

I am using standard game and I am not sure how input handlers are supposed to be used with it.  I noticed DebugGameState has its own input handler, but I couldn't find a way to give my own gameState an input handler.

Have you looked at the source for DebugGameState? It should be as easy creating an input handler and adding it to your game states update() method, like below…



    // In your game state
    protected InputHandler input;
    ....
   
    // In constructor
    input = new FirstPersonHandler(DisplaySystem.getDisplaySystem().getRenderer().getCamera(), 15.0f, 0.5f);   //(or whatever handler you want)
    KeyBindingManager.getKeyBindingManager().set("exit", KeyInput.KEY_ESCAPE);
    ....

    // In update()
    input.update(tpf);

    if (KeyBindingManager.getKeyBindingManager().isValidCommand("exit", false)) {
               System.exit(0);
    }



Any questions?

Thanks for the info.

Thanks for the info on this! I found this solution very elegant and easy to incorporate in my GameState-based design. Thanks.