Simplify the mouse button code path.

pull/28/head
Jesse Vincent 8 years ago
parent 322c2fa589
commit 5e843dc9cd

@ -3,13 +3,6 @@
#include "Arduino.h"
#include "KeyboardioHID.h"
// Buttons
#define KEY_MOUSE_BUTTON_LEFT 0x01
#define KEY_MOUSE_BUTTON_MIDDLE 0x02
#define KEY_MOUSE_BUTTON_RIGHT 0x04
// Warping commands
#define WARP_END 1

@ -38,8 +38,8 @@ typedef union {
// Synthetic, not internal
#define KEY_MOUSE_BTN_L 0x01 // Synthetic key
#define KEY_MOUSE_BTN_M 0x04 // Synthetic key
#define KEY_MOUSE_BTN_R 0x02 // Synthetic key
#define KEY_MOUSE_BTN_M 0x02 // Synthetic key
#define KEY_MOUSE_BTN_R 0x04 // Synthetic key

@ -10,15 +10,9 @@ void handle_synthetic_key_event(Key mappedKey, uint8_t currentState, uint8_t pre
|| mappedKey.rawKey == KEY_MOUSE_BTN_M
|| mappedKey.rawKey == KEY_MOUSE_BTN_R)) {
if (key_toggled_on(currentState, previousState)) {
MouseWrapper.press_button(
(mappedKey.rawKey == KEY_MOUSE_BTN_L ? KEY_MOUSE_BUTTON_LEFT : 0x00) |
(mappedKey.rawKey == KEY_MOUSE_BTN_M ? KEY_MOUSE_BUTTON_MIDDLE : 0x00) |
(mappedKey.rawKey == KEY_MOUSE_BTN_R ? KEY_MOUSE_BUTTON_RIGHT : 0x00) );
MouseWrapper.press_button(mappedKey.rawKey);
} else if (key_toggled_off(currentState, previousState)) {
MouseWrapper.release_button(
(mappedKey.rawKey == KEY_MOUSE_BTN_L ? KEY_MOUSE_BUTTON_LEFT : 0x00) |
(mappedKey.rawKey == KEY_MOUSE_BTN_M ? KEY_MOUSE_BUTTON_MIDDLE : 0x00) |
(mappedKey.rawKey == KEY_MOUSE_BTN_R ? KEY_MOUSE_BUTTON_RIGHT : 0x00) );
MouseWrapper.release_button(mappedKey.rawKey);
}
}

Loading…
Cancel
Save