PDA

View Full Version : Moving mouse location


Nickolei
2002.05.14, 12:41 AM
I'm using the mouse to look around in a 3d world. The cursor is hidden but needs to be kept away from the edges of the screen so the user can continuously turn in any direction.

So I just reset the mouse to the center of the screen if it gets too close to an edge. I have this all worked out for OS 9 (It's a Carbon app), but can't seem to find anything that works on X.

I did find mention of CGWarpMouseCursorPosition() for this purpose but can't get Codewarrior to recognize this even after including...

#include "CGRemoteOperation.h"
#include "ApplicationServices.h"

Any help or other ideas?

OneSadCookie
2002.05.14, 01:21 AM
For MacOSX, hide the mouse cursor, and disassociate the mouse and the cursor. Then read the mouse deltas directly.

Relevant functions:
CG_EXTERN CGEventErr CGAssociateMouseAndMouseCursorPosition(boolean_t connected);
CGDisplayErr CGDisplayHideCursor(CGDirectDisplayID display);
typedef int32_t CGMouseDelta;
CGDirectDisplay.h:void CGGetLastMouseDelta( CGMouseDelta * deltaX, CGMouseDelta * deltaY );

You need to include <ApplicationServices/ApplicationServices.h> to get these prototypes.

If you're trying to do this in a CFM application, it's just about possible, but my advice is don't -- just have two separate binaries, one for 9 and one for X.