|
|
|
@ -5,33 +5,22 @@
|
|
|
|
|
#include "MouseWrapper.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Warping
|
|
|
|
|
static double mouseActiveForCycles = 0;
|
|
|
|
|
static float carriedOverX = 0;
|
|
|
|
|
static float carriedOverY = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int abs_left = 0;
|
|
|
|
|
static int abs_top = 0;
|
|
|
|
|
static int next_width;
|
|
|
|
|
static int next_height;
|
|
|
|
|
static int section_top;
|
|
|
|
|
static int section_left;
|
|
|
|
|
static boolean is_warping = false;
|
|
|
|
|
|
|
|
|
|
MouseWrapper_::MouseWrapper_(void) {
|
|
|
|
|
Mouse.begin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void press_button(uint8_t button) {
|
|
|
|
|
void MouseWrapper_::press_button(uint8_t button) {
|
|
|
|
|
Mouse.press(button);
|
|
|
|
|
end_warping();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void release_button(uint8_t button) {
|
|
|
|
|
void MouseWrapper_::release_button(uint8_t button) {
|
|
|
|
|
Mouse.release(button);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void _warp_jump(long left, long top, long height, long width) {
|
|
|
|
|
void MouseWrapper_::warp_jump(long left, long top, long height, long width) {
|
|
|
|
|
long x_center = left + width/2;
|
|
|
|
|
long y_center = top + height/2;
|
|
|
|
|
AbsoluteMouse.moveTo(x_center,y_center);
|
|
|
|
@ -41,19 +30,19 @@ void _warp_jump(long left, long top, long height, long width) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void begin_warping() {
|
|
|
|
|
section_left = abs_left;
|
|
|
|
|
section_top = abs_top;
|
|
|
|
|
void MouseWrapper_::begin_warping() {
|
|
|
|
|
section_left = WARP_ABS_LEFT;
|
|
|
|
|
section_top = WARP_ABS_TOP;
|
|
|
|
|
next_width = MAX_WARP_WIDTH;
|
|
|
|
|
next_height = MAX_WARP_HEIGHT;
|
|
|
|
|
is_warping = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void end_warping() {
|
|
|
|
|
void MouseWrapper_::end_warping() {
|
|
|
|
|
is_warping= false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void warp_mouse(uint8_t warp_cmd) {
|
|
|
|
|
void MouseWrapper_::warp(uint8_t warp_cmd) {
|
|
|
|
|
if (is_warping == false) {
|
|
|
|
|
begin_warping();
|
|
|
|
|
}
|
|
|
|
@ -82,13 +71,13 @@ void warp_mouse(uint8_t warp_cmd) {
|
|
|
|
|
section_left = section_left + next_width;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_warp_jump(section_left, section_top, next_height,next_width);
|
|
|
|
|
warp_jump(section_left, section_top, next_height,next_width);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double mouse_accel (double cycles) {
|
|
|
|
|
double MouseWrapper_::acceleration (double cycles) {
|
|
|
|
|
double accel = (atan((cycles * ACCELERATION_CLIMB_SPEED)-ACCELERATION_RUNWAY) + ATAN_LIMIT) * ACCELERATION_MULTIPLIER;
|
|
|
|
|
if (accel < ACCELERATION_FLOOR) {
|
|
|
|
|
accel = ACCELERATION_FLOOR;
|
|
|
|
@ -96,11 +85,11 @@ double mouse_accel (double cycles) {
|
|
|
|
|
return accel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void move_mouse( int8_t x, int8_t y) {
|
|
|
|
|
void MouseWrapper_::move( int8_t x, int8_t y) {
|
|
|
|
|
|
|
|
|
|
if (x != 0 || y != 0) {
|
|
|
|
|
mouseActiveForCycles++;
|
|
|
|
|
double accel = (double) mouse_accel(mouseActiveForCycles);
|
|
|
|
|
double accel = (double) acceleration(mouseActiveForCycles);
|
|
|
|
|
float moveX = 0;
|
|
|
|
|
float moveY = 0;
|
|
|
|
|
if (x > 0) {
|
|
|
|
@ -127,4 +116,4 @@ void move_mouse( int8_t x, int8_t y) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MouseWrapper_ MouseWrapper;
|
|
|
|
|