summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2020-02-24 00:49:21 -0600
committerepoch <epoch@hacking.allowed.org>2020-02-24 00:49:21 -0600
commit7272b080db41ef9033b83a991ee44e7a24176b62 (patch)
treeb52478f28438a14d1ed7eb1de129e0e86b397487 /src
parentb1f45a8a1528ba0f9c2068844df2e6293e5e46db (diff)
downloadhackvr-7272b080db41ef9033b83a991ee44e7a24176b62.tar.gz
hackvr-7272b080db41ef9033b83a991ee44e7a24176b62.zip
made the camera control with the secondary mouse button work in a way that is easier to use
Diffstat (limited to 'src')
-rw-r--r--src/graphics_c3.h2
-rw-r--r--src/mouse_x11.c6
2 files changed, 6 insertions, 2 deletions
diff --git a/src/graphics_c3.h b/src/graphics_c3.h
index 691b650..b609721 100644
--- a/src/graphics_c3.h
+++ b/src/graphics_c3.h
@@ -23,6 +23,8 @@ struct gra_global {
int mapxoff;
int mapyoff;
int mousemap[10];//you're only going to have 10 buttons on your mouse... right?
+ c2_t dragstart[10];//mouse coordinates where a drag was started
+ c3_rot_t oldcamera;
int maxshapes;
};
diff --git a/src/mouse_x11.c b/src/mouse_x11.c
index 23ec5ab..16c577c 100644
--- a/src/mouse_x11.c
+++ b/src/mouse_x11.c
@@ -38,12 +38,14 @@ int mouse_event_handler() {//this returns HVM_ key + for buttondown and - for bu
printf("# gra_global.input_mode == %d\n",gra_global.input_mode);
}
printf("# button press %d\n",butt);
+ gra_global.dragstart[butt]=gra_global.mouse;
gra_global.mousemap[butt]=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
+ gra_global.oldcamera=global.camera.r;
redrawplzkthx=1;
break;
case MotionNotify:
@@ -68,8 +70,8 @@ int mouse_event_handler() {//this returns HVM_ key + for buttondown and - for bu
//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);
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);
+ global.camera.r.x.d=gra_global.oldcamera.x.d + (gra_global.mouse.y - gra_global.dragstart[2].y);
+ global.camera.r.y.d=gra_global.oldcamera.y.d + (gra_global.mouse.x - gra_global.dragstart[2].x);
}
}
if(redrawplzkthx) {