Moving mouse location

Posts: 33
Joined: 2002.04
Post: #1
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?
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #2
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  ending location from angle and speed Kazooless 5 7,393 Apr 3, 2009 02:40 PM
Last Post: Gillissie
  polling mouse location? alloca 1 3,806 Jan 22, 2009 04:14 PM
Last Post: ThemsAllTook
  Cocoa: Mouse location while dragging window Fenris 4 7,435 Jul 14, 2005 04:46 PM
Last Post: Fenris
  Getting mouse location Steven 25 13,886 Aug 3, 2003 07:24 PM
Last Post: OneSadCookie
  Setting the mouse location Michael 6 6,380 Jun 22, 2003 03:39 AM
Last Post: reubert