Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid READ command in stream mode #5408

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tmk_core/protocol/ps2.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ uint8_t ps2_host_send(uint8_t data);
uint8_t ps2_host_recv_response(void);
uint8_t ps2_host_recv(void);
void ps2_host_set_led(uint8_t usb_led);

bool pbuf_has_data(void);

/*--------------------------------------------------------------------
* static functions
Expand Down
3 changes: 1 addition & 2 deletions tmk_core/protocol/ps2_interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ uint8_t ps2_error = PS2_ERR_NONE;

static inline uint8_t pbuf_dequeue(void);
static inline void pbuf_enqueue(uint8_t data);
static inline bool pbuf_has_data(void);
static inline void pbuf_clear(void);


Expand Down Expand Up @@ -261,7 +260,7 @@ static inline uint8_t pbuf_dequeue(void)

return val;
}
static inline bool pbuf_has_data(void)
bool pbuf_has_data(void)
{
uint8_t sreg = SREG;
cli();
Expand Down
14 changes: 14 additions & 0 deletions tmk_core/protocol/ps2_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void ps2_mouse_task(void) {
extern int tp_buttons;

/* receives packet from mouse */
#ifdef PS2_MOUSE_USE_REMOTE_MODE
uint8_t rcv;
rcv = ps2_host_send(PS2_MOUSE_READ_DATA);
if (rcv == PS2_ACK) {
Expand All @@ -88,6 +89,19 @@ void ps2_mouse_task(void) {
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.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

/* if mouse moves or buttons state changes */
if (mouse_report.x || mouse_report.y || mouse_report.v ||
Expand Down