From 8e1acfa3b1be3bb60b8a23baf6f14f98595fac7a Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 31 Jan 2026 06:17:25 +0100 Subject: [PATCH] Mouse Systems mice: The last two bytes of the report are now correctly the mouse movement delta between when we've initially prepared the report for sending and when we've reached the 3rd byte. --- src/device/mouse_serial.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/device/mouse_serial.c b/src/device/mouse_serial.c index 45750ef09..340d3d144 100644 --- a/src/device/mouse_serial.c +++ b/src/device/mouse_serial.c @@ -143,8 +143,24 @@ sermouse_transmit_byte(mouse_t *dev, int do_next) if (dev->buf_pos == 0) dev->acc_time = 0.0; - if (dev->serial) + if (dev->serial) { + if ((dev->state == STATE_TRANSMIT_REPORT) && (dev->format == FORMAT_PB_5BYTE) && + (dev->buf_pos == 3)) { + /* + The last two bytes are the delta between now and when we originally + prepared the report for sending. + */ + int delta_x = 0; + int delta_y = 0; + + mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 1, 0); + + dev->buf[3] = delta_x; /* same as byte 1 */ + dev->buf[4] = delta_y; /* same as byte 2 */ + } + serial_write_fifo(dev->serial, dev->buf[dev->buf_pos]); + } if (do_next) { /* If we have a buffer length of 0, pretend the state is STATE_SKIP_PACKET. */