MouseWrapper: static-ification

Mark most of the things static, to save a couple of bytes in program-space.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/365/head
Gergely Nagy 8 years ago
parent ba1a8604a0
commit ce734dbd37

@ -4,6 +4,13 @@
//
#include "MouseWrapper.h"
uint16_t MouseWrapper_::next_width;
uint16_t MouseWrapper_::next_height;
uint16_t MouseWrapper_::section_top;
uint16_t MouseWrapper_::section_left;
boolean MouseWrapper_::is_warping;
uint8_t MouseWrapper_::mouseActiveForCycles;
MouseWrapper_::MouseWrapper_(void) {
Mouse.begin();
@ -20,17 +27,12 @@ void MouseWrapper_::release_button(uint8_t button) {
Mouse.release(button);
}
void MouseWrapper_::warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width) {
uint16_t x_center = left + width/2;
uint16_t y_center = top + height/2;
AbsoluteMouse.moveTo(x_center,y_center);
AbsoluteMouse.moveTo(x_center, y_center);
}
void MouseWrapper_::begin_warping() {
section_left = WARP_ABS_LEFT;
section_top = WARP_ABS_TOP;
@ -48,14 +50,12 @@ void MouseWrapper_::warp(uint8_t warp_cmd) {
begin_warping();
}
if ( warp_cmd & WARP_END) {
if (warp_cmd & WARP_END) {
end_warping();
return;
}
next_width = next_width / 2;
next_width = next_width/2;
next_height = next_height/2;
if (warp_cmd & WARP_UP) {
@ -73,10 +73,8 @@ void MouseWrapper_::warp(uint8_t warp_cmd) {
}
warp_jump(section_left, section_top, next_height,next_width);
}
// cubic wave function based on code from FastLED
uint8_t MouseWrapper_::acceleration(uint8_t cycles) {
uint8_t i = cycles;
@ -92,14 +90,14 @@ uint8_t MouseWrapper_::acceleration(uint8_t cycles) {
i = (( (3 * (uint16_t)(ii)) - ( 2 * (uint16_t)(iii))) / 2) + ACCELERATION_FLOOR;
if ( i > ACCELERATION_CEIL) {
i = ACCELERATION_CEIL;
if (i > ACCELERATION_CEIL) {
i = ACCELERATION_CEIL;
}
return i;
}
void MouseWrapper_::move( int8_t x, int8_t y) {
void MouseWrapper_::move(int8_t x, int8_t y) {
int16_t moveX =0;
int16_t moveY = 0;
if (x != 0 ) {

@ -11,8 +11,6 @@
#define WARP_LEFT 8
#define WARP_RIGHT 16
// apparently, the mac discards 15% of the value space for mouse movement.
// need to test this on other platforms
@ -29,28 +27,27 @@
#define ACCELERATION_FLOOR 2
#define ACCELERATION_CEIL 50
class MouseWrapper_ {
public:
MouseWrapper_(void);
void move( int8_t x, int8_t y);
void warp(uint8_t warp_cmd);
void press_button(uint8_t button);
void release_button(uint8_t button);
uint8_t mouseActiveForCycles = 0;
private:
uint16_t next_width = 0;
uint16_t next_height = 0;
uint16_t section_top = 0;
uint16_t section_left = 0;
boolean is_warping = false;
uint8_t acceleration (uint8_t cycles);
void begin_warping();
void end_warping();
void warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width);
static void move(int8_t x, int8_t y);
static void warp(uint8_t warp_cmd);
static void press_button(uint8_t button);
static void release_button(uint8_t button);
static uint8_t mouseActiveForCycles;
private:
static uint16_t next_width;
static uint16_t next_height;
static uint16_t section_top;
static uint16_t section_left;
static boolean is_warping;
static uint8_t acceleration(uint8_t cycles);
static void begin_warping();
static void end_warping();
static void warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width);
};
extern MouseWrapper_ MouseWrapper;

Loading…
Cancel
Save