Moving the mouse in Mac OS 9
Does anyone know an easy way to move the mouse about the screen in MacOS 9 from C/C++? The only example I've been able to find was complicated and not commented, so it was hard to discern what I really needed in my program and what I didn't. Thanks...
#include <CursorDevices.h>
CursorDevicePtr theCursor;
void InitMouse()
{
CursorDeviceNewDevice( &theCursor ); //Mouse
}
void MoveMouse(int xcoord, int ycoord)
{
CursorDeviceMoveTo( theCursor, xcoord, ycoord);
}
void DisposeMouse()
{
CursorDeviceDisposeDevice( theCursor );//Mouse
}
I have no idea how to do this in Carbon though :/
CursorDevicePtr theCursor;
void InitMouse()
{
CursorDeviceNewDevice( &theCursor ); //Mouse
}
void MoveMouse(int xcoord, int ycoord)
{
CursorDeviceMoveTo( theCursor, xcoord, ycoord);
}
void DisposeMouse()
{
CursorDeviceDisposeDevice( theCursor );//Mouse
}
I have no idea how to do this in Carbon though :/
On Mac OS X, you don't move the mouse -- you just get absolute mouse deltas either via Carbon events, or via CoreGraphics. You can pin the mouse to a specific location on the screen if you don't want it moving around, but that's probably unnecessary.
On Carbon things get complicated here because there is no CursorDeviceMoveTo() or CGDisplayWarpCursor() or what it is called. You must have a function which checks whether the app runs in OS Classic or Mac OS X and then load the function from the "InterfaceLib" or "ApplicationServices.framework" and execute it.
I think I already posted my code for this in another thread which deals with the same problem. Just search the forum. There was once sample code on ADC but now I can't find it called "WarpCursor" or something.
The code is also inside the code of my and Bill's uDG entry "Antack". When the uDG sources are made public (which I hope will go faster than with uDG 2001
), you can just copy the code from there.
Good luck!
-Tobi
I think I already posted my code for this in another thread which deals with the same problem. Just search the forum. There was once sample code on ADC but now I can't find it called "WarpCursor" or something.
The code is also inside the code of my and Bill's uDG entry "Antack". When the uDG sources are made public (which I hope will go faster than with uDG 2001
), you can just copy the code from there.Good luck!
-Tobi

