views:

286

answers:

1

Background We're porting our PythonOgre-based games to Mac, and the publishers demand ability for mouse to leave the window. On Windows, we're going around OIS (Object-oriented Input System) for the purposes of mouse control; that is, we don't let OIS keep the mouse captured inside window borders, and then track the mouse cursor in screen coordinates using GetCursorPos() Win32 API.

We cannot trivially modify the Ogre3d loop -- it would require at least a rebuild of the library, plus a rebuild of the wrapper which can easily take about an entire workday on our build machine. Theoretically we could modify OIS but we're on tight schedule so, for same reasons, we'd rather not unnecessarily play with it either.

Question What is the Carbon API for obtaining screen-space mouse cursor coordinate, equivalent to Windows API GetCursorPos()?

+1  A: 

I believe that what you are looking for is GetMouse(). You can find an example in Apple's UIElementInspector sample code. This is in Obj-C not Python, though.

EDIT: HIGetMousePosition() is the preferred method, according to NSD.

Colin Gislason
GetMouse() has nothing to do with Objective-C as it predates its existence by several years. Its original implementation would have been Pascal. At any rate, HIGetMousePosition() would be the preferred method today.
Azeem.Butt
Yeah, I meant the example was Objective-C. Good to know about HIGetMousePosition(), though. I'll update my answer.
Colin Gislason
HIGetMousePosition() is new to Leopard. We need 10.4 compatibility, so we'll use GetMouse(). In Python, it's located in Carbon.Evt module, so the proper call is: result=Carbon.Evt.GetMouse(). Thank you both!
Ivan Vučica