summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorepoch <epoch@thebackupbox.net>2020-10-10 00:00:55 -0500
committerepoch <epoch@thebackupbox.net>2020-10-10 00:00:55 -0500
commitfe9ad894000ff986cd642d23ac4762e97d5b1ccc (patch)
tree1e253ac02dc7d3339b60ca68d9bfca24cbd3ef7e /src
parent19feecae5124e5eb4c8a2f2dfd300e94e59b9d9f (diff)
parent4982876f0d021e4637f6db500063169477fe7289 (diff)
downloadhackvr-fe9ad894000ff986cd642d23ac4762e97d5b1ccc.tar.gz
hackvr-fe9ad894000ff986cd642d23ac4762e97d5b1ccc.zip
Merge branch 'master' of ssh://batou.thebackupbox.net:65432/hackvr
Diffstat (limited to 'src')
-rw-r--r--src/Makefile28
-rw-r--r--src/graphics_c2.h5
-rw-r--r--src/graphics_c3.c38
-rw-r--r--src/graphics_c3.h3
-rw-r--r--src/graphics_cs.h3
-rw-r--r--src/graphics_cs_svg.c270
-rw-r--r--src/graphics_svg.h15
-rw-r--r--src/hackvr.c44
l---------src/hackvr_svg.c1
l---------src/hackvr_xdiewii.c1
-rw-r--r--src/keyboard_die.c6
-rw-r--r--src/math.c17
-rw-r--r--src/mouse.h11
-rw-r--r--src/mouse_die.c57
-rw-r--r--src/mouse_wii.c145
-rw-r--r--src/mouse_x11.c60
16 files changed, 615 insertions, 89 deletions
diff --git a/src/Makefile b/src/Makefile
index 398aaa8..6187723 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -11,15 +11,18 @@ LIBHASHTABLE_INCLUDE_PATH:=$(PREFIX)/include
BASE_CFLAGS=-g -Wall -pedantic -std=c99 -ffast-math -I$(PREFIX)/include -I$(LIBIDC_INCLUDE_PATH) -I$(LIBHASHTABLE_INCLUDE_PATH)
-CFLAGS+=$(BASE_CFLAGS)
-CFLAGS+=-DGRAPHICAL
+override CFLAGS+=$(BASE_CFLAGS)
+override CFLAGS+=-DGRAPHICAL
-LDFLAGS+=-L$(PREFIX)/lib -L$(LIBIDC_LIB_PATH) -L$(LIBHASHTABLE_LIB_PATH)
+override LDFLAGS+=-L$(PREFIX)/lib -L$(LIBIDC_LIB_PATH) -L$(LIBHASHTABLE_LIB_PATH)
#all: hackvr_headless hackvr_x11 hackvr_opengl slowcat ### when hackvr_opengl gets useful at all I'll start including it in default build.
-all: hackvr_fb hackvr_xdie hackvr_headless hackvr_x11 slowcat nonblocktail
+all: hackvr_svg hackvr_fb hackvr_xdie hackvr_headless hackvr_x11 slowcat nonblocktail hackvr_xdiewii
# hackvr_fb hackvr_freeglut slowcat
+hackvr_xdiewii: override LDLIBS+=-lm -lidc -lX11 -lhashtable
+hackvr_xdiewii: hackvr_xdiewii.o graphics_c3.o graphics_c2.o graphics_cs_x11.o math.o physics.o keyboard.o mouse_wii.o keyboard_x11.o
+
hackvr_xdie: override LDLIBS+=-lm -lidc -lX11 -lhashtable
hackvr_xdie: hackvr_xdie.o graphics_c3.o graphics_c2.o graphics_cs_x11.o math.o physics.o keyboard.o mouse_die.o keyboard_die.o
@@ -32,6 +35,9 @@ hackvr_headless: hackvr_headless.o math.o physics.o
hackvr_x11: override LDLIBS+=-lm -lidc -lX11 -lhashtable
hackvr_x11: hackvr_x11.o graphics_c3.o graphics_c2.o graphics_cs_x11.o math.o physics.o keyboard.o mouse_x11.o keyboard_x11.o
+hackvr_svg: override LDLIBS+=-lm -lidc -lhashtable
+hackvr_svg: hackvr_svg.o graphics_c3.o graphics_c2.o graphics_cs_svg.o math.o physics.o keyboard.o keyboard_die.o mouse_die.o
+
#notice how all the targets have generic graphics objects up until a specific one.
hackvr_fb: override LDLIBS+=-lm -lidc -lhashtable
@@ -43,11 +49,13 @@ hackvr_opengl: hackvr_opengl.o graphics_c3.o graphics_c2_opengl.o graphics_cs_op
hackvr_freeglut: override LDLIBS+=-lm -lidc -lGL -lGLU -lglut -lhashtable
hackvr_freeglut: hackvr_freeglut.o graphics_c3_freeglut.o math.o physics.o keyboard.o mouse_die.o keyboard_die.o
-hackvr_fb.o: CFLAGS+='-DHVR_VERSION="framebuffer"'
-hackvr_x11.o: CFLAGS+='-DHVR_VERSION="x11"'
-hackvr_xdie.o: CFLAGS+='-DHVR_VERSION="x11+die"'
-hackvr_headless.o: CFLAGS=$(BASE_CFLAGS)
-hackvr_headless.o: CFLAGS+='-DHVR_VERSION="headless"'
+hackvr_fb.o: override CFLAGS+='-DHVR_VERSION="framebuffer"'
+hackvr_x11.o: override CFLAGS+='-DHVR_VERSION="x11"'
+hackvr_xdie.o: override CFLAGS+='-DHVR_VERSION="x11+die"'
+hackvr_xdiewii.o: override CFLAGS+='-DHVR_VERSION="x11+kdie+wii"'
+hackvr_svg.o: override CFLAGS+='-DHVR_VERSION="svg"'
+hackvr_headless.o: override CFLAGS=$(BASE_CFLAGS)
+hackvr_headless.o: override CFLAGS+='-DHVR_VERSION="headless"'
install: all
mkdir -p $(PREFIX)/bin
@@ -57,6 +65,8 @@ install: all
install -t $(PREFIX)/bin nonblocktail
install -t $(PREFIX)/bin hackvr_xdie
install -t $(PREFIX)/bin hackvr_fb
+ install -t $(PREFIX)/bin hackvr_svg
+ install -t $(PREFIX)/bin hackvr_xdiewii
# install -t $(PREFIX)/bin hackvr_freeglut
uninstall:
diff --git a/src/graphics_c2.h b/src/graphics_c2.h
index 35920fd..8a481d9 100644
--- a/src/graphics_c2.h
+++ b/src/graphics_c2.h
@@ -3,6 +3,11 @@
#include "math.h"
+#define TOP 240.0
+#define BOTTOM -240.0
+#define RIGHT 320.0
+#define LEFT -320.0
+
int c2sX(real x);
int s2cX(real x);
int c2sY(real y);
diff --git a/src/graphics_c3.c b/src/graphics_c3.c
index eb63909..72a03e3 100644
--- a/src/graphics_c3.c
+++ b/src/graphics_c3.c
@@ -10,6 +10,7 @@
#include "config.h"
#include "common.h"
+#include "mouse.h"
//#include "graphics_cs.h" //this header includes all the functions you'll need to implement if you want to port hackvr to something else
#include "graphics_c3.h"//we're defining these functions in this file.
@@ -28,14 +29,6 @@ struct gra_global gra_global;
#ifdef GRAPHICAL
-//used to figure out what c2 values are associated with each edge of the window.
-//#define TOP 160.0
-//#define BOTTOM -160.0
-#define TOP 240.0
-#define BOTTOM -240.0
-#define RIGHT 320.0
-#define LEFT -320.0
-
/*
real distance2(c2_t p1,c2_t p2) {
return sqrt(( (p1.x-p2.x)*(p1.x-p2.x) )+( (p1.y-p2.y)*(p1.y-p2.y) ));
@@ -127,6 +120,7 @@ c3_t c3_subtract(c3_t p1,c3_t p2) {
//how is this supposed to work? x is distance?
#define MAGIC(x) (1.0l-(1.0l/pow(1.01l,(x)))) //??? might want to have some changables in here
+//#define MAGIC(x) (1.0l-(1.0l/pow(1.0001l,(x))))
//#define MAGIC(x) (-250.0l / x )
#define TOO_CLOSE (.25l)
@@ -153,12 +147,13 @@ c2_t c3_to_c2(c3_group_rel_t eye,c3_t p3) { //DO NOT DRAW STUFF IN HERE
real delta_x=(eye.p.x - final.x);//I guess X needs this flippage too.
real delta_y=(eye.p.y - final.y);//I dunno. Y is weird.
real delta_z=(final.z - eye.p.z);
- //real d=distance3(global.camera.p,final);
+ //real d=distance3(eye.p,final);
+
p2.x=global.zoom * (delta_x * MAGIC(delta_z) - delta_x);
p2.y=global.zoom * (delta_y * MAGIC(delta_z) - delta_y);//this doesn't look right either.
- // p2.x=global.zoom * (delta_x * MAGIC(d) - delta_x); // this doesn't look quite right
-// p2.y=global.zoom * (delta_y * MAGIC(d) - delta_y);//dunno if this is better or not.
+ //p2.x=2 * (d * MAGIC(d) - delta_x); // this doesn't look quite right
+ //p2.y=2 * (d * MAGIC(d) - delta_y); // dunno if this is better or not.
return p2;
}
@@ -421,9 +416,13 @@ void draw_screen() {
//draw_sky();//???p?
//XCopyArea(global.dpy,skypixmap,global.backbuffer,global.backgc,((camera.yr*5)+SKYW)%SKYW,0,WIDTH,global.height/2,0,0);
}
- if(gra_global.draw3d) {//wtf? why do I not compensate for camaera rotation along the x and z?
- //draw_c2_line((c2_t){LEFT,0},(c2_t){RIGHT,0}); //horizon
- }
+ //if(gra_global.draw3d) {//wtf? why do I not compensate for camaera rotation along the x and z?
+ //horizon line
+ draw_c2_line((c2_t){LEFT,
+ (int)((real)(global.camera.r.x.d) * (real)(BOTTOM+BOTTOM) / (real)90.0)},
+ (c2_t){RIGHT,
+ (int)((real)(global.camera.r.x.d) * (real)(BOTTOM+BOTTOM) / (real)90.0)});
+ //}
///// shiiiit. I should be applying group rotations to all these shapes before sorting them.
//when I do that. I need to make sure to take the group rotation out of draw_c3_shape()'s code.
for(i=0;global.shape[i];i++) {
@@ -458,9 +457,9 @@ void draw_screen() {
//}
}
//we check here to see if the mouse button is still down
- if(gra_global.mousemap[0]==-1) {
+ if(gra_global.mousemap[MOUSE_PRIMARY]==-1) {//0 in x11
printf("%s action %f %f\n",global.user,gra_global.mouse.x,gra_global.mouse.y);
- gra_global.mousemap[0]=0;
+ gra_global.mousemap[MOUSE_PRIMARY]=0;
}
/*
if(gra_global.drawminimap == 1) {
@@ -515,9 +514,10 @@ void draw_screen() {
}
void redraw() {//something is requesting a redraw.
- if(gra_global.force_redraw == 0) {
- gra_global.force_redraw=1;//this is to prevent drawing way too often.
- write(gra_global.redraw[1],"redraw plzkthx!\n",16);
+ if(gra_global.redrawplzkthx == 0) {
+ gra_global.redrawplzkthx=1;//this is to prevent drawing way too often.
+ //fprintf(stderr,"# in the redraw() function\n");
+ write(gra_global.redraw[1],"redrawplzkthx!\n",15);
}
}
diff --git a/src/graphics_c3.h b/src/graphics_c3.h
index ce3354c..36b7c6b 100644
--- a/src/graphics_c3.h
+++ b/src/graphics_c3.h
@@ -13,7 +13,8 @@ struct gra_global {
int split_screen;
real split;
int split_flip;
- char force_redraw;
+ char force_redraw;//this should be to make it draw as often as possible
+ char redrawplzkthx;//this is just a flag that redraw() sets, so if multiple draws are asked for, it can clear all of them at once instead of queueing them
char red_and_blue;
unsigned int depth;//???
unsigned int border_width;
diff --git a/src/graphics_cs.h b/src/graphics_cs.h
index a16f03f..1abba31 100644
--- a/src/graphics_cs.h
+++ b/src/graphics_cs.h
@@ -4,9 +4,6 @@
#include "math.h"
#include <idc.h>
-//these are just the functions that all backends need to implement to work with hackvr.
-//the list of functions are subject to change.
-
void draw_cs_line(cs_t p1,cs_t p2);
void draw_cs_text(cs_t p,char *text);
void draw_cs_shape(cs_s_t s);
diff --git a/src/graphics_cs_svg.c b/src/graphics_cs_svg.c
new file mode 100644
index 0000000..305ad39
--- /dev/null
+++ b/src/graphics_cs_svg.c
@@ -0,0 +1,270 @@
+#define _POSIX_C_SOURCE 200809L //for fileno and strdup
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <assert.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <stdlib.h>
+//#include <sys/select.h> //code to use select instead of non-blocking is commented out. might decide to use it later.
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+#include <X11/cursorfont.h>
+#include <X11/Xutil.h> //for size hints
+#include <time.h>
+
+#include "config.h"
+#include "math.h"
+#include "common.h"
+#include "graphics_c3.h"//not needed?
+#include "graphics_svg.h"
+#include "graphics_c2.h"
+#include "graphics_cs.h"
+
+//typedef float real; //think this conflicts?
+
+//TODO: will have to make some pixmaps get resized when the window does.
+//for now set them to be as big as you think you'll ever resize the window to.
+
+//#define SKYRULE 90
+//#define SKYW (WIDTH*5)
+//#define SKYH (HEIGHT/2)
+
+//Pixmap skypixmap;
+//char sky[SKYH][SKYW];
+
+extern struct hvr_global global;
+extern struct gra_global gra_global;
+struct svg_global svg_global;
+
+#ifdef GRAPHICAL
+
+void set_luminosity_color(int lum) {
+ svg_global.foreground_color=svg_global.colors[lum%100];
+}
+
+
+void draw_cs_line(cs_t p1,cs_t p2) {
+ char tmp[1024];
+ snprintf(tmp,sizeof(tmp)-1,"<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke=\"%s\" />\n"
+ ,p1.x ,p1.y ,p2.x ,p2.y ,svg_global.foreground_color);
+ strcat(svg_global.backbuffer,tmp);
+}
+
+void draw_cs_text(cs_t p,char *text) {//lol. I don't even use this anymore.
+/* char t[256];
+ int direction,ascent,descent;
+ XFontStruct *font=XLoadQueryFont(x11_global.dpy,"fixed");
+ XCharStruct overall;
+ snprintf(t,sizeof(t)-1,"%s",text);
+ XTextExtents(font,text,strlen(text),&direction,&ascent,&descent,&overall);
+ XDrawString(x11_global.dpy,x11_global.backbuffer,x11_global.backgc,p.x,p.y+(descent+ascent),text,strlen(text));
+*/
+}
+
+void draw_cs_shape(cs_s_t s) {//this is implemented as draw_cs_line... hrm. it could be moved up to graphics.c? probl no.
+ char tmp[1024];
+ //cs_t smouse=c2_to_cs(gra_global.mouse);
+ int i;//all cs shapes can have 1, 2, or 3+ points. guess I gotta do that logic here too.
+ switch(s.len) {
+ case 1:
+ break;
+ default:
+ strcat(svg_global.backbuffer,"<polygon points=\"");
+ for(i=0;i<s.len+(s.len==1);i++) {//this shape is closed!
+ snprintf(tmp,sizeof(tmp)-1,"%d,%d",s.p[i].x,s.p[i].y);
+ strcat(svg_global.backbuffer,tmp);
+ if(i != s.len-1) strcat(svg_global.backbuffer," ");//only print space after points that have a point after them.
+ }
+ snprintf(tmp,sizeof(tmp)-1,"\" fill=\"dark%s\" stroke=\"%s\" />\n",svg_global.foreground_color,svg_global.foreground_color);
+ strcat(svg_global.backbuffer,tmp);
+ break;
+ }
+}
+
+void draw_cs_filled_shape(cs_s_t s) {
+ int i;
+ char tmp[1024];
+ switch(s.len) {
+ case 1:
+ break;
+ default:
+ strcat(svg_global.backbuffer,"<polygon points=\"");
+ for(i=0;i<s.len+(s.len==1);i++) {//this shape is closed!
+ snprintf(tmp,sizeof(tmp)-1,"%d,%d",s.p[i].x,s.p[i].y);
+ strcat(svg_global.backbuffer,tmp);
+ if(i != s.len-1) strcat(svg_global.backbuffer," ");//only print space after points that have a point after them.
+ }
+ snprintf(tmp,sizeof(tmp)-1,"\" fill=\"%s\" stroke=\"%s\" />\n",svg_global.foreground_color,svg_global.foreground_color);
+ strcat(svg_global.backbuffer,tmp);
+ break;
+ }
+}
+
+//should I do clipping in each graphics lib or make graphics.c just have clipping stuff?
+void clear_backbuffer() {
+// strcpy(svg_global.backbuffer,"<?xml version=\"1.0\" standalone=\"no\">\n");
+ strcpy(svg_global.backbuffer,"<html><head><meta http-equiv=\"refresh\" content=\"0\" /></head><body>\n");
+ strcat(svg_global.backbuffer,"<svg width=\"1024\" height=\"768\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n");
+}
+
+void set_clipping_rectangle(int x,int y,int width,int height) {
+/*
+ XRectangle cliprect;
+ cliprect.x=0;
+ cliprect.y=0;
+ cliprect.width=width;
+ cliprect.height=height;
+ XSetClipRectangles(x11_global.dpy,x11_global.backgc,x,y,&cliprect,1,Unsorted);
+*/
+}
+
+void draw_mode_copy() {
+/*
+ XGCValues gcval;
+ gcval.function=GXcopy;
+ XChangeGC(x11_global.dpy,x11_global.backgc,GCFunction,&gcval);
+*/
+}
+
+void draw_mode_and() {
+/*
+ XGCValues gcval;
+ gcval.function=GXand;
+ XChangeGC(x11_global.dpy,x11_global.backgc,GCFunction,&gcval);
+*/
+}
+
+void draw_mode_or() {
+/*
+ XGCValues gcval;
+ gcval.function=GXor;
+ XChangeGC(x11_global.dpy,x11_global.backgc,GCFunction,&gcval);
+*/
+}
+
+void red_and_blue_magic() {
+ //draw_mode_or();
+}
+
+//void draw_sky() {
+// XCopyArea(x11_global.dpy,skypixmap,x11_global.backbuffer,x11_global.backgc,((global.camera.yr.d*5)+SKYW)%SKYW,0,WIDTH,gra_global.height/2,0,0);
+//}
+
+void set_color_snow() {
+ //x11_global.snow=1;//override foreground color in the draw functions. drawing different grey each time.
+}
+
+void set_ansi_color(int i) {
+ svg_global.foreground_color=svg_global.ansi_color[i];
+}
+
+void set_color() {
+ svg_global.foreground_color=svg_global.green;
+}
+
+void set_color_red() {
+ svg_global.foreground_color=svg_global.red;
+}
+
+void set_color_blue() {
+ svg_global.foreground_color=svg_global.blue;
+}
+
+void flipscreen() {
+ fprintf(stderr,"# flipping screen!\n");
+// strcat(svg_global.backbuffer,"</svg>\n</xml>\n");
+ strcat(svg_global.backbuffer,"</svg></body></html>\n");
+ int fd=open(svg_global.filename,O_TRUNC|O_WRONLY|O_CREAT);
+ write(fd,svg_global.backbuffer,strlen(svg_global.backbuffer));
+ close(fd);
+}
+
+void set_aspect_ratio() {
+/*
+ XSizeHints *hints=XAllocSizeHints();
+ hints->min_aspect.x=AR_W*(gra_global.split_screen / (gra_global.red_and_blue ? gra_global.split_screen : 1));
+ hints->min_aspect.y=AR_H;
+ hints->max_aspect.x=AR_W*(gra_global.split_screen / (gra_global.red_and_blue ? gra_global.split_screen : 1));
+ hints->max_aspect.y=AR_H;
+ hints->flags |= PAspect;
+ XSetWMNormalHints(x11_global.dpy,x11_global.w,hints);
+ XFree(hints);
+*/
+}
+
+void set_demands_attention() {
+/*
+ XWMHints *hints=XGetWMHints(x11_global.dpy,x11_global.w);
+ if(!hints) hints=XAllocWMHints();
+ hints->flags |= XUrgencyHint;
+ XSetWMHints(x11_global.dpy,x11_global.w,hints);
+ XFree(hints);
+*/
+}
+
+void set_title(char *t) {
+ //XStoreName(x11_global.dpy,x11_global.w,t);
+}
+
+int graphics_sub_init() {//this returns an fd we need to keep an eye one? :/
+ svg_global.filename="/tmp/hackvr.html";
+ svg_global.ansi_color[0]="black";
+ svg_global.ansi_color[1]="blue";
+ svg_global.ansi_color[2]="green";
+ svg_global.ansi_color[3]="cyan";
+ svg_global.ansi_color[4]="red";
+ svg_global.ansi_color[5]="magenta";
+ svg_global.ansi_color[6]="yellow";
+ svg_global.ansi_color[7]="white";
+ svg_global.ansi_color[8]=0;
+/* x11_global.fd=ConnectionNumber(x11_global.dpy);//we need to to pass to libidc
+ x11_global.color_map=DefaultColormap(x11_global.dpy, DefaultScreen(x11_global.dpy));
+ fprintf(stderr,"# generating colors...\n");
+ for(i=0;ansi_color[i];i++) {
+ XAllocNamedColor(x11_global.dpy,x11_global.color_map,ansi_color[i],&x11_global.ansi_color[i],&x11_global.ansi_color[i]);
+ }
+ for(i=0;i<=100;i++) {
+ snprintf(tmp,sizeof(tmp),"gray%d",i);
+ XAllocNamedColor(x11_global.dpy,x11_global.color_map,tmp,&x11_global.colors[i],&x11_global.colors[i]);
+ }
+ fprintf(stderr,"# done.\n");
+ assert(x11_global.dpy);
+ x11_global.root_window=0;
+ //global.colors[0]=BlackPixel(x11_global.dpy,DefaultScreen(x11_global.dpy));
+// int whiteColor = //WhitePixel(x11_global.dpy, DefaultScreen(x11_global.dpy));
+ attributes.background_pixel=x11_global.colors[0].pixel;
+ if(x11_global.root_window) {
+ x11_global.w = DefaultRootWindow(x11_global.dpy); //this is still buggy.
+ } else {
+ fprintf(stderr,"# creating window...\n");
+ x11_global.w = XCreateWindow(x11_global.dpy,DefaultRootWindow(x11_global.dpy),0,0,WIDTH*(gra_global.split_screen / (gra_global.red_and_blue ? gra_global.split_screen : 1)),HEIGHT,1,DefaultDepth(x11_global.dpy,DefaultScreen(x11_global.dpy)),InputOutput,DefaultVisual(x11_global.dpy,DefaultScreen(x11_global.dpy))\
+ ,CWBackPixel, &attributes);
+ fprintf(stderr,"# done. window id: %ld\n",x11_global.w);
+ set_aspect_ratio();
+ XSelectInput(x11_global.dpy, x11_global.w, HV_MOUSE_X11_EVENT_MASK|HV_X11_KB_EVENT_MASK|HV_GRAPHICS_X11_EVENT_MASK);
+ }
+ XMapWindow(x11_global.dpy,x11_global.w);
+ set_title("hackvr");//uses the globals to know what dpy and w
+ x11_global.gc=XCreateGC(x11_global.dpy,x11_global.w, 0, 0);
+ x11_global.backbuffer=XCreatePixmap(x11_global.dpy,x11_global.w,MAXWIDTH,MAXHEIGHT,DefaultDepth(x11_global.dpy,DefaultScreen(x11_global.dpy)));
+ x11_global.cleanbackbuffer=XCreatePixmap(x11_global.dpy,x11_global.w,MAXWIDTH,MAXHEIGHT,DefaultDepth(x11_global.dpy,DefaultScreen(x11_global.dpy)));
+
+//backbuffer is uninitialized
+ x11_global.backgc=XCreateGC(x11_global.dpy,x11_global.backbuffer,0,0);
+
+ cursor=XCreateFontCursor(x11_global.dpy,XC_crosshair);
+ XDefineCursor(x11_global.dpy, x11_global.w, cursor);
+*/
+ svg_global.green="green";
+ svg_global.red="red";
+ svg_global.blue="blue";
+
+ return -1;//what do we return in svg's case?
+}
+
+void graphics_event_handler(struct shit *me,char *line) {//line should always be empty
+ redraw();
+}
+
+#endif
diff --git a/src/graphics_svg.h b/src/graphics_svg.h
new file mode 100644
index 0000000..3ad1cae
--- /dev/null
+++ b/src/graphics_svg.h
@@ -0,0 +1,15 @@
+#ifndef _HACKVR_GRAPHICS_SVG_H_
+#define _HACKVR_GRAPHICS_SVG_H_
+
+struct svg_global {//stores global variables for the x11 *specific* shit.
+ char backbuffer[1024 * 1024 * 1024];//1 meg should be fine?
+ char *colors[256];
+ char *ansi_color[16];
+ char *foreground_color;
+ char *filename;
+ char *red;
+ char *green;
+ char *blue;
+};
+
+#endif
diff --git a/src/hackvr.c b/src/hackvr.c
index b789dbe..1a72896 100644
--- a/src/hackvr.c
+++ b/src/hackvr.c
@@ -1,4 +1,5 @@
#define _POSIX_C_SOURCE 200809L //for fileno and strdup
+#include <ctype.h> //isspace
#include <stdio.h>
#include <fcntl.h>
#include <assert.h>
@@ -92,21 +93,21 @@ char **line_splitter(char *line,int *rlen) {
char **a;
int len,i=0;
len=1;//we're just counting how much we'll need the first loop through.
- for(i=0;line[i] && line[i] == ' ';i++);//skip leading space
+ for(i=0;line[i] && isspace(line[i]);i++);//skip leading space
for(;line[i];len++) {
- for(;line[i] && line[i] != ' ';i++);//skip rest of data
- for(;line[i] && line[i] == ' ';i++);//skip rest of space
+ for(;line[i] && !isspace(line[i]);i++);//skip rest of data
+ for(;line[i] && isspace(line[i]);i++);//skip rest of space
}
a=malloc(sizeof(char *) * len+1);
a[len]=0;
len=0;//reuse!
- for(i=0;line[i] && line[i] == ' ';i++);//skip leading space
+ for(i=0;line[i] && isspace(line[i]);i++);//skip leading space
a[len]=line+i;
for(;;) {
- for(;line[i] && line[i] != ' ';i++);//skip rest of data
+ for(;line[i] && !isspace(line[i]);i++);//skip rest of data
if(!line[i]) break;
line[i++]=0;
- for(;line[i] && line[i] == ' ';i++);//skip rest of space
+ for(;line[i] && isspace(line[i]);i++);//skip rest of space
if(!line[i]) break;
a[++len]=line+i;
}
@@ -133,6 +134,7 @@ void hvr_version() {
int hackvr_handler(char *line);
void hackvr_handler_idc(struct shit *me,char *line) {
+ //fprintf(stderr,"# got a hackvr line.\n");
switch(hackvr_handler(line)) {
case -1://quit
fprintf(stderr,"# exiting due to EOF\n");
@@ -155,7 +157,7 @@ int hackvr_handler(char *line) {
int len;
int j,i,k,l;
unsigned int key_count;
- c3_group_rel_t *gr;
+ c3_group_rel_t *gr,*pgr;
real tmpx,tmpy,tmpz;
char **a;
char **keys;
@@ -418,7 +420,7 @@ int hackvr_handler(char *line) {
#endif
return ret;
}
- fprintf(stderr,"# %s toggled!\n",a[2]);
+ fprintf(stderr,"# %s toggled.\n",a[2]);
ret=1;
return ret;
}
@@ -446,8 +448,21 @@ int hackvr_handler(char *line) {
/* ---------- */
if(helping) fprintf(stderr,"# subsume child-group\n");
if(!strcmp(command,"subsume")) {
- gr=get_group_relative(a[2]);//we need the child's group relative...
- gr->parent = gr->id;
+ if(strchr(a[2],'*')) {
+ for(i=0;i < global.ht_group.kl;i++) {
+ for(m=global.ht_group.bucket[global.ht_group.keys[i]]->ll;m;m=m->next) {
+ if(!glob_match(id,m->original)) {
+ gr=m->target;
+ pgr=get_group_relative(id);
+ gr->parent = pgr->id;
+ }
+ }
+ }
+ } else {
+ gr=get_group_relative(a[2]);//we need the child's group relative...
+ pgr=get_group_relative(id);
+ gr->parent = pgr->id;
+ }
ret=0;
return ret;
}
@@ -730,9 +745,14 @@ int export_file(FILE *fp) {//not used yet. maybe export in obj optionally? no. t
#ifdef GRAPHICAL
void redraw_handler(struct shit *me,char *line) {//how do we strip out extra redraws?
- if(gra_global.force_redraw) {
+ //fprintf(stderr,"# attempting to redraw\n");
+ if(gra_global.redrawplzkthx) {//this is how multiple calls to redraw() don't cause a flood of draw_screen();
draw_screen();
- gra_global.force_redraw=0;
+ gra_global.redrawplzkthx=0;
+ if(gra_global.force_redraw == 1) {
+ fprintf(stderr,"# warning. force redrawing.\n");
+ redraw();//wew.
+ }
}
}
#endif
diff --git a/src/hackvr_svg.c b/src/hackvr_svg.c
new file mode 120000
index 0000000..e4c9ddd
--- /dev/null
+++ b/src/hackvr_svg.c
@@ -0,0 +1 @@
+hackvr.c \ No newline at end of file
diff --git a/src/hackvr_xdiewii.c b/src/hackvr_xdiewii.c
new file mode 120000
index 0000000..e4c9ddd
--- /dev/null
+++ b/src/hackvr_xdiewii.c
@@ -0,0 +1 @@
+hackvr.c \ No newline at end of file
diff --git a/src/keyboard_die.c b/src/keyboard_die.c
index 5a52879..dd172b9 100644
--- a/src/keyboard_die.c
+++ b/src/keyboard_die.c
@@ -3,11 +3,13 @@
#include <linux/input.h>
#include <fcntl.h>
#include <unistd.h>
+#include <stdlib.h> //getenv()
#include "keyboard.h"
-//#define KBDEV "/dev/input/event0"
-#define KBDEV "/dev/input/by-path/platform-i8042-serio-0-event-kbd"
+//#define KBDEV "/dev/input/by-path/pci-0000:00:02.0-usb-0:2.1:1.0-event-kbd"
+//#define KBDEV "/dev/input/event3"
+#define KBDEV getenv("HVR_KBDEV")
int kbfd = -1;
diff --git a/src/math.c b/src/math.c
index 2221957..0f48dd3 100644
--- a/src/math.c
+++ b/src/math.c
@@ -157,8 +157,7 @@ c3_t c3_multiply(c3_t p,c3_t s) {
// arm pieces will rotate around origin...
// I dunno....
c3_t point_apply_group_relative(c3_t p,c3_group_rel_t *gr) {
- if(!gr) return p;//fuck it. nothing to do..
-
+ if(!gr) { return p; }
return c3_add(point_apply_group_relative(gr->p,get_group_relative(gr->parent)),
rotate_c3_xr(
rotate_c3_yr(
@@ -202,20 +201,6 @@ c3_s_t apply_group_relative(c3_s_t s,c3_group_rel_t *group_rel) {
} else {
if(gr) {
s2.p[i]=point_apply_group_relative(s.p[i],gr);
-
-/*
- s.p[i].x *= gr->s.x;
- s.p[i].y *= gr->s.y;
- s.p[i].z *= gr->s.z;//scaling applied? sure....
- //s2.p[i]=c3_add(gr->p,rotate_c3_yr(s.p[i],gr->p,d2r(gr->r.y)));
- s2.p[i]=c3_add(gr->p,rotate_c3_xr(
- rotate_c3_yr(
- rotate_c3_zr(s.p[i],(c3_t){0,0,0},d2r(gr->r.z)
- ),(c3_t){0,0,0},d2r(gr->r.y)
- ),(c3_t){0,0,0},d2r(gr->r.x)
- )
- );
-*/
} else {
s2.p[i]=s.p[i];
}
diff --git a/src/mouse.h b/src/mouse.h
new file mode 100644
index 0000000..842a190
--- /dev/null
+++ b/src/mouse.h
@@ -0,0 +1,11 @@
+#ifndef _HACKVR_MOUSE_H_
+#define _HACKVR_MOUSE_H_
+
+#define MOUSE_PRIMARY 0
+#define MOUSE_TERTIARY 1
+#define MOUSE_SECONDARY 2
+
+#define MOUSE_SCROLLUP 3
+#define MOUSE_SCROLLDOWN 4
+
+#endif
diff --git a/src/mouse_die.c b/src/mouse_die.c
index 4fddf5f..2258a08 100644
--- a/src/mouse_die.c
+++ b/src/mouse_die.c
@@ -5,6 +5,7 @@
#include <unistd.h>
#include "graphics_c3.h"
+#include "mouse.h"
extern struct hvr_global global;
extern struct gra_global gra_global;
@@ -29,11 +30,29 @@ int mouse_init() {
return mfd;
}
+//buttons are:
+//0 for left click, 1 for right click, 2 is middle-click
+
+//in the hackvr mouse map, right is 2, left is 0 and center is 1?
+#define DIE_MOUSE_LEFT 0
+#define DIE_MOUSE_RIGHT 1
+#define DIE_MOUSE_CENTER 2
+//it doesn't care if you have X11 buttons swapped around ofc.
+char die2map(char d) {//edit this function if you want to change your primary and secondary mouse button.
+ switch(d) {
+ case DIE_MOUSE_RIGHT: return MOUSE_PRIMARY;
+ case DIE_MOUSE_LEFT: return MOUSE_SECONDARY;
+ case DIE_MOUSE_CENTER: return MOUSE_TERTIARY;
+ default: return -1;
+ }
+}
+
int mouse_event_handler() {
struct wtf ie;
int butt;
int l;
- int i;
+ int i;//this is a DIE_MOUSE value
+ unsigned char m;//this is a hackvr mouse map value.
int redrawplzkthx=0;
memset(&ie,0,sizeof(ie));
if(mfd == -1) {
@@ -46,22 +65,24 @@ int mouse_event_handler() {
return 1;
}
if((l=read(mfd,&ie,sizeof(ie))) > 0) {
- //type == 8 and a or of some bits to say which direction.
- //these types are movement: 8 40 56 24
- for(i=0;i<4;i++) {//we need to loop over all buttons each event. :/
- butt=ie.type & 0x07 & (1<<i);
+ for(i=0;i<3;i++) {//we need to loop over all buttons each event. :/
+ butt=ie.type & 0x07 & (1<<i);//lowest 3 bits are possible mouse button states
+ m=die2map(i);
+ if(m == -1) {
+ continue;//not gonna even try.
+ }
if(butt) {//this button is down
fprintf(stderr,"# mouse button %d is down.\n",butt-1);
- if(gra_global.mousemap[butt-1] != 1) {//freshly down. save coords and set it to down.
- gra_global.dragstart[butt-1]=gra_global.mouse;
- gra_global.mousemap[butt-1]=1;
- redrawplzkthx=1;
- }
+ if(gra_global.mousemap[m] != 1) {//freshly down. save coords and set it to down.
+ gra_global.dragstart[m]=gra_global.mouse;
+ gra_global.mousemap[m]=1;
+ redrawplzkthx=1;
+ }
} else {
- if(gra_global.mousemap[(1<<i)-1]) {//only if it was pressed we mark it as "released"
+ if(gra_global.mousemap[m]) {//only if it was pressed we mark it as "released"
fprintf(stderr,"# mouse button %d is being marked as released.\n",(1<<i)-1);
- gra_global.mousemap[(1<<i)-1]=-1;
- if((1<<i)-1 == 1) {//do this for right-click only.
+ gra_global.mousemap[m]=-1;
+ if(m == MOUSE_SECONDARY) {//do this for secondary button release
gra_global.oldcamera = global.camera.r;//we're done dragging, so set this as where the camera points at for next drag around
}
redrawplzkthx=1;
@@ -72,11 +93,15 @@ int mouse_event_handler() {
if(ie.dx || ie.dy) {
fprintf(stderr,"# mouse debug: type:\t%d\tdx:%d\tdy:%d\n",ie.type,ie.dx,ie.dy);
gra_global.mouse.x+=ie.dx;
+ if(gra_global.mouse.x < LEFT) gra_global.mouse.x = LEFT;
+ if(gra_global.mouse.x > RIGHT) gra_global.mouse.x = RIGHT;
gra_global.mouse.y+=ie.dy;
+ if(gra_global.mouse.y < BOTTOM) gra_global.mouse.y = BOTTOM;
+ if(gra_global.mouse.y > TOP) gra_global.mouse.y = TOP;
fprintf(stderr,"# mouse: x:%F y:%F\n",gra_global.mouse.x,gra_global.mouse.y);
- if(gra_global.mousemap[1] == 1) {//if "right" click is held down
- global.camera.r.x.d=gra_global.oldcamera.x.d + (gra_global.mouse.y - gra_global.dragstart[1].y);
- global.camera.r.y.d=gra_global.oldcamera.y.d + (gra_global.mouse.x - gra_global.dragstart[1].x);
+ if(gra_global.mousemap[MOUSE_SECONDARY] == 1) {//if "right" click is held down... this is somehow primary click
+ global.camera.r.x.d=gra_global.oldcamera.x.d + (gra_global.mouse.y - gra_global.dragstart[MOUSE_SECONDARY].y);
+ global.camera.r.y.d=gra_global.oldcamera.y.d + (gra_global.mouse.x - gra_global.dragstart[MOUSE_SECONDARY].x);
}
redrawplzkthx=1;
}
diff --git a/src/mouse_wii.c b/src/mouse_wii.c
new file mode 100644
index 0000000..63020f2
--- /dev/null
+++ b/src/mouse_wii.c
@@ -0,0 +1,145 @@
+#include <stdio.h>
+#include <string.h>
+#include <linux/input.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h> //getenv()
+
+#include "graphics_c3.h"
+#include "mouse.h"
+
+extern struct hvr_global global;
+extern struct gra_global gra_global;
+
+//#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/event19"
+#define MOUSEDEV getenv("HVR_MOUSEDEV")
+int mfd = -1;
+
+//#define "mouse.h" //I guess
+
+struct wtf {//totals to 24
+ struct timeval time;
+ unsigned short type;
+ unsigned short code;
+ unsigned int state;
+};
+
+int mouse_init() {
+ if((mfd=open(MOUSEDEV,O_RDWR)) == -1) {
+ fprintf(stderr,"# failed to open mouse: %d\n",mfd);
+ }
+ return mfd;
+}
+
+//buttons are:
+//0 for left click, 1 for right click, 2 is middle-click
+
+//in the hackvr mouse map, right is 2, left is 0 and center is 1?
+#define DIE_MOUSE_LEFT 0
+#define DIE_MOUSE_RIGHT 1
+#define DIE_MOUSE_CENTER 2
+//it doesn't care if you have X11 buttons swapped around ofc.
+char die2map(char d) {//edit this function if you want to change your primary and secondary mouse button.
+ switch(d) {
+ case DIE_MOUSE_LEFT: return MOUSE_PRIMARY;
+ case DIE_MOUSE_RIGHT: return MOUSE_SECONDARY;
+ case DIE_MOUSE_CENTER: return MOUSE_TERTIARY;
+ default: return -1;
+ }
+}
+
+int mouse_event_handler() {
+ struct wtf ie;
+ //int butt;
+ int l;
+ //int i;//this is a DIE_MOUSE value
+ //unsigned char m;//this is a hackvr mouse map value.
+ int redrawplzkthx=0;
+ memset(&ie,0,sizeof(ie));
+ if(mfd == -1) {
+ mfd=open(MOUSEDEV,O_RDWR);
+ //probably don't need nonblock anymore.
+ //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) {
+ if(ie.code == 3) global.camera.r.x.d=ie.state;
+ if(ie.code == 4) global.camera.r.y.d=ie.state;
+ if(ie.code == 5) global.camera.r.z.d=ie.state;
+ if(ie.code >= 3 && ie.code <= 5) redrawplzkthx=1;
+/*
+ for(i=0;i<3;i++) {//we need to loop over all buttons each event. :/
+ butt=ie.type & 0x07 & (1<<i);//lowest 3 bits are possible mouse button states
+ m=die2map(i);
+ if(m == -1) {
+ continue;//not gonna even try.
+ }
+ if(butt) {//this button is down
+ fprintf(stderr,"# mouse button %d is down.\n",butt-1);
+ if(gra_global.mousemap[m] != 1) {//freshly down. save coords and set it to down.
+ gra_global.dragstart[m]=gra_global.mouse;
+ gra_global.mousemap[m]=1;
+ redrawplzkthx=1;
+ }
+ } else {
+ if(gra_global.mousemap[m]) {//only if it was pressed we mark it as "released"
+ fprintf(stderr,"# mouse button %d is being marked as released.\n",(1<<i)-1);
+ gra_global.mousemap[m]=-1;
+ if(m == MOUSE_SECONDARY) {//do this for secondary button release
+ gra_global.oldcamera = global.camera.r;//we're done dragging, so set this as where the camera points at for next drag around
+ }
+ redrawplzkthx=1;
+ //this is where camera rotation based on dragging is done?
+ }
+ }
+ }
+ if(ie.dx || ie.dy) {
+ fprintf(stderr,"# mouse debug: type:\t%d\tdx:%d\tdy:%d\n",ie.type,ie.dx,ie.dy);
+ gra_global.mouse.x+=ie.dx;
+ if(gra_global.mouse.x < LEFT) gra_global.mouse.x = LEFT;
+ if(gra_global.mouse.x > RIGHT) gra_global.mouse.x = RIGHT;
+ gra_global.mouse.y+=ie.dy;
+ if(gra_global.mouse.y < BOTTOM) gra_global.mouse.y = BOTTOM;
+ if(gra_global.mouse.y > TOP) gra_global.mouse.y = TOP;
+ fprintf(stderr,"# mouse: x:%F y:%F\n",gra_global.mouse.x,gra_global.mouse.y);
+ if(gra_global.mousemap[MOUSE_SECONDARY] == 1) {//if "right" click is held down... this is somehow primary click
+ global.camera.r.x.d=gra_global.oldcamera.x.d + (gra_global.mouse.y - gra_global.dragstart[MOUSE_SECONDARY].y);
+ global.camera.r.y.d=gra_global.oldcamera.y.d + (gra_global.mouse.x - gra_global.dragstart[MOUSE_SECONDARY].x);
+ }
+ redrawplzkthx=1;
+ }
+*/
+ }
+ if(redrawplzkthx) {
+ redraw();
+ return 1;
+ }
+ return 0;
+}
+/*
+#include <stdio.h>
+#include <sys/time.h>
+
+
+int main(int argc,char *argv[]) {
+ int i;
+ struct input_event ie;
+ int x,y,z;
+ while(!feof(stdin)) {
+ read(0,&ie,sizeof(struct input_event));
+ printf("type: %d :: ",ie.type);
+ if(ie.code == 3) x=ie.state;
+ if(ie.code == 4) y=ie.state;
+ if(ie.code == 5) z=ie.state;
+ printf("%15d %15d %15d",x,y,z);
+ //for(i=0;i<16;i++) {
+ // printf(" %02x",(unsigned char)ae.derp[i]);
+ //}
+ printf("\n");
+ }
+}
+*/
diff --git a/src/mouse_x11.c b/src/mouse_x11.c
index 719940e..78926f9 100644
--- a/src/mouse_x11.c
+++ b/src/mouse_x11.c
@@ -4,6 +4,7 @@
#include "graphics_c3.h"
#include "graphics_c2.h"
#include "graphics_x11.h"
+#include "mouse.h"
extern struct hvr_global global;
extern struct gra_global gra_global;
@@ -13,8 +14,27 @@ int mouse_init() {
return x11_global.fd;
}
+#define X11_MOUSE_PRIMARY 1
+#define X11_MOUSE_SECONDARY 3
+#define X11_MOUSE_TERTIARY 2
+#define X11_MOUSE_SCROLLUP 4
+#define X11_MOUSE_SCROLLDOWN 5
+
+char x112map(char x) {
+ switch(x) {
+ case X11_MOUSE_PRIMARY: return MOUSE_PRIMARY;
+ case X11_MOUSE_TERTIARY: return MOUSE_TERTIARY;//middle-click
+ case X11_MOUSE_SECONDARY: return MOUSE_SECONDARY;
+ case X11_MOUSE_SCROLLUP: return MOUSE_SCROLLUP;
+ case X11_MOUSE_SCROLLDOWN: return MOUSE_SCROLLDOWN;
+ default: return -1;
+ }
+ return -1;
+}
+
int mouse_event_handler() {//this returns HVM_ key + for buttondown and - for buttonup... set the mousex and mousey in here?
XEvent e;
+ c3_group_rel_t *gr;
Window root,child;//just dimmies
unsigned int mask;//just dummies
char motion_notify=0;
@@ -26,14 +46,17 @@ int mouse_event_handler() {//this returns HVM_ key + for buttondown and - for bu
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
- butt=e.xbutton.button-1;
- if(butt == 3) {//scroll wheel up
+ if((butt=x112map(e.xbutton.button)) == -1) {
+ continue;//we don't know how to handle this button. :/
+ }
+ fprintf(stderr,"# x11 button: %d is %d in hackvr\n",e.xbutton.button,butt);
+ if(butt == MOUSE_SCROLLUP) {//scroll wheel up
selfcommand("epoch move forward\n");//need to implement this syntax in hackvr
}
- if(butt == 4) {//scroll wheel down
+ if(butt == MOUSE_SCROLLDOWN) {//scroll wheel down
selfcommand("epoch move backward\n");
}
- if(butt == 1) {//middle-click
+ if(butt == MOUSE_TERTIARY) {//middle-click
gra_global.input_mode ^= 1;
printf("# gra_global.input_mode == %d\n",gra_global.input_mode);
}
@@ -43,9 +66,13 @@ int mouse_event_handler() {//this returns HVM_ key + for buttondown and - for bu
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;
+ if((butt=x112map(e.xbutton.button)) == -1) {
+ continue;//we don't know how to handle this button. :/
+ }
+ printf("# button release %d\n",butt);
+ gra_global.mousemap[butt]=-1;//we can trigger on -1 or on 1 then set back to 0 to prevent double-trigger
+ gr=get_group_relative(global.user);
+ gra_global.oldcamera=gr->r;
redrawplzkthx=1;
break;
case MotionNotify:
@@ -68,11 +95,22 @@ int mouse_event_handler() {//this returns HVM_ key + for buttondown and - for bu
//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 - 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.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);
+ //fprintf(stderr,"# mouse.x: %f mouse.y: %f\n# width: %u height: %u\n",gra_glo bal.mouse.x,gra_global.mouse.y,gra_global.width,gra_global.height);
+ //this /was/ using a 2 for the mousemap index... so 2 is "right" in hackvr.
+ if(gra_global.mousemap[MOUSE_SECONDARY] == 1) {//if "right" click is held down
+ gr=get_group_relative(global.user);
+ gr->r.x.d=gra_global.oldcamera.x.d + (gra_global.mouse.y - gra_global.dragstart[MOUSE_SECONDARY].y);
+ gr->r.y.d=gra_global.oldcamera.y.d + (gra_global.mouse.x - gra_global.dragstart[MOUSE_SECONDARY].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);
}
+ /* dunno if I really want to do this.
+ if(gra_global.mousemap[MOUSE_TERTIARY] == 1) {//if we're holding down middle-click
+ //need to move forward or sideways based on
+ gr->r.x = gra_global.oldcmaera.gra_global.dragstart[MOUSE_TERTIARY].x//
+ gr->r.y = //
+ gr->r.z = //
+ }*/
//do we need to redraw on mouse movement?
//probably.
redrawplzkthx=1;