diff options
| author | epoch <epoch@hacking.allowed.org> | 2020-01-27 18:00:00 -0600 | 
|---|---|---|
| committer | epoch <epoch@hacking.allowed.org> | 2020-01-27 18:00:00 -0600 | 
| commit | a56b739dcde3cba228a5be6150bbfa525a56eebb (patch) | |
| tree | a599305f5004ebd183e39a97cbb9a8337f61e863 | |
| parent | 9372595d5bb91c0c2ecadaf796433b5b3f1b9c66 (diff) | |
| download | hackvr-a56b739dcde3cba228a5be6150bbfa525a56eebb.tar.gz hackvr-a56b739dcde3cba228a5be6150bbfa525a56eebb.zip | |
added scroll-wheel handling for X11 mouse and removed camera rotation from mouse movement
| -rw-r--r-- | src/mouse_x11.c | 16 | 
1 files changed, 14 insertions, 2 deletions
| diff --git a/src/mouse_x11.c b/src/mouse_x11.c index c70ea1a..0c4f1e9 100644 --- a/src/mouse_x11.c +++ b/src/mouse_x11.c @@ -4,7 +4,7 @@  #include "graphics_c2.h"  #include "graphics_x11.h" -extern struct global global; +extern struct hvr_global global;  extern struct gra_global gra_global;  extern struct x11_global x11_global; @@ -20,13 +20,22 @@ int mouse_event_handler() {//this returns HVM_ key + for buttondown and - for bu    char redrawplzkthx=0;    cs_t mouse;    cs_t rmouse; +//  char cmd[512];    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 +      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 //scroll wheel up is 3, down is 4 +        if(e.xbutton.button == 4) {//scroll wheel up +          selfcommand("epoch move forward\n");//need to implement this syntax in hackvr +        } +        if(e.xbutton.button == 5) {//scroll wheel down +          selfcommand("epoch move backward\n"); +        } +        printf("# button press %d\n",e.xbutton.button-1);          gra_global.mousemap[e.xbutton.button-1]=1;          redrawplzkthx=1;          break;        case ButtonRelease: +        printf("# button release %d\n",e.xbutton.button-1);          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          redrawplzkthx=1;          break; @@ -45,6 +54,9 @@ int mouse_event_handler() {//this returns HVM_ key + for buttondown and - for bu      //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... +    //self-command myself to rotate myself? +    //snprintf(cmd,sizeof(cmd),"%s rotate +%d +%d +%d\n",global.user,3,11,1); +    //selfcommand(cmd);      //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));    } | 
