/*
* check byte 0 for consistency
*/
- if(nb==0 && (c&0xc8)!=0x08)
+ if(nb==0 && (c&0xc8)!=0x08){
if(intellimouse && (c==0x00 || c==0x01 || c==0xFF)){
/* last byte of 4-byte packet */
packetsize = 4;
- return;
}
+ return;
+ }
msg[nb] = c;
- if(++nb == packetsize){
+ if(++nb >= packetsize){
nb = 0;
if(msg[0] & 0x10)
msg[1] |= 0xFF00;
dy = -msg[2];
mousetrack(dx, dy, buttons, TK2MS(MACHP(0)->ticks));
}
- return;
}
/*
if(mousetype == MousePS2)
return;
- i8042auxenable(ps2mouseputc);
- /* make mouse streaming, enabled */
- i8042auxcmd(0xEA);
- i8042auxcmd(0xF4);
-
mousetype = MousePS2;
packetsize = 3;
- mousehwaccel = 1;
+ mousehwaccel = 0;
+
+ i8042auxenable(ps2mouseputc);
+ i8042auxcmd(0xEA); /* set stream mode */
}
/*
i8042auxcmd(0x50);
break;
case Mouseserial:
- i8250setmouseputc(mouseport, m5mouseputc);
+ uartsetmouseputc(mouseport, m5mouseputc);
break;
}
}
i8042auxcmd(0xEA); /* streaming */
i8042auxcmd(0xE8); /* set resolution */
i8042auxcmd(3);
- i8042auxcmd(0xF4); /* enabled */
+ break;
+ }
+}
+
+static void
+setstream(int on)
+{
+ int i;
+
+ switch(mousetype){
+ case MousePS2:
+ /*
+ * disabling streaming can fail when
+ * a packet is currently transmitted.
+ */
+ for(i=0; i<4; i++){
+ if(i8042auxcmd(on ? 0xF4 : 0xF5) != -1)
+ break;
+ delay(50);
+ }
break;
}
}
ct = lookupcmd(cb, mousectlmsg, nelem(mousectlmsg));
switch(ct->index){
case CMaccelerated:
+ setstream(0);
setaccelerated(cb->nf == 1 ? 1 : atoi(cb->f[1]));
+ setstream(1);
break;
case CMintellimouse:
+ setstream(0);
setintellimouse();
+ setstream(1);
break;
case CMlinear:
+ setstream(0);
setlinear();
+ setstream(1);
break;
case CMps2:
intellimouse = 0;
ps2mouse();
+ setstream(1);
break;
case CMps2intellimouse:
ps2mouse();
setintellimouse();
+ setstream(1);
break;
case CMres:
+ setstream(0);
if(cb->nf >= 2)
setres(atoi(cb->f[1]));
else
setres(1);
+ setstream(1);
break;
case CMreset:
resetmouse();
setres(resolution);
if(intellimouse)
setintellimouse();
+ setstream(1);
break;
case CMserial:
if(mousetype == Mouseserial)
if(cb->nf > 2){
if(strcmp(cb->f[2], "M") == 0)
- i8250mouse(cb->f[1], m3mouseputc, 0);
+ uartmouse(cb->f[1], m3mouseputc, 0);
else if(strcmp(cb->f[2], "MI") == 0)
- i8250mouse(cb->f[1], m5mouseputc, 0);
+ uartmouse(cb->f[1], m5mouseputc, 0);
else
- i8250mouse(cb->f[1], mouseputc, cb->nf == 1);
+ uartmouse(cb->f[1], mouseputc, cb->nf == 1);
} else
- i8250mouse(cb->f[1], mouseputc, cb->nf == 1);
+ uartmouse(cb->f[1], mouseputc, cb->nf == 1);
mousetype = Mouseserial;
strncpy(mouseport, cb->f[1], sizeof(mouseport)-1);
+ mouseport[sizeof(mouseport)-1] = 0;
packetsize = 3;
break;
case CMhwaccel: