Danke für die Aufklärung![]()
Hab deine Tips mal umgesetzt und noch alles etwas verschönert. Denke so kann mans vorsichtig mal ne Beta nennen *g*
Isses schlimm das es ne endlosschleife is und man es manuell killen muss? muss/sollte man da noch explizit auf signale reagieren und das fclose dann doch noch irgendwie ausführen oder so? kenn mich da noch nich so jut aus :-/Code:#include <stdio.h> #include <stdlib.h> #include <time.h> main(int argc, char *argv[]){ char *device = "/dev/input/mice"; FILE *fmouse; char b[3]; if(argc>1){ if(strcmp(argv[1],"-?")==0 || argc > 2){ printf("Usage:\nmousereader [device]\t(default is /dev/input/mice)\n"); printf("Format:\nlb;mb;rb;xd;yd\t(left-,middle-,right mousebutton, x delta, y delta)\n"); return 0; }else{ device = argv[1]; } } fmouse = fopen(device,"r"); if(fmouse==NULL){ printf("Could not open device '%s'. Check permissions!\n",device); return 0; } 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; //left/middle/right mousebutton while(1){ fread(b,sizeof(char),3,fmouse); lb=(b[0]&1)>0; rb=(b[0]&2)>0; mb=(b[0]&4)>0; xo=(b[0]&64)>0; yo=(b[0]&128)>0; xd=b[1]; yd=b[2]; //printf("lb=%d rm=%d mb=%d xo=%d yo=%d xd=%d yd=%d\n",lb,rb,mb,xo,yo,xd,yd); printf("%d;%d;%d;%d;%d\n",lb,mb,rb,xd,yd); usleep(10); } //fclose(fmouse); }







Zitieren

Lesezeichen