How does MouseInputAction work?

Right now I'm a bit stuck in the jME input handler code. I've been looking at DebugGameState, FirstPersonHandler, MouseLookHandler, RelativeMouse and MouseLook and I'm a bit puzzled how this stuff works together and why it was assembled that way.

In order to understand the input subsystem better I decided upon writing my own simple mouse input handler:

  1. I subclassed InputHandler (let's call it FooInputHandler) and made sure FooInputHandler#update(int tpf) is called during the GameState#update(int tpf) method
  2. FooInputHandler adds a MouseInputAction and prints InputActionEvent#getTriggerName() on every performAction(InputActionEvent evt) call

    As a result the console is flooded with "X Axis" mouse events. It makes no difference wether the mouse is outside the window, inside the window, moved, clicked, etc. Even entirely detaching the mouse device yields the same result. The thing which puzzles me even more that only "X Axis" events are reported - clicking and moving the mouse around (including the Y Axis) don't seam to affect the output at all.

    In the MouseLook#performAction(InputActionEvent evt) code I found that the 'evt' is just being ignored and it relies on the Mouse object instead which must be passed as constructor argument.

    Edit: One thing I should add - I'm using the latest jME from CVS.

You should not subclass InputHandler. I know there are still some very old classes in jME doing this, but the new InputHandler is not meant to be used this way. Have a look at TestInputHandler on how to use it.

I just stumbled across this javadoc for InputHandler#addAction(MouseInputAction mouseAction): "Adds a mouse input action to be invoked each frame."

Now this kinda explains the behaviour. The mouse input action is invoked each frame. Still it doesn't explain the event structure doesn't contain any useful data at all. I just switched to InputHandler#addAction(InputActionInterface action, String deviceName, int button, int axis, boolean allowRepeats) and it yields the result I was expecting.

TestInputHandler really gave me the Idea though there is one thing which doesn't look right to me:

  1. There is an AbsoluteMouse object which renders the cursor to the screen.
  2. The mouse position is reported via the InputAction.

    Isn't it posible that AbsoluteMouse might yield a different position than the InputAction? Having to register two actions - one for rendering the cursor and one for handling the cursor position - just feels wrong to me.