PDA

View Full Version : Setting the mouse location


Michael
2002.10.27, 07:58 PM
Does anyone know of a way to have a program set the mouse location in C? The LMSetMouseLocation function in LowMem.h has been phased out in Carbon, and the Apple page says that it is impossible for an application to change the mouse location directly.

Background: I'm trying to program a Crystal-quest style mouse control for a game. Basically, to do that control style:

Store the location of the mouse
If the mouse moves, accelerate your ship in that direction
Store the new location of the mouse

So basically, moving the cursor accelerates in the direction that you moved it in. It's very intuitive, but the problem is that the cursor can end up moved all the way to one side of the screen, and will move no farther. So the work-around is to re-center the mouse each frame...

OneSadCookie
2002.10.27, 08:45 PM
Search the forums, this has been answered before.

You should really use absolute mouse deltas rather than moving the mouse.

GoodDoug
2002.10.28, 09:21 PM
Look in the CoreGraphics headers. its all in there.

ededed
2002.10.29, 11:11 AM
Yup core graphics...

CGDirectDisplay.h
CGDisplayErr CGDisplayMoveCursorToPoint(CGDirectDisplayID display, CGPoint point)

I think I can get you an example of that in use...

ededed
2002.10.29, 11:17 AM
http://www.geocities.com/ed72678954/index.html

Download JellyMouse and Space Goon (Just get Space Goon because its 1/10cool).

Taxxodium
2002.10.31, 04:23 PM
OMG, someone with the same idea as me. A little competition doesn't hurt, but this looks doubtful...

Here (http://www.idevgames.com/forum/showthread.php?s=&threadid=1059) is the thread

reubert
2003.06.22, 06:39 AM
Well I just had to post this solution, after just spending about 8 hours trying to figure out the same thing. Now if anyone looks at this post they might have an easier way of setting the mouse position.

CGPoint pos;
CGSetLocalEventsSuppressionInterval(0);
CGWarpMouseCursorPosition(pos);

I'm trying to port the gameTutorials SDL openGL tutorials to Cocoa. Very good learning experience.