diff options
author | epoch <epoch@hacking.allowed.org> | 2019-02-05 22:09:13 -0600 |
---|---|---|
committer | epoch <epoch@hacking.allowed.org> | 2019-02-05 22:09:13 -0600 |
commit | 888b870c576313c4c4c13958acb7d0e833b375c1 (patch) | |
tree | 8034e567b917cc5d20670f76b131c6f611f14528 /src/mouse_die.c | |
parent | 7bfb38770dbbce06cef6208705fc7d28af561413 (diff) | |
download | hackvr-888b870c576313c4c4c13958acb7d0e833b375c1.tar.gz hackvr-888b870c576313c4c4c13958acb7d0e833b375c1.zip |
added the separated out mouse and keyboard files
Diffstat (limited to 'src/mouse_die.c')
-rw-r--r-- | src/mouse_die.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/mouse_die.c b/src/mouse_die.c new file mode 100644 index 0000000..6729a94 --- /dev/null +++ b/src/mouse_die.c @@ -0,0 +1,38 @@ +#include <stdio.h> +#include <string.h> +#include <linux/input.h> +#include <fcntl.h> +#include <unistd.h> + + +//#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_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); + } + 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. + fprintf(stderr,"# mouse debug: type:\t%d\tdx:%d\tdy:%d\n",ie.type,ie.dx,ie.dy); + } + return 0; +} |