I'm getting a lot of hassle about the way we handle the mouse in our games. Brief history and explanation:
Up until quite recently we'd relied on plain old Mouse.setGrabbed(true) and completely captured the mouse, then relying on getDX()/DY() to update our own rendered mouse cursor. Unfortunately for reasons unexplained getDX()/DY() occasionally produce fairly crazy values and also they appear to be unrelated to the actual system mouse movement, which basically means the mouse does not behave in the same way as the user's desktop mouse and this is poo.
So in the end I've stopped grabbing the mouse, and instead set it to an almost invisible speck, and simply use Mouse.getX()/Y() to get the actual real mouse coordinates as it moves around on the window; this gives me perfect correlation with the user's desktop mouse speed and acceleration and calibration etc. Unfortunately the mouse can now happily leave the window; worse, on OSes other than Windows, it seems the mouse can even wander onto the other screens even when in fullscreen mode.
I propose some new APIs which fix the issue:
boolean Mouse.setClipped(boolean clip); /** Returns true if successful and clip = true, true if clip = false, and false otherwise */
boolean Mouse.isClipped(); /** Returns true if the mouse is genuinely clipped */
Which will physically constrain the mouse to the client (renderable) area of the Display window in both fullscreen and windowed mode.
The reason for the return value of boolean in setClipped() is in case there is no implementation on a particular OS. I thought an exception would be too annoying as it'd probably cause Windows developers to crash their games with an exception rather than just carry on with the minor inconvenience of not getting a constrained mouse.
I'd kill for this to be available in the next couple of weeks and there is a Small Financial Prize Awaiting whoever would like to implement it courtesy of Puppygames
Cas