From 7c9c6dcb800fcf4652b7f481a5f0693035e673ef Mon Sep 17 00:00:00 2001 From: epoch Date: Thu, 25 Jun 2020 08:18:22 -0500 Subject: added horizon line back --- src/graphics_c3.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/graphics_c3.c b/src/graphics_c3.c index eb63909..3bcef68 100644 --- a/src/graphics_c3.c +++ b/src/graphics_c3.c @@ -421,9 +421,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++) { -- cgit v1.2.3 From 96148386827f7aa831865dc877a06034679422cc Mon Sep 17 00:00:00 2001 From: epoch Date: Thu, 25 Jun 2020 08:31:00 -0500 Subject: anything isspace() things is space is allowed as whitespace instead of just 0x20 --- src/hackvr.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/hackvr.c b/src/hackvr.c index b789dbe..6dea5b9 100644 --- a/src/hackvr.c +++ b/src/hackvr.c @@ -1,4 +1,5 @@ #define _POSIX_C_SOURCE 200809L //for fileno and strdup +#include //isspace #include #include #include @@ -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; } -- cgit v1.2.3 From f0083dfdcb930b1014bbbd7c98207b7255bcc4c8 Mon Sep 17 00:00:00 2001 From: epoch Date: Sun, 5 Jul 2020 08:17:06 -0500 Subject: added a subsume tester --- share/hackvr/examples/subsume/arms.hackvr | 7 +++++++ share/hackvr/examples/subsume/test.sh | 11 +++++++++++ 2 files changed, 18 insertions(+) create mode 100644 share/hackvr/examples/subsume/arms.hackvr create mode 100755 share/hackvr/examples/subsume/test.sh diff --git a/share/hackvr/examples/subsume/arms.hackvr b/share/hackvr/examples/subsume/arms.hackvr new file mode 100644 index 0000000..de31aba --- /dev/null +++ b/share/hackvr/examples/subsume/arms.hackvr @@ -0,0 +1,7 @@ +base addshape 1 2 0 0 0 0 8 0 +mid addshape 2 2 0 0 0 0 4 0 +mid move 0 8 0 +base subsume mid +end addshape 4 2 0 0 0 0 2 0 +end move 0 4 0 +mid subsume end diff --git a/share/hackvr/examples/subsume/test.sh b/share/hackvr/examples/subsume/test.sh new file mode 100755 index 0000000..67139ac --- /dev/null +++ b/share/hackvr/examples/subsume/test.sh @@ -0,0 +1,11 @@ +#!/bin/bash +cat arms.hackvr + +# these start all straight-up, rotate counter clockwise as rotation increases, and +# at these rates of rotation they should all be curled in on themselves at the bottom. +while true;do + printf "base rotate 0 0 +1\n" + printf "mid rotate 0 0 +2\n" + printf "end rotate 0 0 +3\n" + sleep .1 +done -- cgit v1.2.3 From d9708580e6679a9b9924856b59b0133d15fda2c2 Mon Sep 17 00:00:00 2001 From: epoch Date: Sun, 5 Jul 2020 08:18:09 -0500 Subject: subsume got multiple group globbing and actually works again --- src/hackvr.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/hackvr.c b/src/hackvr.c index 6dea5b9..775564a 100644 --- a/src/hackvr.c +++ b/src/hackvr.c @@ -156,7 +156,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; @@ -447,8 +447,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; } -- cgit v1.2.3 From 961144c7350ef1720316192486f6626a41322098 Mon Sep 17 00:00:00 2001 From: epoch Date: Mon, 13 Jul 2020 02:29:28 -0500 Subject: added another example that makes a marquee out a text file that contains one line and will periodically change. --- share/hackvr/examples/marquee/marquee.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 share/hackvr/examples/marquee/marquee.sh diff --git a/share/hackvr/examples/marquee/marquee.sh b/share/hackvr/examples/marquee/marquee.sh new file mode 100755 index 0000000..4ea6c61 --- /dev/null +++ b/share/hackvr/examples/marquee/marquee.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -o pipefail + +pi=3 #lol + +from_cam=150 + +elevation=10 +while printf "marquee rotate 0 +-2 0\n";do + sleep .1 +done & + +tail -F ~/.local/var/cache/music/nowplaying.txt 2>/dev/null | while read -r line;do + printf "%s deleteallexcept %s\n" "$USER" "$USER" + printf "nowplaying flatten\n" + printf "%s\n" "$line" >&2 + chars="$(printf "%s" "$line" | wc -c | tr -cd '[0-9]')" + char_width=5 #I think.. + rot=$[ 360 / $chars ] + diameter=$[ $chars * $char_width / $pi ] + printf "%s\n" "$line" | fold -w1 | while read -r char;do + printf "%s\n" "$char" | makelabel.sh nowplaying 0 0 0 | offsetshape.sh 0 0 "-${diameter}" + printf "nowplaying rotate 0 %d 0\n" "-$rot" + printf "nowplaying flatten\n" + done + printf "marquee assimilate nowplaying\n" + printf "marquee move 0 %s %s\n" "$elevation" "$[$diameter + $from_cam]" #this won't work before the generation loop unless I can flatten on certain parts. +done -- cgit v1.2.3 From d00cf5f8fdd18a5ef0dfbfa8a24db360d4c16029 Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 03:41:27 -0500 Subject: hackvr_svg? what kind of madness is this? --- src/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 398aaa8..3588d10 100644 --- a/src/Makefile +++ b/src/Makefile @@ -17,7 +17,7 @@ CFLAGS+=-DGRAPHICAL 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_fb hackvr_freeglut slowcat hackvr_xdie: override LDLIBS+=-lm -lidc -lX11 -lhashtable @@ -32,6 +32,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 @@ -46,6 +49,7 @@ hackvr_freeglut: hackvr_freeglut.o graphics_c3_freeglut.o math.o physics.o keybo hackvr_fb.o: CFLAGS+='-DHVR_VERSION="framebuffer"' hackvr_x11.o: CFLAGS+='-DHVR_VERSION="x11"' hackvr_xdie.o: CFLAGS+='-DHVR_VERSION="x11+die"' +hackvr_svg.o: CFLAGS+='-DHVR_VERSION="svg"' hackvr_headless.o: CFLAGS=$(BASE_CFLAGS) hackvr_headless.o: CFLAGS+='-DHVR_VERSION="headless"' @@ -57,6 +61,7 @@ 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_freeglut uninstall: -- cgit v1.2.3 From d1347508d7080980eb1a4974ab91d98bb08c39b1 Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 03:44:02 -0500 Subject: removed some commented out code and put braces around an if's body --- src/math.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) 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]; } -- cgit v1.2.3 From 9ff0ebb74c03433bac557d693b4684c01dc20e45 Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 03:54:35 -0500 Subject: changed to using redrawplzkthx instead of force_redraw to request a redraw. force_redraw will now request /another/ directly after a previous draw so it does what it is named now. --- src/hackvr.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/hackvr.c b/src/hackvr.c index 775564a..8abc0d6 100644 --- a/src/hackvr.c +++ b/src/hackvr.c @@ -134,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"); @@ -419,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; } @@ -744,9 +745,13 @@ 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) { + redraw();//wew. + } } } #endif -- cgit v1.2.3 From e905fdddfe654616417f0ae6ba05f3bbc7dd704d Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 03:55:24 -0500 Subject: added redrawplzkthx to gra_global struct to get force_redraw back to doing what it should have been doing --- src/graphics_c3.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3 From a62c1dde4cc417bec166ee032bb39d1be63d7e7d Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 03:58:33 -0500 Subject: removed the rotation from map2globe. you can use a second script to do rotation. --- bin/map2globe.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bin/map2globe.py b/bin/map2globe.py index cb49675..1a50ea5 100755 --- a/bin/map2globe.py +++ b/bin/map2globe.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3.6 +#!/usr/bin/python3 import sys import math @@ -49,9 +49,6 @@ while(1): break if(lat and lon and x and y and z and plat and plon and px and py and pz): #if the previouses exist print("{} addshape 2 2 {} {} {} {} {} {}".format(name,x,y,z,px,py,pz)) - print("{} rotate 0 {} 0".format(name,str(rotation))) - rotation+=1 - rotation%=360 #set previouses to currents (plat,plon,px,py,pz)=(lat,lon,x,y,z) -- cgit v1.2.3 From 76c2983c0d1ce48321310ebb60b1c81f4dcbbf44 Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 03:59:35 -0500 Subject: added a header for what the different mouse buttons are for hackvr --- src/mouse.h | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/mouse.h 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 -- cgit v1.2.3 From 086db581230d0f795f92dbaef637cd19d8538da9 Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 04:00:45 -0500 Subject: switched to using named constants instead of magic values. right now to configure mouse buttons you need to edit these files. --- src/mouse_die.c | 57 +++++++++++++++++++++++++++++++++++++++++---------------- src/mouse_x11.c | 50 +++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 80 insertions(+), 27 deletions(-) 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 #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< 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_x11.c b/src/mouse_x11.c index 719940e..8218c98 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 2 +#define X11_MOUSE_TERTIARY 3 +#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,10 @@ 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; + 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,10 +92,14 @@ 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[2].y); + gr->r.y.d=gra_global.oldcamera.y.d + (gra_global.mouse.x - gra_global.dragstart[2].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); } //do we need to redraw on mouse movement? //probably. -- cgit v1.2.3 From 7bb1723876d365b8574f1c281134f0f46aea83fe Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 04:01:24 -0500 Subject: this header got 4 constants moved into it that it should have gotten a long time ago. TOP, BOTTOM, RIGHT, LEFT --- src/graphics_c2.h | 5 +++++ 1 file changed, 5 insertions(+) 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); -- cgit v1.2.3 From cd5328c93dc0e8df95d94fcee48dd085c5d31738 Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 04:01:59 -0500 Subject: removed a comment I don't care for anymore. --- src/graphics_cs.h | 3 --- 1 file changed, 3 deletions(-) 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 -//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); -- cgit v1.2.3 From eaa6a8a1c7d124cc8ffd4206b81ad22f68e3da3f Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 04:03:01 -0500 Subject: my keyboard device node changed names. meh --- src/keyboard_die.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/keyboard_die.c b/src/keyboard_die.c index 5a52879..46eb1fa 100644 --- a/src/keyboard_die.c +++ b/src/keyboard_die.c @@ -6,8 +6,7 @@ #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" int kbfd = -1; -- cgit v1.2.3 From 21b9145bf0c8bfa25da1c362aea70e838cf2db1c Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 04:04:34 -0500 Subject: moved 4 defines out to graphics_c2.h. switched to using named constants for mouse stuff. renamed redraw vars to make more sense. --- src/graphics_c3.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/graphics_c3.c b/src/graphics_c3.c index 3bcef68..f5dbdbe 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; } @@ -462,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) { @@ -519,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); } } -- cgit v1.2.3 From 1cdf08dd44261f8972c066a18f00cb3166ca215a Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 04:05:03 -0500 Subject: experimental svg output --- src/hackvr_svg.c | 1 + 1 file changed, 1 insertion(+) create mode 120000 src/hackvr_svg.c 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 -- cgit v1.2.3 From 07e163349f9251a5e9c10aba6e080c73da0481f3 Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 04:05:11 -0500 Subject: experimental svg output --- src/graphics_cs_svg.c | 270 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100644 src/graphics_cs_svg.c 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 +#include +#include +#include +#include +#include +#include +//#include //code to use select instead of non-blocking is commented out. might decide to use it later. +#include +#include +#include +#include //for size hints +#include + +#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,"\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,"\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,"\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,"\n"); + strcpy(svg_global.backbuffer,"\n"); + strcat(svg_global.backbuffer,"\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,"\n\n"); + strcat(svg_global.backbuffer,"\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 -- cgit v1.2.3 From 0e60854be6ca99e7db9f2dfc49e4fe329da92628 Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 04:05:20 -0500 Subject: experimental svg output --- src/graphics_svg.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/graphics_svg.h 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 -- cgit v1.2.3 From d83b9196d88dcc934d47f4609310a9840390fa9b Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 04:05:48 -0500 Subject: added hackvr_svg to .gitignore list --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7b6a851..eeced2c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,6 @@ src/hackvr_headless src/hackvr_x11 src/hackvr_xdie src/hackvr_opengl +src/hackvr_svg src/slowcat src/nonblocktail -- cgit v1.2.3 From b93aaf12a23d64afa92e77f59d084c019327f645 Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 04:27:34 -0500 Subject: got the secondary and tertiary buttons swapped around. oops. --- src/mouse_x11.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mouse_x11.c b/src/mouse_x11.c index 8218c98..623dd68 100644 --- a/src/mouse_x11.c +++ b/src/mouse_x11.c @@ -15,8 +15,8 @@ int mouse_init() { } #define X11_MOUSE_PRIMARY 1 -#define X11_MOUSE_SECONDARY 2 -#define X11_MOUSE_TERTIARY 3 +#define X11_MOUSE_SECONDARY 3 +#define X11_MOUSE_TERTIARY 2 #define X11_MOUSE_SCROLLUP 4 #define X11_MOUSE_SCROLLDOWN 5 @@ -47,7 +47,7 @@ int mouse_event_handler() {//this returns HVM_ key + for buttondown and - for bu 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((butt=x112map(e.xbutton.button)) == -1) { - continue;//we don't know how to handle this button. :/ + 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 @@ -66,6 +66,9 @@ int mouse_event_handler() {//this returns HVM_ key + for buttondown and - for bu redrawplzkthx=1; break; case ButtonRelease: + 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); -- cgit v1.2.3 From 96d65fff7bcf9552edef844cba723384f0051746 Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 05:45:46 -0500 Subject: default build error messages less often --- src/hackvr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hackvr.c b/src/hackvr.c index 8abc0d6..1a72896 100644 --- a/src/hackvr.c +++ b/src/hackvr.c @@ -745,11 +745,12 @@ 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? - fprintf(stderr,"# attempting to redraw\n"); + //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.redrawplzkthx=0; if(gra_global.force_redraw == 1) { + fprintf(stderr,"# warning. force redrawing.\n"); redraw();//wew. } } -- cgit v1.2.3 From 3f85bff904cfeccd704b014fee8a4ee33982fdd7 Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 17 Jul 2020 05:45:57 -0500 Subject: default build error messages less often --- src/graphics_c3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphics_c3.c b/src/graphics_c3.c index f5dbdbe..72a03e3 100644 --- a/src/graphics_c3.c +++ b/src/graphics_c3.c @@ -516,7 +516,7 @@ void draw_screen() { void redraw() {//something is requesting a redraw. if(gra_global.redrawplzkthx == 0) { gra_global.redrawplzkthx=1;//this is to prevent drawing way too often. - fprintf(stderr,"# in the redraw() function\n"); + //fprintf(stderr,"# in the redraw() function\n"); write(gra_global.redraw[1],"redrawplzkthx!\n",15); } } -- cgit v1.2.3 From 2a5c038b9ffc03fe49f0c29585ec333df7ff8907 Mon Sep 17 00:00:00 2001 From: epoch Date: Sun, 16 Aug 2020 16:44:48 -0500 Subject: used a defined constant instead of a magic constant. also put an idea in a comment for middle-drag to move camera instead of just rotate. dunno --- src/mouse_x11.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mouse_x11.c b/src/mouse_x11.c index 623dd68..78926f9 100644 --- a/src/mouse_x11.c +++ b/src/mouse_x11.c @@ -99,11 +99,18 @@ int mouse_event_handler() {//this returns HVM_ key + for buttondown and - for bu //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[2].y); - gr->r.y.d=gra_global.oldcamera.y.d + (gra_global.mouse.x - gra_global.dragstart[2].x); + 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; -- cgit v1.2.3 From eb7f8f14bfbf8a6a43613db9802d17d1ea6591a3 Mon Sep 17 00:00:00 2001 From: epoch Date: Tue, 1 Sep 2020 07:27:41 -0500 Subject: README now has info about each binary that gets dropped into src/ after a make --- README | 68 ++++++++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/README b/README index a3a4ff3..36ff84b 100644 --- a/README +++ b/README @@ -8,11 +8,14 @@ hackvr... um. outputs commands to stdout based on keys pressed inside hackvr, and inputs the same type of commands. so do some plumbing and get a multiplayer game going? -I'm working on making hackvr work with different output and input types. Right now the only one -that works with everything is hackvr_x11. There's also a hackvr_fb that uses the linux framebuffer, -but it doesn't have mouse support and keyboard support is wonky due to me not thinging it through. +How about a nice GL version written in zig made by someone else? +https://git.random-projects.net/xq/hackvr-turbo -quick start: +I'm telling you. It looks a lot nicer than my stuff. + +:::::::::::::::::::: +::: DEPENDENCIES ::: +:::::::::::::::::::: You'll need to have the library and headers of libx11 installed for hackvr to build successfully. Which usually means you will need the dev version of the libx11 (xlib) package for your distro. @@ -24,8 +27,6 @@ If you want to build the GLut crap you'll need freeglut3-dev -Although I haven't touched the non-x11 versions in a long time. Good luck. - Since I first wrote this README, I pushed a couple other libraries I've written into hackvr. You'll need those too. @@ -49,18 +50,51 @@ git://thebackupbox.net/libhashtable git://main.lv/libhashtable https://github.com/kkabrams/libhashtable + +:::::::::::::::: +::: BUILDING ::: +:::::::::::::::: + I have a script that just runs make with PREFIX=$PREFIX prefix=$PREFIX so I end up with everything installed under ~/.local/ - -After you have that installed you should be able to do these to get hackvr built: +You should be able to do these to get hackvr built: make #BSD make doesn't do target specific variables. use GNUMake. + +The make install will create the following programs: + +:: hackvr_headless :: +This doesn't output to any display, but you can still read commands in, do manipulations +then export them back out. This can make writing a few scripts for hackvr easier +and it can also compress any long list of hackvr commands. + +:: hackvr_x11 :: +This is the binary I use most on my desktop. It outputs to a single X11 window, +and gets its input events from that same X11 window. + +:: hackvr_fb :: +This outputs to the /dev/fb0 device so you can run hackvr without an X11 server if you want. +It uses /dev/input/events for user input. + +:: hackvr_xdie :: +This is a mix of the last two programs. It outputs to an X11 window, but uses +/dev/input/events for user input. + +:: hackvr_svg :: +This uses /dev/input/events for user input, and each screen-draw it overwrites an HTML file +in /tmp that contains an inline SVG with an autorefresh. I think this program was meant +as a joke to myself. Still kind of funny. + +::::::::::::::: +::: INSTALL ::: +::::::::::::::: + +The way I install updated hackvr binaries is this way: + export PREFIX=$(HOME)/.local #the Makefiles are short, worth a read. make install -The make install will create hackvr_headless, hackvr_x11, hackvr_fb. - If you didn't want to make install the libraries, there are variables you can set to let the makefile know where they are: @@ -76,17 +110,11 @@ A few helper scripts are written in perl and python. So you might want to install perl and python if you want to play with them. They're pretty nifty. -what hackvr can do... - -I dunno. - -try cd tictactoe ; ./run -or... fiddle with the scripts laying around? -_ _ - \O_o/ - +::::::::::::::::::: +::: Stereoscopy ::: +::::::::::::::::::: -Red and Blue mode +Right now there's side-by-side mode and red-and-blue mode. You'll have to either enable this using a command sent to hackvr's stdin that I don't even remember, or just enable it in config.h make clean then rebuild. -- cgit v1.2.3 From f0cf51e49512195ad4372d8c117a60179e2873d7 Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 9 Oct 2020 18:35:57 -0500 Subject: forgot the wiimote files --- src/hackvr_xdiewii.c | 1 + src/mouse_wii.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 120000 src/hackvr_xdiewii.c create mode 100644 src/mouse_wii.c 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/mouse_wii.c b/src/mouse_wii.c new file mode 100644 index 0000000..863e4e2 --- /dev/null +++ b/src/mouse_wii.c @@ -0,0 +1,143 @@ +#include +#include +#include +#include +#include + +#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" + +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; +/* + for(i=0;i<3;i++) {//we need to loop over all buttons each event. :/ + butt=ie.type & 0x07 & (1< 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 +#include + + +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"); + } +} +*/ -- cgit v1.2.3 From c27f40e7f2d20b0a576ece53e9bdeacc7b40da9e Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 9 Oct 2020 18:47:59 -0500 Subject: make was not working on my laptop. adding override to a bunch of lines made it work. bugs may ensue. --- src/Makefile | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/Makefile b/src/Makefile index 3588d10..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_svg 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 @@ -46,12 +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_svg.o: CFLAGS+='-DHVR_VERSION="svg"' -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 @@ -62,6 +66,7 @@ install: all 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: -- cgit v1.2.3 From d9f7be90abb4191db97a385cb004fc4a23f92f46 Mon Sep 17 00:00:00 2001 From: epoch Date: Fri, 9 Oct 2020 23:44:17 -0500 Subject: mouse_wii was not refreshing on change. keyboard and mouse event devices can now be set using getenv instead of editing source code --- src/keyboard_die.c | 5 ++++- src/mouse_wii.c | 12 +++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/keyboard_die.c b/src/keyboard_die.c index 46eb1fa..dd172b9 100644 --- a/src/keyboard_die.c +++ b/src/keyboard_die.c @@ -3,10 +3,13 @@ #include #include #include +#include //getenv() #include "keyboard.h" -#define KBDEV "/dev/input/by-path/pci-0000:00:02.0-usb-0:2.1:1.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/mouse_wii.c b/src/mouse_wii.c index 863e4e2..63020f2 100644 --- a/src/mouse_wii.c +++ b/src/mouse_wii.c @@ -3,6 +3,7 @@ #include #include #include +#include //getenv() #include "graphics_c3.h" #include "mouse.h" @@ -11,8 +12,8 @@ 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 "/dev/input/event19" +#define MOUSEDEV getenv("HVR_MOUSEDEV") int mfd = -1; //#define "mouse.h" //I guess @@ -50,10 +51,10 @@ char die2map(char d) {//edit this function if you want to change your primary an int mouse_event_handler() { struct wtf ie; - int butt; + //int butt; int l; - int i;//this is a DIE_MOUSE value - unsigned char m;//this is a hackvr mouse map value. + //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) { @@ -69,6 +70,7 @@ int mouse_event_handler() { 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< Date: Fri, 9 Oct 2020 23:44:54 -0500 Subject: added gitxdiewii to ignore list --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index eeced2c..5c4941d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,6 @@ src/hackvr_x11 src/hackvr_xdie src/hackvr_opengl src/hackvr_svg +src/hackvr_xdiewii src/slowcat src/nonblocktail -- cgit v1.2.3