Mouse cursor in PyOgre

kupiakos

09-09-2010 02:41:24

Is it possible for the cursor to be shown while PyOgre is reading its position and movement?
Does the hardware acceleration of OpenGL and DirectX not allow this?

Thanks in advance ;)
- Kupiakos

SirGolan

11-09-2010 17:23:02

If you are looking to just have any mouse cursor, check out CEGUI. There's a tutorial on the wiki. If you want Ogre / OIS to not hide the system mouse cursor and only relay movements when the mouse is inside the Ogre window, that's a little trickier. I made a recent attempt at that for MV3D, but so far haven't gotten it working. You can show the system cursor with this code for initializing OIS:


windowHnd = self.renderWindow.getCustomAttributeInt("WINDOW")
oisOptions = [("WINDOW", str(windowHnd))]
if sys.platform == "win32":
oisOptions.append(("w32_mouse", "DISCL_FOREGROUND"))
oisOptions.append(("w32_mouse", "DISCL_NONEXCLUSIVE"))
oisOptions.append(("w32_keyboard", "DISCL_FOREGROUND"))
oisOptions.append(("w32_keyboard", "DISCL_NONEXCLUSIVE"))
else:
oisOptions.append(("x11_mouse_grab", "false"))
oisOptions.append(("x11_mouse_hide", "false"))
oisOptions.append(("x11_keyboard_grab", "false"))
oisOptions.append(("XAutoRepeatOn", "true"))

self.inputSys = OIS.createPythonInputSystem(oisOptions)


However, you'll still get mouse events even when the cursor is not in the window (as long as the window is active). I couldn't see any way to switch OIS modes based on whether the mouse was inside the window or not unfortunately. The next thing I was going to try as a total hack was to use WxPython to manage the window and mouse input then pass that along to CEGUI when the mouse was over the window. It'd probably work, but it adds a dependency on WxPython to your app.

Mike