Remove all knowledge of Mouse() from key_events.cpp

pull/18/head
Jesse Vincent 9 years ago
parent 451b133e3a
commit a2648d7996

@ -40,11 +40,16 @@ void handle_synthetic_key_event(byte switchState, Key mappedKey) {
|| mappedKey.rawKey == KEY_MOUSE_BTN_M || mappedKey.rawKey == KEY_MOUSE_BTN_M
|| mappedKey.rawKey == KEY_MOUSE_BTN_R) { || mappedKey.rawKey == KEY_MOUSE_BTN_R) {
if (key_toggled_on (switchState)) { if (key_toggled_on (switchState)) {
Mouse.press(mappedKey.rawKey); press_button(
end_warping(); (mappedKey.rawKey == KEY_MOUSE_BTN_L ? MOUSE_BUTTON_LEFT : 0x00) |
} else if (key_is_pressed(switchState)) { (mappedKey.rawKey == KEY_MOUSE_BTN_M ? MOUSE_BUTTON_MIDDLE : 0x00) |
} else if (Mouse.isPressed(mappedKey.rawKey) ) { (mappedKey.rawKey == KEY_MOUSE_BTN_R ? MOUSE_BUTTON_RIGHT : 0x00) );
Mouse.release(mappedKey.rawKey);
} else if (key_toggled_off(switchState)) {
release_button(
(mappedKey.rawKey == KEY_MOUSE_BTN_L ? MOUSE_BUTTON_LEFT : 0x00) |
(mappedKey.rawKey == KEY_MOUSE_BTN_M ? MOUSE_BUTTON_MIDDLE : 0x00) |
(mappedKey.rawKey == KEY_MOUSE_BTN_R ? MOUSE_BUTTON_RIGHT : 0x00) );
} }
} }
} }

@ -20,6 +20,17 @@ static int section_left;
static boolean is_warping = false; static boolean is_warping = false;
void press_button(uint8_t button) {
Mouse.press(button);
end_warping();
}
void release_button(uint8_t button) {
Mouse.release(button);
}
void _warp_jump(long left, long top, long height, long width) { void _warp_jump(long left, long top, long height, long width) {
long x_center = left + width/2; long x_center = left + width/2;
long y_center = top + height/2; long y_center = top + height/2;

@ -12,6 +12,14 @@ void move_mouse( int8_t x, int8_t y);
void begin_warping(); void begin_warping();
void end_warping(); void end_warping();
void warp_mouse(uint8_t warp_cmd); void warp_mouse(uint8_t warp_cmd);
void press_button(uint8_t button);
void release_button(uint8_t button);
// Buttons
#define MOUSE_BUTTON_LEFT 0x01
#define MOUSE_BUTTON_MIDDLE 0x02
#define MOUSE_BUTTON_RIGHT 0x04
// Warping commands // Warping commands

Loading…
Cancel
Save