Mapping to MouseAxisTrigger / KeyTrigger with different speeds


I stumbled across this problem:

My camera can be controled with either keyboard keys or mouse movements.
I made a mapping like those from the FlyByCamera:

inputManager.addMapping(mCamLeft, new MouseAxisTrigger(MouseInput.AXIS_X, false),
new KeyTrigger(KeyInput.KEY_LEFT));[/java]

The problem is:
When I tried it, the mouse speed is very different to the key speed.
The key pressed needs long time for the camera to move. The mouse moved quickly moves the camera.

Usually you would multiply those two with a different forefactor, for example: (keySpeed = 10.0f / mouseSpeed = 1.0f)

This is currently not given, because in my AnalogListener I only get one value and then have the problem described above.

Now, what I do as a workaround is: Have everything mapped twice (three times when I introduce my joystick gamepad, four times when making android touch input).

How could I avoid my workaround and do it properly?
Is there an official solution to this problem?

Your work-around is the only way when using analog listeners. If you use RawInputListener then you get to multiple everything yourself. I don’t think there is an official solution to this problem but InputManager is extremely limited in this area. For example, you’d already have to map twice anything you wanted to do with keys too.

This is why Lemur has InputMapper which wraps InputManager. It lets you use the same listeners for keys, joysticks, and mouse at the same time… they are more appropriately scaled to one another and even still you can change the scaling.

Some of this was described in the first Lemur Gem article I wrote:

1 Like

Thanks very much, I will have a look at Lemur then.
This might help me in my next game.

@Ogli said: Thanks very much, I will have a look at Lemur then. This might help me in my next game. Thanks!

The Lemur jar is small. So even if you don’t use the full GUI, the parts are written to be used separately, ie: you can just use the InputMapper related stuff if you don’t want everything else.