#include #include #include #include #include #include "graphics_c3.h" extern struct hvr_global global; extern struct gra_global gra_global; //#define MOUSEDEV "/dev/input/mouse0" //just one of the many possibly connected mice. (just in case you want to use one mouse for one thing and another mouse for something else) #define MOUSEDEV "/dev/input/mice" //all the mice connected act as one. int mfd = -1; //#define "mouse.h" //I guess struct wtf { unsigned char type; char dx; char dy; }; int mouse_init() { if((mfd=open(MOUSEDEV,O_RDWR)) == -1) { fprintf(stderr,"# failed to open mouse: %d\n",mfd); } return mfd; } int mouse_event_handler() { struct wtf ie; int butt; int l; int i; int redrawplzkthx=0; memset(&ie,0,sizeof(ie)); if(mfd == -1) { mfd=open(MOUSEDEV,O_RDWR); //probably don't need nonblock anymore. //fcntl(mfd,F_SETFL,O_NONBLOCK); } if(mfd == -1) { fprintf(stderr,"# mouse shit fucked up.\n"); return 1; } if((l=read(mfd,&ie,sizeof(ie))) > 0) { //type == 8 and a or of some bits to say which direction. //these types are movement: 8 40 56 24 for(i=0;i<4;i++) {//we need to loop over all buttons each event. :/ butt=ie.type & 0x07 & (1<