update move smooth fix #96

This commit is contained in:
vcaesar 2018-02-06 18:21:08 +08:00
parent 3c4a887903
commit 1b840c8102
3 changed files with 17 additions and 13 deletions

View File

@ -16,7 +16,8 @@ int mouseDelay = 10;
// int keyboardDelay = 10;
// int CheckMouseButton(const char * const b, MMMouseButton * const button){
// int CheckMouseButton(const char * const b,
// MMMouseButton * const button){
// if (!button) return -1;
// if (strcmp(b, "left") == 0)
@ -74,7 +75,7 @@ int move_mouse_smooth(size_t x, size_t y, double lowSpeed,
}
MMPoint get_mousePos(){
MMPoint get_mouse_pos(){
MMPoint pos = getMousePos();
// Return object with .x and .y.

View File

@ -334,10 +334,12 @@ bool smoothlyMoveMouse(MMPoint endPoint, double lowSpeed, double highSpeed)
double velo_x = 0.0, velo_y = 0.0;
double distance;
while ((distance = crude_hypot((double)pos.x - endPoint.x,
(double)pos.y - endPoint.y)) > 1.0) {
// double gravity = DEADBEEF_UNIFORM(5.0, 500.0);
double gravity = DEADBEEF_UNIFORM(lowSpeed, highSpeed);
while ((distance =
crude_hypot((double)pos.x - endPoint.x, (double)pos.y - endPoint.y))
> 1.0) {
double gravity = DEADBEEF_UNIFORM(5.0, 500.0);
// double gravity = DEADBEEF_UNIFORM(lowSpeed, highSpeed);
double veloDistance;
velo_x += (gravity * ((double)endPoint.x - pos.x)) / distance;
velo_y += (gravity * ((double)endPoint.y - pos.y)) / distance;
@ -359,7 +361,8 @@ bool smoothlyMoveMouse(MMPoint endPoint, double lowSpeed, double highSpeed)
moveMouse(pos);
/* Wait 1 - 3 milliseconds. */
microsleep(DEADBEEF_UNIFORM(1.0, 3.0));
microsleep(DEADBEEF_UNIFORM(lowSpeed, highSpeed));
// microsleep(DEADBEEF_UNIFORM(1.0, 3.0));
}
return true;

View File

@ -63,7 +63,7 @@ import (
)
const (
version string = "v0.48.0.508, Ben Nevis!"
version string = "v0.48.0.509, Ben Nevis!"
)
type (
@ -393,8 +393,8 @@ func MoveMouseSmooth(x, y int, args ...interface{}) {
low = C.double(args[0].(float64))
high = C.double(args[1].(float64))
} else {
low = 5.0
high = 500.0
low = 1.0
high = 3.0
}
C.move_mouse_smooth(cx, cy, low, high, C.int(mouseDelay))
@ -420,8 +420,8 @@ func MoveSmooth(x, y int, args ...interface{}) {
low = C.double(args[0].(float64))
high = C.double(args[1].(float64))
} else {
low = 5.0
high = 500.0
low = 1.0
high = 3.0
}
C.move_mouse_smooth(cx, cy, low, high, C.int(mouseDelay))
@ -429,7 +429,7 @@ func MoveSmooth(x, y int, args ...interface{}) {
// GetMousePos get mouse portion
func GetMousePos() (int, int) {
pos := C.get_mousePos()
pos := C.get_mouse_pos()
// fmt.Println("pos:###", pos, pos.x, pos.y)
x := int(pos.x)
y := int(pos.y)