From d9d998644defec48172fde353f0a339933800cce Mon Sep 17 00:00:00 2001 From: epoch Date: Sun, 12 Apr 2020 23:45:07 -0500 Subject: fixed up the /dev/input/event (die) inputs to work better with libidc --- src/mouse_die.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/mouse_die.c') diff --git a/src/mouse_die.c b/src/mouse_die.c index 6729a94..b17c143 100644 --- a/src/mouse_die.c +++ b/src/mouse_die.c @@ -18,13 +18,21 @@ struct wtf { 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 l; memset(&ie,0,sizeof(ie)); if(mfd == -1) { mfd=open(MOUSEDEV,O_RDWR); - fcntl(mfd,F_SETFL,O_NONBLOCK); + //probably don't need nonblock anymore. + //fcntl(mfd,F_SETFL,O_NONBLOCK); } if(mfd == -1) { fprintf(stderr,"# mouse shit fucked up.\n"); -- cgit v1.2.3 From aff5af827cf8906486fe2c363c2e91e9e06da1f3 Mon Sep 17 00:00:00 2001 From: epoch Date: Tue, 14 Apr 2020 06:01:59 -0500 Subject: redid most of the /dev/input/mice code --- src/mouse_die.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'src/mouse_die.c') diff --git a/src/mouse_die.c b/src/mouse_die.c index b17c143..4fddf5f 100644 --- a/src/mouse_die.c +++ b/src/mouse_die.c @@ -4,6 +4,10 @@ #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. @@ -27,7 +31,10 @@ int mouse_init() { 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); @@ -40,7 +47,43 @@ int mouse_event_handler() { } if((l=read(mfd,&ie,sizeof(ie))) > 0) { //type == 8 and a or of some bits to say which direction. - fprintf(stderr,"# mouse debug: type:\t%d\tdx:%d\tdy:%d\n",ie.type,ie.dx,ie.dy); + //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<