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.
This commit is contained in:
parent
52777e21ab
commit
488106eaac
|
@ -20,7 +20,7 @@ main(int argc, char *argv[])
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
int ps2fd;
|
int ps2fd;
|
||||||
int mousefd;
|
int mousefd;
|
||||||
int c;
|
char c;
|
||||||
static short msg[4];
|
static short msg[4];
|
||||||
static int nb;
|
static int nb;
|
||||||
static uint8_t b[] = {0, 1, 4, 5, 2, 3, 6, 7, 0, 1, 2, 3, 2, 3, 6, 7 };
|
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.
|
* but still set mouseshifted.
|
||||||
*/
|
*/
|
||||||
//shift |= mouseshifted;
|
//shift |= mouseshifted;
|
||||||
/*
|
/*
|
||||||
* check byte 0 for consistency
|
* check byte 0 for consistency
|
||||||
*/
|
*/
|
||||||
if(nb==0 && (c&0xc8)!=0x08)
|
if(nb==0 && (c&0xc8)!=0x08)
|
||||||
|
@ -52,7 +52,7 @@ main(int argc, char *argv[])
|
||||||
packetsize = 4;
|
packetsize = 4;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg[nb] = c;
|
msg[nb] = c;
|
||||||
if(++nb == packetsize){
|
if(++nb == packetsize){
|
||||||
nb = 0;
|
nb = 0;
|
||||||
|
@ -60,7 +60,7 @@ main(int argc, char *argv[])
|
||||||
msg[1] |= 0xFF00;
|
msg[1] |= 0xFF00;
|
||||||
if(msg[0] & 0x20)
|
if(msg[0] & 0x20)
|
||||||
msg[2] |= 0xFF00;
|
msg[2] |= 0xFF00;
|
||||||
|
|
||||||
buttons = b[(msg[0]&7) | (shift ? 8 : 0)];
|
buttons = b[(msg[0]&7) | (shift ? 8 : 0)];
|
||||||
if(intellimouse && packetsize==4){
|
if(intellimouse && packetsize==4){
|
||||||
if((msg[3]&0xc8) == 0x08){
|
if((msg[3]&0xc8) == 0x08){
|
||||||
|
@ -83,9 +83,9 @@ main(int argc, char *argv[])
|
||||||
* and generate a single button 4 or 5 click
|
* and generate a single button 4 or 5 click
|
||||||
* accordingly.
|
* accordingly.
|
||||||
*/
|
*/
|
||||||
if((msg[3] >> 3) & 1)
|
if((msg[3] >> 3) & 1)
|
||||||
buttons |= 1<<3;
|
buttons |= 1<<3;
|
||||||
else if(msg[3] & 0x7)
|
else if(msg[3] & 0x7)
|
||||||
buttons |= 1<<4;
|
buttons |= 1<<4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue