I am making an iphone iphone mouse controller app for Mac: the iPhone app sends coordinate values to a Mac, which then process the mouse location value.
To get the current mouse location on a Mac, the receiver calls [NSEvent mouseLocation].
The value for x is always correct, but the value for y is incorrect.
I used a while loop to handle this event.
while (1) { mouseLoc = [NSEvent mouseLocation]; while ((msgLength = recv(clientSocket, buffer, sizeof(buffer), 0)) != 0) { CGPoint temp; temp.x = mouseLoc.x; temp.y = mouseLoc.y;
The y value in each cycle period is different. For example, y is 400 in the first cycle, y is 500 in the next cycle; then y again 400 in the next loop.
The mouse pointer moves up and down continuously, and the sum of two different y values is always 900. (I think because the screen resolution is 1440 * 900.)
I don’t know why this is happening, what to do and how to debug it.
source share