Skip to content

Commit

Permalink
fix: btn events should be handled in ps2_mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
klesh committed Oct 6, 2022
1 parent 500f39a commit 172b37e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
7 changes: 3 additions & 4 deletions drivers/ps2/ps2_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,30 +80,29 @@ void ps2_mouse_task(void) {
uint8_t rcv;
rcv = ps2_host_send(PS2_MOUSE_READ_DATA);
if (rcv == PS2_ACK) {
mouse_report.buttons = ps2_host_recv_response() | tp_buttons;
mouse_report.buttons = ps2_host_recv_response();
mouse_report.x = ps2_host_recv_response() * PS2_MOUSE_X_MULTIPLIER;
mouse_report.y = ps2_host_recv_response() * PS2_MOUSE_Y_MULTIPLIER;
# ifdef PS2_MOUSE_ENABLE_SCROLLING
mouse_report.v = -(ps2_host_recv_response() & PS2_MOUSE_SCROLL_MASK) * PS2_MOUSE_V_MULTIPLIER;
# endif
} else {
if (debug_mouse) print("ps2_mouse: fail to get mouse packet\n");
return;
}
#else
if (pbuf_has_data()) {
mouse_report.buttons = ps2_host_recv_response() | tp_buttons;
mouse_report.buttons = ps2_host_recv_response();
mouse_report.x = ps2_host_recv_response() * PS2_MOUSE_X_MULTIPLIER;
mouse_report.y = ps2_host_recv_response() * PS2_MOUSE_Y_MULTIPLIER;
# ifdef PS2_MOUSE_ENABLE_SCROLLING
mouse_report.v = -(ps2_host_recv_response() & PS2_MOUSE_SCROLL_MASK) * PS2_MOUSE_V_MULTIPLIER;
# endif
} else {
if (debug_mouse) print("ps2_mouse: fail to get mouse packet\n");
return;
}
#endif

mouse_report.buttons |= tp_buttons;
/* if mouse moves or buttons state changes */
if (mouse_report.x || mouse_report.y || mouse_report.v || ((mouse_report.buttons ^ buttons_prev) & PS2_MOUSE_BTN_MASK)) {
#ifdef PS2_MOUSE_DEBUG_RAW
Expand Down
5 changes: 0 additions & 5 deletions quantum/mousekey.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,5 @@ report_mouse_t mousekey_get_report(void) {
}

bool should_mousekey_report_send(report_mouse_t *mouse_report) {
static char previous_buttons = 0;
if (previous_buttons != mouse_report->buttons) {
previous_buttons = mouse_report->buttons;
return true;
}
return mouse_report->x || mouse_report->y || mouse_report->v || mouse_report->h;
}

0 comments on commit 172b37e

Please sign in to comment.