This might be kind of a strange question, but how does the software for a mouse work? (specifically on OSX)
If I want to move the mouse around on OSX, I've been using this code:
CGAssociateMouseAndMouseCursorPosition(0);
CGWarpMouseCursorPosition(point); // point is of type NSPoint
CGAssociateMouseAndMouseCursorPosition (1);
But this causes the cursor to jump (and even lag occasionally). How does a mouse (or trackpad) make it so fluid? What APIs do they use?
Likewise, if I use this code to move the cursor over the dock, for example, the dock doesn't magnify (magnification is turned on), even though moving the cursor there normally using the trackpad works just fine. Why?
Your question should really be "How does a mouse device driver work?"
You should take a look at IOKit, especially the HID family.
If you just want to simulate a mouse movement, you could also try creating a mouse event with CGEventCreateMouseEvent
, then posting it with CGEventPost
.