[SOLVED] Simple way to detect when mouse moves?

So, after finally being able to make my GUI responsive, I want to make it fade when the mouse is idle for more than 10 seconds. For that, I looked if there was a simple method or way to detect when the user moves the cursor.

What I’m currently doing (since I couldn’t find a “clean” way) was to add 4 triggers, each corresponding to an axis and/or negative/positive movement:

inputManager.addMapping("MouseMoved", new MouseAxisTrigger(MouseInput.AXIS_X, true),
                                        new MouseAxisTrigger(MouseInput.AXIS_X, false),
                                        new MouseAxisTrigger(MouseInput.AXIS_Y, true),
                                        new MouseAxisTrigger(MouseInput.AXIS_Y, false));

But for me, it feels kinda “dirty”. I also thought of having a local Vector2f that would be the cursor’s position and each time the game would update I would compare the two variables (local and inputManager.getCursorPosition() variable) to detect mouse movement, but it also feels “dirty”.

What I want to know is that if there is a simple method or way to detect mouse movement. Something like didMouseMoveOnLastFrame() or some way to detect it in a “clean” way.

Or if my solution isn’t as “dirty” as I think it is (I’m kinda paranoic with performance)



Ok, thanks @pspeed!