Joystick emulation with mouse

Would it be possible to emulate the input of a joystick with a mouse in order make absolute mouse control possible.



I am trying to control a vehicle with rotationcontroller and its not absolute, which means sadly it isnt working, any thoughts?

As I see it you have two options:


  • Use the relative GameControl to create a custom controller that moves the mouse around based on the changes

  • Create a new GameControl that takes the absolute mouse positional information and changes the value to a minimum of 0.0f (left or top) - 1.0f (right or bottom)



The second option is probably a better one as it is not bound to the update speed for sensitivity.

You can do it with plain InputHandler stuff as well, relative mouse coordinates are supported… what's the actual problem? Do you want to avoid writing an own controller?

I think it's more that GameControls do everything else, but they don't currently have a solution to this problem.

How would the second suggestion be done? I dont really understand how you would even start?

I don't have code in front of me, so this will be philosophical rather than programmatic. :o



Get a reference to the mouse (Mouse.get(), MouseInput.get(), or something like that) and from that you can get the absolute x and y positions.  From that you need to determine maxX and maxY and then do a division of the max x and y by the absolute x and y to get your floats from 0.0f - 1.0f and then you'd multiply by two and subtract by one to get a value between -1.0f - +1.0f.