Controlling the mouse with the keyboar or with a pad

Hi everybody!!

Im making a game with JMonkey and im looking forward for controlling the mouse cursor whit the keyboard or the gamepad.

Is there a way to change the position of the mouse in the screen?

What is the better way for doing this?

I have tried in this way, but it havent work:

I have mapped 4 keys: up, right , left and down. When i press up i get the mouse position with “inputManager.getCursorPosition()”. then i want to make something like “cursor.setPosition().y(actualposition + 1” so that the mouse goes up when i press the key.

How can this be made?

Thank you all!

This is a case of smoke and daggers. Most (if not all) games won’t actually move the mouse, they just give the illusion by putting an image of a cursor next to the selection. So for example if you start using your gamepad, the real mouse will get hidden, and the fake mouse will come into play.

1 Like

But there is a Mouse.setSomething method,

However you will annoy everyone if you actually use it, as it would make it impossible to move the real mouse away from the game.

So yeah i suggest using software cursor in this case.

1 Like

What do you mean with software cursor? Maybe hide the real cursor and use a hud? But in this case how can i detect when i click a nifty element with this fake cursor?

Thank you all for your replies!

Position and overlap.

You mean “how can I find out if my cursor at 180/1010 clicks the 100x100 button at 100/980?”… Though one :wink: