|
|
|
@ -112,24 +112,19 @@ uint8_t MouseWrapper_::acceleration(uint8_t cycles) {
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int8_t roundAwayFromZero(float value) {
|
|
|
|
|
if (value < 0.0f) {
|
|
|
|
|
return static_cast<int8_t>(value - 0.5f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return static_cast<int8_t>(value + 0.5f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MouseWrapper_::move(int8_t x, int8_t y) {
|
|
|
|
|
int16_t moveX = 0;
|
|
|
|
|
int16_t moveY = 0;
|
|
|
|
|
static int8_t remainderX = 0;
|
|
|
|
|
static int8_t remainderY = 0;
|
|
|
|
|
static const float HALF_SQRT_2 = 0.7071f;
|
|
|
|
|
|
|
|
|
|
if (x != 0 && y != 0) {
|
|
|
|
|
x = roundAwayFromZero(HALF_SQRT_2 * x);
|
|
|
|
|
y = roundAwayFromZero(HALF_SQRT_2 * y);
|
|
|
|
|
// 99 / 140 closely approximates sqrt(2) / 2.
|
|
|
|
|
int8_t adjusted_x = x * 99 / 140;
|
|
|
|
|
int8_t adjusted_y = y * 99 / 140;
|
|
|
|
|
|
|
|
|
|
x = (adjusted_x == 0 ? x : adjusted_x);
|
|
|
|
|
y = (adjusted_y == 0 ? y : adjusted_y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (x != 0) {
|
|
|
|
|