Simplify mouse movement code

pull/18/head
Jesse Vincent 9 years ago
parent 4dc59ecf94
commit 73caeff437

@ -31,9 +31,6 @@ void setup();
#include "mouse_movement.h"
#include "storage.h"
char x;
char y;
uint8_t matrixState[ROWS][COLS] = {0};
static const Key keymaps[KEYMAPS][ROWS][COLS] = { KEYMAP_LIST };

@ -43,13 +43,10 @@ void setup() {
void loop() {
x = 0;
y = 0;
scan_matrix();
LEDs.update_leds(temporary_keymap);
Keyboard.sendReport();
Keyboard.releaseAll();
move_mouse(x, y);
LEDs.update_leds(temporary_keymap);
}
@ -62,7 +59,7 @@ void handle_synthetic_key_event(byte switchState, Key mappedKey) {
warp_mouse(mappedKey);
}
} else {
handle_mouse_key_press(switchState, mappedKey, x, y);
handle_mouse_key_press(switchState, mappedKey);
}
}
if (mappedKey.flags & IS_CONSUMER) {

@ -89,7 +89,7 @@ double mouse_accel (double cycles) {
return accel;
}
void move_mouse( char x, char y) {
void move_mouse( int8_t x, int8_t y) {
if (x != 0 || y != 0) {
mouseActiveForCycles++;
@ -121,21 +121,20 @@ void move_mouse( char x, char y) {
}
void handle_mouse_key_press(byte switchState, Key mappedKey, char &x, char &y) {
void handle_mouse_key_press(byte switchState, Key mappedKey) {
if (key_is_pressed(switchState)) {
if (mappedKey.rawKey & MOUSE_UP) {
y -= 1;
move_mouse(0,-1);
}
if (mappedKey.rawKey & MOUSE_DN) {
y += 1;
move_mouse(0,1);
}
if (mappedKey.rawKey & MOUSE_L) {
x -= 1;
move_mouse(-1,0);
}
if (mappedKey.rawKey & MOUSE_R) {
x += 1 ;
move_mouse(1,0);
}
}
}

@ -4,8 +4,8 @@
// Mouse-related 'public' API methods
double mouse_accel (double cycles);
void handle_mouse_key_press(byte switchState, Key mappedKey, char &x, char &y);
void move_mouse( char x, char y);
void handle_mouse_key_press(byte switchState, Key mappedKey);
void move_mouse( int8_t x, int8_t y);
void begin_warping();
void end_warping();
void warp_mouse(Key key);

Loading…
Cancel
Save