Mouse Grabbing

How do I grab the mouse with jinput (and/or AWT or jogl)

Specifically, I need to be able to lock the mouse position on the canvas to prevent it from moving outside the canvas. This is to implement something like a drag-to-rotate camera. Typically when you do this in C++ you lock it to the center of the canvas until it is released, then move it back to the click point when you are done. You also typically hide the mouse cursor while it is grabbed. (I know how to do this)

LWJGL has a mechanism to do this, via its Mouse.setGrabbed() and Mouse.setCursorPosition() methods. These are implemented natively for LWJGL, ultimately calling Windows ClipCursor() and SetCursorPos() functions. This is really a big deal for games so I hope that I don’t have to duplicate what LWJGL did myself :confused:

Thanks!