Skip to content

Commit 88f356f

Browse files
committed
(#8) Removed smoothlyMoveMouse
1 parent 9d27e3b commit 88f356f

File tree

1 file changed

+0
-61
lines changed

1 file changed

+0
-61
lines changed

src/mouse.c

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -334,64 +334,3 @@ void scrollMouse(int x, int y)
334334
SendInput(1, &mouseScrollInputV, sizeof(mouseScrollInputV));
335335
#endif
336336
}
337-
338-
/*
339-
* A crude, fast hypot() approximation to get around the fact that hypot() is
340-
* not a standard ANSI C function.
341-
*
342-
* It is not particularly accurate but that does not matter for our use case.
343-
*
344-
* Taken from this StackOverflow answer:
345-
* http://stackoverflow.com/questions/3506404/fast-hypotenuse-algorithm-for-embedded-processor#3507882
346-
*
347-
*/
348-
static double crude_hypot(double x, double y)
349-
{
350-
double big = fabs(x); /* max(|x|, |y|) */
351-
double small = fabs(y); /* min(|x|, |y|) */
352-
353-
if (big > small) {
354-
double temp = big;
355-
big = small;
356-
small = temp;
357-
}
358-
359-
return ((M_SQRT2 - 1.0) * small) + big;
360-
}
361-
362-
bool smoothlyMoveMouse(MMPoint endPoint)
363-
{
364-
MMPoint pos = getMousePos();
365-
MMSize screenSize = getMainDisplaySize();
366-
double velo_x = 0.0, velo_y = 0.0;
367-
double distance;
368-
369-
while ((distance = crude_hypot((double)pos.x - endPoint.x,
370-
(double)pos.y - endPoint.y)) > 1.0) {
371-
double gravity = DEADBEEF_UNIFORM(5.0, 500.0);
372-
double veloDistance;
373-
velo_x += (gravity * ((double)endPoint.x - pos.x)) / distance;
374-
velo_y += (gravity * ((double)endPoint.y - pos.y)) / distance;
375-
376-
/* Normalize velocity to get a unit vector of length 1. */
377-
veloDistance = crude_hypot(velo_x, velo_y);
378-
velo_x /= veloDistance;
379-
velo_y /= veloDistance;
380-
381-
pos.x += floor(velo_x + 0.5);
382-
pos.y += floor(velo_y + 0.5);
383-
384-
/* Make sure we are in the screen boundaries!
385-
* (Strange things will happen if we are not.) */
386-
if (pos.x >= screenSize.width || pos.y >= screenSize.height) {
387-
return false;
388-
}
389-
390-
moveMouse(pos);
391-
392-
/* Wait 1 - 3 milliseconds. */
393-
microsleep(DEADBEEF_UNIFORM(1.0, 3.0));
394-
}
395-
396-
return true;
397-
}

0 commit comments

Comments
 (0)