From 488106eaac33f189d9c0219122dd8b7dfa682261 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 29 Nov 2016 20:42:24 +0100 Subject: [PATCH] cmd/ms: read #P/ps2mouse in a char (not in an int) After the removal of dumb push in crt0 (commit 929014ebca5c738d3854758326de7abfb77c1ef1) the first byte of the c integer is not zeroed anymore (which is correct). But since ms.c reads and bit-match a single byte in c, when it's an int some test success/fail due to the state of the unused bytes. This makes the mouse turn crazy. So we turn it into a char, so that bitmasks and tests work as expected. --- sys/src/cmd/ms.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/src/cmd/ms.c b/sys/src/cmd/ms.c index d6a0e09..11c7332 100644 --- a/sys/src/cmd/ms.c +++ b/sys/src/cmd/ms.c @@ -20,7 +20,7 @@ main(int argc, char *argv[]) int shift = 0; int ps2fd; int mousefd; - int c; + char c; static short msg[4]; static int nb; static uint8_t b[] = {0, 1, 4, 5, 2, 3, 6, 7, 0, 1, 2, 3, 2, 3, 6, 7 }; @@ -43,7 +43,7 @@ main(int argc, char *argv[]) * but still set mouseshifted. */ //shift |= mouseshifted; - /* + /* * check byte 0 for consistency */ if(nb==0 && (c&0xc8)!=0x08) @@ -52,7 +52,7 @@ main(int argc, char *argv[]) packetsize = 4; continue; } - + msg[nb] = c; if(++nb == packetsize){ nb = 0; @@ -60,7 +60,7 @@ main(int argc, char *argv[]) msg[1] |= 0xFF00; if(msg[0] & 0x20) msg[2] |= 0xFF00; - + buttons = b[(msg[0]&7) | (shift ? 8 : 0)]; if(intellimouse && packetsize==4){ if((msg[3]&0xc8) == 0x08){ @@ -83,9 +83,9 @@ main(int argc, char *argv[]) * and generate a single button 4 or 5 click * accordingly. */ - if((msg[3] >> 3) & 1) + if((msg[3] >> 3) & 1) buttons |= 1<<3; - else if(msg[3] & 0x7) + else if(msg[3] & 0x7) buttons |= 1<<4; } }