Skip to content

Commit

Permalink
support concurrent trackpoint movement and mousekeys
Browse files Browse the repository at this point in the history
  • Loading branch information
alonswartz committed Apr 15, 2017
1 parent f20a6f8 commit e71670a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
33 changes: 29 additions & 4 deletions tmk_core/common/action.c
Expand Up @@ -33,6 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nodebug.h"
#endif

int tp_buttons;

void action_exec(keyevent_t event)
{
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tmk_core/protocol/ps2_mouse.c
Expand Up @@ -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 {
Expand Down

0 comments on commit e71670a

Please sign in to comment.