From 18fbe060074d8c2ed1b739dac1051fbe1e170301 Mon Sep 17 00:00:00 2001 From: epoch Date: Mon, 24 Feb 2020 00:23:04 -0600 Subject: added two new mouse controls. secondary click will enable camera movement. middle-click will toggle keyboard input mode. --- src/mouse_x11.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/mouse_x11.c b/src/mouse_x11.c index 2442953..23ec5ab 100644 --- a/src/mouse_x11.c +++ b/src/mouse_x11.c @@ -19,20 +19,26 @@ int mouse_event_handler() {//this returns HVM_ key + for buttondown and - for bu unsigned int mask;//just dummies char motion_notify=0; char redrawplzkthx=0; + int butt; 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 //scroll wheel up is 3, down is 4 - if(e.xbutton.button == 4) {//scroll wheel up + butt=e.xbutton.button-1; + if(butt == 3) {//scroll wheel up selfcommand("epoch move forward\n");//need to implement this syntax in hackvr } - if(e.xbutton.button == 5) {//scroll wheel down + if(butt == 4) {//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; + if(butt == 1) {//middle-click + gra_global.input_mode ^= 1; + printf("# gra_global.input_mode == %d\n",gra_global.input_mode); + } + printf("# button press %d\n",butt); + gra_global.mousemap[butt]=1; redrawplzkthx=1; break; case ButtonRelease: @@ -61,8 +67,10 @@ int mouse_event_handler() {//this returns HVM_ key + for buttondown and - for bu //selfcommand(cmd); //global.camera.r.x.d=(gra_global.height - gra_global.mouse.y);//up and down camera controls backwards //fprintf(stderr,"# mouse.x: %f mouse.y: %f\n# width: %u height: %u\n",gra_global.mouse.x,gra_global.mouse.y,gra_global.width,gra_global.height); - global.camera.r.x.d=(gra_global.mouse.y); - global.camera.r.y.d=(gra_global.mouse.x); + if(gra_global.mousemap[2] == 1) {//if "right" click is held down + global.camera.r.x.d=(gra_global.mouse.y); + global.camera.r.y.d=(gra_global.mouse.x); + } } if(redrawplzkthx) { redraw(); -- cgit v1.2.3