Cast from PGraphics to GraphicsDevice?

I am trying to make a 3D game in Processing, and the problem I run into the most is the cursor going out of the window, and losing control of the camera. If only the cursor looped back around…
Well, I used java.awt.Robot for that, and it can either use the current screen, or a GraphicsDevice element. So, is there any way to cast from a PGraphics object to a GraphicsDevice?

Also, I tried to use the empty constructor “Robot()”, and it constrained my cursor outside of the window. I get the feeling that this constructor would only work in fullscreen. And even then, it would fail…

By 3D I assume you’re using P3D? In which case check out GLWindow and this thread from earlier today Problem with robot cursor