From 8b559f12712db0c66faabd8273f7ccabf6688978 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 19 Jun 2023 01:59:33 +0200 Subject: [PATCH] Fixed Y polarity in the MM Series packet format on the Logitech Serial Mouse. --- src/device/mouse_serial.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/device/mouse_serial.c b/src/device/mouse_serial.c index 58183e1df..37dc6b4a0 100644 --- a/src/device/mouse_serial.c +++ b/src/device/mouse_serial.c @@ -214,13 +214,14 @@ sermouse_data_mmseries(mouse_t *dev, int x, int y, int b) dev->data[0] = 0x80; if (x >= 0) dev->data[0] |= 0x10; - if (y >= 0) + /* It appears we have inverted Y polarity. */ + if (y < 0) dev->data[0] |= 0x08; dev->data[0] |= (b & 0x01) ? 0x04 : 0x00; /* left button */ dev->data[0] |= (b & 0x04) ? 0x02 : 0x00; /* middle button */ dev->data[0] |= (b & 0x02) ? 0x01 : 0x00; /* right button */ - dev->data[1] = abs(x); - dev->data[2] = abs(y); + dev->data[1] = abs(x) & 0x7f; + dev->data[2] = abs(y) & 0x7f; return 3; }