Moving mouse location
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?
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?
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.
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.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| ending location from angle and speed | Kazooless | 5 | 3,923 |
Apr 3, 2009 02:40 PM Last Post: Gillissie |
|
| polling mouse location? | alloca | 1 | 2,211 |
Jan 22, 2009 04:14 PM Last Post: ThemsAllTook |
|
| Cocoa: Mouse location while dragging window | Fenris | 4 | 4,488 |
Jul 14, 2005 04:46 PM Last Post: Fenris |
|
| Getting mouse location | Steven | 25 | 7,436 |
Aug 3, 2003 07:24 PM Last Post: OneSadCookie |
|
| Setting the mouse location | Michael | 6 | 3,886 |
Jun 22, 2003 03:39 AM Last Post: reubert |
|

