Skip to content

Commit

Permalink
Fix sharing of mouse button state from mousekeys to ps2_mouse (qmk#9124)
Browse files Browse the repository at this point in the history
With this change, when ps2_mouse is disabled, mousekeys works as usual. With
ps2_mouse enabled, mousekeys button state is shared with ps2_mouse for clicking,
dragging, and scrolling, mousekeys clicks are produced by ps2_mouse only, and
mouskeys button state is transferred to mousekeys without generating clicks to
enable mousekeys dragging.

Co-authored-by: Drashna Jaelre <[email protected]>

Co-authored-by: Drashna Jaelre <[email protected]>
  • Loading branch information
manna-harbour and drashna committed Aug 9, 2020
1 parent 95782d3 commit f32994a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tmk_core/common/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ void process_action(keyrecord_t *record, action_t action) {
/* Mouse key */
case ACT_MOUSEKEY:
if (event.pressed) {
mousekey_on(action.key.code);
switch (action.key.code) {
# ifdef PS2_MOUSE_ENABLE
case KC_MS_BTN1:
tp_buttons |= (1 << 0);
break;
Expand All @@ -410,13 +412,15 @@ void process_action(keyrecord_t *record, action_t action) {
case KC_MS_BTN3:
tp_buttons |= (1 << 2);
break;
# endif
default:
mousekey_send();
break;
}
mousekey_on(action.key.code);
mousekey_send();
} else {
mousekey_off(action.key.code);
switch (action.key.code) {
# ifdef PS2_MOUSE_ENABLE
case KC_MS_BTN1:
tp_buttons &= ~(1 << 0);
break;
Expand All @@ -426,11 +430,11 @@ void process_action(keyrecord_t *record, action_t action) {
case KC_MS_BTN3:
tp_buttons &= ~(1 << 2);
break;
# endif
default:
mousekey_send();
break;
}
mousekey_off(action.key.code);
mousekey_send();
}
break;
#endif
Expand Down

0 comments on commit f32994a

Please sign in to comment.