Multiple InputListeners

Hey girls and guys,

Is it not possible to add multiple InputListeners to the InputManager of a SimpleApplication? In my code this segment appears:

    handler[0] = new GamepadInmenuHandler(0);
    handler[0] .init(app.getInputManager());
    app.getInputManager().addListener(handler[0], handler[0].getActions());
    kHandler = new KeyboardInmenuHandler();
    app.getInputManager().addListener(kHandler, kHandler.getActions());

The first section is supposed to register a listener which listens to gamepad input, the latter is supposed to react to keyboard input. But when I do this, only keyboard input works - but when I swap these two paragraph’s position only gamepad input works. So it seems to me the InputManager is only supposed to have one listener and assigning one then more results in the first one to be overwritten?

You can have as many listeners as you want… even for the same ‘actions’.

Your problem is elsewhere.

I do not have the slightest idea where my problem lies. The code from above is executed in the initialize method of an AppState. When I comment out one of the InputListener registrations the other works perfectly fine. Do I have to use a different method than “addListener(handler, actions)” ?

What does “working” mean? How do you know? What other assumptions have you made that may be false.

Put a System.out.println() in your listener’s method that is at the very beginning of the method with no other logic before it. When that gets printed fine, then you can figure out where your logic was wrong before.