// show effects of lost bytes on ps/2 mouse protocol #include #include int main(void) { FILE *f; int i=0,x,a,y, xo,yo,xs,ys,r,m,l,t,dx,dy; f=fopen("/dev/psaux","r"); if(f==NULL) strerror(errno); //printf("Simulating 2 lost bytes\n"); //a=fgetc(f); a=fgetc(f); printf("Simulating 1 lost byte\n"); a=fgetc(f); while (1) { a=fgetc(f); x=fgetc(f); y=fgetc(f); i++; printf("%5d -- %02x %02x %02x",i,a,x,y); yo=a&0x80; xo=a&0x40; ys=a&0x20; xs=a&0x10; t=a&0x08; m=a&0x04; r=a&0x02; l=a&0x01; dx=x; dy=y; if(xs) dx=x-256; if(ys) dy=y-256; printf(" --- %4d : %4d Buttons=%s%s%s Overflow/errors:%s%s%s\n", dx,dy,m?"M":" ", r?"R":" ", l?"L":" ", xo?"X":" ", yo?"Y":" ", t?" ":"T"); } return 0; }