iDevGames Forums
Moving mouse location - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Moving mouse location (/thread-7765.html)

Moving mouse location - Nickolei - May 13, 2002 09:41 PM

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?

Moving mouse location - OneSadCookie - May 13, 2002 10:21 PM

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.