#include #include main(){ FILE *fmouse; char b[3]; fmouse = fopen("/dev/input/mice","r"); int xd=0,yd=0; //x/y movement delta int xo=0,yo=0; //x/y overflow (out of range -255 to +255) int lb=0,mb=0,rb=0,hs=0,vs=0; //left/middle/right mousebutton int run=0; while(!run){ fread(b,sizeof(char),3,fmouse); lb=(b[0]&1)>0; rb=(b[0]&2)>0; mb=(b[0]&4)>0; hs=(b[0]&16)>0; vs=(b[0]&32)>0; xo=(b[0]&64)>0; yo=(b[0]&128)>0; xd=b[1]; yd=b[2]; printf("hs=%d,vs=%d,lb=%d rm=%d mb=%d xo=%d yo=%d xd=%d yd=%d\n",hs,vs,lb,rb,mb,xo,yo,xd,yd); } fclose(fmouse); }