diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index 339b3ee67e..afd6a2652d 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -33,6 +33,7 @@ along with this program. If not, see . #include "nodebug.h" #endif +int tp_buttons; void action_exec(keyevent_t event) { @@ -201,11 +202,35 @@ void process_action(keyrecord_t *record) /* Mouse key */ case ACT_MOUSEKEY: if (event.pressed) { - mousekey_on(action.key.code); - mousekey_send(); + switch (action.key.code) { + case KC_MS_BTN1: + tp_buttons |= (1<<0); + break; + case KC_MS_BTN2: + tp_buttons |= (1<<1); + break; + case KC_MS_BTN3: + tp_buttons |= (1<<2); + break; + default: + mousekey_on(action.key.code); + mousekey_send(); + } } else { - mousekey_off(action.key.code); - mousekey_send(); + switch (action.key.code) { + case KC_MS_BTN1: + tp_buttons &= ~(1<<0); + break; + case KC_MS_BTN2: + tp_buttons &= ~(1<<1); + break; + case KC_MS_BTN3: + tp_buttons &= ~(1<<2); + break; + default: + mousekey_off(action.key.code); + mousekey_send(); + } } break; #endif diff --git a/tmk_core/protocol/ps2_mouse.c b/tmk_core/protocol/ps2_mouse.c index c3e8b3c1c3..6ed05a2f9c 100644 --- a/tmk_core/protocol/ps2_mouse.c +++ b/tmk_core/protocol/ps2_mouse.c @@ -73,12 +73,13 @@ void ps2_mouse_task(void) enum { SCROLL_NONE, SCROLL_BTN, SCROLL_SENT }; static uint8_t scroll_state = SCROLL_NONE; static uint8_t buttons_prev = 0; + extern tp_buttons; /* receives packet from mouse */ uint8_t rcv; rcv = ps2_host_send(PS2_MOUSE_READ_DATA); if (rcv == PS2_ACK) { - mouse_report.buttons = ps2_host_recv_response(); + mouse_report.buttons = ps2_host_recv_response() | tp_buttons; mouse_report.x = ps2_host_recv_response(); mouse_report.y = ps2_host_recv_response(); } else {