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_x11.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_x11.c')
-rw-r--r-- | src/mouse_x11.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/mouse_x11.c b/src/mouse_x11.c new file mode 100644 index 0000000..6cb1490 --- /dev/null +++ b/src/mouse_x11.c @@ -0,0 +1,43 @@ +#include "mouse_x11.h" +#include "common.h" +#include "graphics_c3.h" +#include "graphics_c2.h" +#include "graphics_x11.h" + +extern struct global global; +extern struct gra_global gra_global; +extern struct x11_global x11_global; + +int mouse_event_handler() {//this returns HVM_ key + for buttondown and - for buttonup... set the mousex and mousey in here? + XEvent e; + Window root,child;//just dimmies + unsigned int mask;//just dummies + char motion_notify=0; + cs_t mouse; + cs_t rmouse; + while(XCheckMaskEvent(x11_global.dpy,HV_MOUSE_X11_EVENT_MASK,&e)) {//we want to collapse mouse stuff to one for each loop. + switch(e.type) { + case ButtonPress: //e.xbutton.button == 1 for first button. we don't need to start at 1. let's start at 0 with the -1 + gra_global.mousemap[e.xbutton.button-1]=1; + break; + case ButtonRelease: + gra_global.mousemap[e.xbutton.button-1]=-1;//we can trigger on -1 or on 1 then set back to 0 to prevent double-trigger + break; + case MotionNotify: + motion_notify=1; + break; + } + } + if(motion_notify) { + //mouse.x and mouse.y are shorts. this function expects ints. why are these shorts? + XQueryPointer(x11_global.dpy,x11_global.w,&root,&child,&rmouse.x,&rmouse.y,&mouse.x,&mouse.y,&mask); + gra_global.mouse=cs_to_c2(mouse); + //return 1; + //we're not going to set camera based on mousex and y here. + //but just so I can get it out of the graphics code... + //global.camera.r.x.d=((gra_global.height/2) - gra_global.mouse.y); + //global.camera.r.y.d=(gra_global.mouse.x - (gra_global.width/2)); + return 1; + } + return 0; +} |