MouseKeys: Make 'em work!

The mousekey handler was way too eager, and captured events that were not meant
to be handled by it, like the `a` key. This has been fixed by removing the
`KEY_MOUSE_CENTER` bit, and replacing it with `KEY_MOUSE_BUTTON`. That way,
everything fits into the `IS_MOUSE_KEY` flag bit.

While there, also fixed the id of the right mouse button.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/68/head
Gergely Nagy 8 years ago
parent 897349b836
commit 2eb61391ee

@ -23,22 +23,18 @@ static void handle_mouse_key_event(Key mappedKey, uint8_t keyState) {
}
static bool handleMouseKeys(Key mappedKey, byte row, byte col, uint8_t keyState) {
if (! (mappedKey.flags & IS_INTERNAL)
&& (mappedKey.rawKey == KEY_MOUSE_BTN_L
|| mappedKey.rawKey == KEY_MOUSE_BTN_M
|| mappedKey.rawKey == KEY_MOUSE_BTN_R)) {
if (mappedKey.flags != (SYNTHETIC | IS_MOUSE_KEY))
return false;
if (mappedKey.rawKey & KEY_MOUSE_BUTTON) {
uint8_t button = mappedKey.rawKey & ~KEY_MOUSE_BUTTON;
if (key_toggled_on(keyState)) {
MouseWrapper.press_button(mappedKey.rawKey);
MouseWrapper.press_button(button);
} else if (key_toggled_off(keyState)) {
MouseWrapper.release_button(mappedKey.rawKey);
MouseWrapper.release_button(button);
}
return true;
}
if (!(mappedKey.flags & IS_MOUSE_KEY))
return false;
if (!(mappedKey.rawKey & KEY_MOUSE_WARP)) {
} else if (!(mappedKey.rawKey & KEY_MOUSE_WARP)) {
handle_mouse_key_event(mappedKey, keyState);
} else if (key_toggled_on(keyState)) {
if (mappedKey.rawKey & KEY_MOUSE_WARP && mappedKey.flags & IS_MOUSE_KEY) {

@ -5,14 +5,14 @@
// Synthetic, not internal
#define KEY_MOUSE_BTN_L 0x01 // Synthetic key
#define KEY_MOUSE_BTN_M 0x02 // Synthetic key
#define KEY_MOUSE_BTN_R 0x04 // Synthetic key
#define KEY_MOUSE_BTN_R 0x03 // Synthetic key
#define KEY_MOUSE_UP B0000001
#define KEY_MOUSE_DOWN B0000010
#define KEY_MOUSE_LEFT B0000100
#define KEY_MOUSE_RIGHT B0001000
#define KEY_MOUSE_CENTER B0010000
#define KEY_MOUSE_BUTTON B0010000
#define KEY_MOUSE_WARP B0100000
#define KEY_MOUSE_WARP_END B1000000
@ -36,6 +36,6 @@
#define Key_mouseScrollDn
#define Key_mouseScrollL
#define Key_mouseScrollR
#define Key_mouseBtnL (Key){ KEY_FLAGS | SYNTHETIC, KEY_MOUSE_BTN_L }
#define Key_mouseBtnM (Key){ KEY_FLAGS | SYNTHETIC, KEY_MOUSE_BTN_M }
#define Key_mouseBtnR (Key){ KEY_FLAGS | SYNTHETIC, KEY_MOUSE_BTN_R }
#define Key_mouseBtnL (Key){ KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY, KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_L }
#define Key_mouseBtnM (Key){ KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY, KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_M }
#define Key_mouseBtnR (Key){ KEY_FLAGS | SYNTHETIC | IS_MOUSE_KEY, KEY_MOUSE_BUTTON | KEY_MOUSE_BTN_R }

Loading…
Cancel
Save