From 2eea5bc2684c84aeaeba4a1f374ab96eb74b7885 Mon Sep 17 00:00:00 2001 From: epoch Date: Mon, 6 Apr 2020 05:55:20 -0500 Subject: fixed hackvr_term's pty.c so I don't have to use python for getting a pty. --- share/hackvr/examples/hackvr_term/pty.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/share/hackvr/examples/hackvr_term/pty.c b/share/hackvr/examples/hackvr_term/pty.c index 1011e38..d894359 100644 --- a/share/hackvr/examples/hackvr_term/pty.c +++ b/share/hackvr/examples/hackvr_term/pty.c @@ -1,12 +1,17 @@ +#define _XOPEN_SOURCE 500 //ptsname +#define _XOPEN_SOURCE_EXTENDED #include #include #include +#include +#include int main(int argc,char *argv[]) { char *pts; - char in[256];//I dunno. + char in;//I dunno. int r; int pid; + int eof1,eof2; int master,slave; master=open("/dev/ptmx",O_RDWR); if(master == -1) return 1; @@ -42,20 +47,22 @@ int main(int argc,char *argv[]) { default: break; } - for(;;) { + eof1=0; + eof2=0; + for(;!(eof1 || eof2);) { if(waitpid(-1,0,WNOHANG) > 0) { return 0;//fuck if I know. //we got a dead child. let's bail. } switch(r=read(0,&in,1)) { - case 0: return 6;//EOF + case 0: eof1=1;;//EOF case -1: break;//EAGAIN probably. - default: write(master,in,r); + default: write(master,&in,r); } switch(r=read(master,&in,1)) { - case 0: return 7;//EOF + case 0: eof2=1;;//EOF case -1: break;//EAGAIN probably - default: write(1,in,r); + default: write(1,&in,r); } usleep(100);//kek } -- cgit v1.2.3 From cfa28d6442dbb4b8037b5538f7bbd95604c261de Mon Sep 17 00:00:00 2001 From: epoch Date: Mon, 6 Apr 2020 05:59:47 -0500 Subject: lol. the order of the arguments has been backwards the whole time --- share/hackvr/examples/hackvr_term/hackvr_term.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/hackvr/examples/hackvr_term/hackvr_term.c b/share/hackvr/examples/hackvr_term/hackvr_term.c index 71f2492..40df2d1 100644 --- a/share/hackvr/examples/hackvr_term/hackvr_term.c +++ b/share/hackvr/examples/hackvr_term/hackvr_term.c @@ -151,7 +151,7 @@ void callback(tmt_msg_t m,TMT *vt, const void *a,void *vt_old) { int main(int argc,char *argv[]) { char in[16]; - if(argc < 3) return fprintf(stderr,"usage: ./hackvr_term rows cols\n"),1; + if(argc < 3) return fprintf(stderr,"usage: ./hackvr_term cols rows\n"),1; int r=atoi(argv[2]); int ret=0; int c=atoi(argv[1]); -- cgit v1.2.3 From 48fe341421279208e090f9d25794aa59a02de8ec Mon Sep 17 00:00:00 2001 From: epoch Date: Mon, 6 Apr 2020 06:03:32 -0500 Subject: added better error checking to not just assume EAGAIN --- share/hackvr/examples/hackvr_term/pty.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/share/hackvr/examples/hackvr_term/pty.c b/share/hackvr/examples/hackvr_term/pty.c index d894359..6903bc3 100644 --- a/share/hackvr/examples/hackvr_term/pty.c +++ b/share/hackvr/examples/hackvr_term/pty.c @@ -5,6 +5,7 @@ #include #include #include +#include int main(int argc,char *argv[]) { char *pts; @@ -56,12 +57,12 @@ int main(int argc,char *argv[]) { } switch(r=read(0,&in,1)) { case 0: eof1=1;;//EOF - case -1: break;//EAGAIN probably. + case -1: if(errno != EAGAIN) eof1=1; break;//EAGAIN probably. default: write(master,&in,r); } switch(r=read(master,&in,1)) { case 0: eof2=1;;//EOF - case -1: break;//EAGAIN probably + case -1: if(errno != EAGAIN) eof2=1; break;//EAGAIN probably default: write(1,&in,r); } usleep(100);//kek -- cgit v1.2.3 From 2edcce43083ec0437521b294eee545227fb77e59 Mon Sep 17 00:00:00 2001 From: epoch Date: Mon, 6 Apr 2020 06:03:57 -0500 Subject: added a new script to try to just get a single line of test from the user --- share/hackvr/examples/hackvr_term/read_line.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 share/hackvr/examples/hackvr_term/read_line.sh diff --git a/share/hackvr/examples/hackvr_term/read_line.sh b/share/hackvr/examples/hackvr_term/read_line.sh new file mode 100755 index 0000000..c26ebf3 --- /dev/null +++ b/share/hackvr/examples/hackvr_term/read_line.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +./hackvr_data_decode.sh \ + | ./pty `which bash` "-c" 'read -p "type> " line;xmessage $line' \ + | ./hackvr_term 60 2 \ + | sed -u 's/addshape 15 4/addshape 12 4/g' -- cgit v1.2.3 From f43bc654684239198fc793df536319bd73a38d7f Mon Sep 17 00:00:00 2001 From: epoch Date: Mon, 6 Apr 2020 06:04:22 -0500 Subject: added an exec --- share/hackvr/examples/hackvr_term/hackvr_data_decode.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/hackvr/examples/hackvr_term/hackvr_data_decode.sh b/share/hackvr/examples/hackvr_term/hackvr_data_decode.sh index 0ac04f2..307b6ff 100755 --- a/share/hackvr/examples/hackvr_term/hackvr_data_decode.sh +++ b/share/hackvr/examples/hackvr_term/hackvr_data_decode.sh @@ -1,2 +1,2 @@ #!/bin/sh -grep --line-buffered '^[^ ]* data ' | stdbuf -oL tr -s ' ' | stdbuf -oL cut '-d ' -f3- | stdbuf -o0 xxd -r -p +exec grep --line-buffered '^[^ ]* data ' | stdbuf -oL tr -s ' ' | stdbuf -oL cut '-d ' -f3- | stdbuf -o0 xxd -r -p -- cgit v1.2.3 From dd3012cf26dff1493934afec4937e668e617750e Mon Sep 17 00:00:00 2001 From: epoch Date: Tue, 7 Apr 2020 02:43:32 -0500 Subject: fixed export, glob_match, and y-axis-only movement. --- src/hackvr.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/hackvr.c b/src/hackvr.c index cc40ed8..9ffcaf7 100644 --- a/src/hackvr.c +++ b/src/hackvr.c @@ -118,6 +118,7 @@ char **line_splitter(char *line,int *rlen) { //this function may be changed to allow globs in different spots later. int glob_match(char *a,char *b) { if(strchr(a,'*')) { + if(*a == '*') return strcmp("yep","yep");//lol return strncmp(a,b,strchr(a,'*')-a-1);//hack? sure. } return strcmp(a,b); @@ -429,18 +430,18 @@ int hackvr_handler(char *line) { if(!strcmp(command,"export")) {//dump shapes and group rotation for argument (or all if arg is *) if(len > 2) { for(i=0;global.shape[i];i++) { -// if(!glob_match(a[2],global.shape[i]->id)) { + if(!glob_match(a[2],global.shape[i]->id)) { printf("%s_%s addshape %d %d",id,global.shape[i]->id,global.shape[i]->attrib.col,global.shape[i]->len); for(j=0;j < global.shape[i]->len+(global.shape[i]->len==1);j++) { printf(" %f %f %f",global.shape[i]->p[j].x,global.shape[i]->p[j].y,global.shape[i]->p[j].z); }//possible TODO: should I combine the string and output it all at once instead of throughout a loop? printf("\n"); -// } + } } for(i=0;global.group_rot[i];i++) { if(!glob_match(a[2],global.group_rot[i]->id)) { -/* printf("%s_%s rotate %d %d %d\n",id,a[2],global.group_rot[i]->r.x.d,global.group_rot[i]->r.y.d,global.group_rot[i]->r.z.d); - printf("%s_%s move %f %f %f\n",id,a[2],global.group_rot[i]->p.x,global.group_rot[i]->p.y,global.group_rot[i]->p.z);*/ + printf("%s_%s rotate %d %d %d\n",id,global.group_rot[i]->id,global.group_rot[i]->r.x.d,global.group_rot[i]->r.y.d,global.group_rot[i]->r.z.d); + printf("%s_%s move %f %f %f\n",id,global.group_rot[i]->id,global.group_rot[i]->p.x,global.group_rot[i]->p.y,global.group_rot[i]->p.z); } } } @@ -456,6 +457,7 @@ int hackvr_handler(char *line) { } //should scaleup even be inside hackvr? seems like something an external program could do... but it wouldn't act on hackvr's state. so nevermind. if(!strcmp(command,"scale")) {//this doesn't just scale *up*, it can scale down too. also, make the group relative stuff keep scale factors. we can flatten if we want later. + //scale seems like something a group relative would hold. for(i=0;global.shape[i];i++) { if(!glob_match(id,global.shape[i]->id)) { //we're allowing globbing in this command I guess. for(j=0;j < global.shape[i]->len+(global.shape[i]->len==1);j++) { @@ -577,10 +579,10 @@ int hackvr_handler(char *line) { tmprady=d2r((degrees){global.camera.r.y.d+180}); //snprintf(tmp,sizeof(tmp)-1,"%s move +%f +0 +%f\n",global.user,tmpx,tmpz); } else if(!strcmp(a[2],"up")) { - tmprady=d2r((degrees){global.camera.r.y.d});//doesn't matter. + tmprady=(radians){0};//d2r((degrees){global.camera.r.y.d});//this was being used to move in the x,z plane. oops. tmpy=WALK_SPEED*1; } else if(!strcmp(a[2],"down")) { - tmprady=d2r((degrees){global.camera.r.y.d});//doesn't matter. yet. + tmprady=(radians){0};//d2r((degrees){global.camera.r.y.d});//doesn't matter. yet. tmpy=-WALK_SPEED*1; } else if(!strcmp(a[2],"left")) { tmprady=d2r((degrees){global.camera.r.y.d+270}); @@ -592,8 +594,13 @@ int hackvr_handler(char *line) { fprintf(stderr,"# dunno what direction you're talking about. try up, down, left, right, forward, or backward\n"); return ret; } - tmpx=WALK_SPEED*sin(tmprady.r);//the camera's y rotation. - tmpz=WALK_SPEED*cos(tmprady.r);//these are only based on + if(!tmpy) {//if we're moving up or down we don't need to calculate this shit. + tmpx=WALK_SPEED*sin(tmprady.r);//the camera's y rotation. + tmpz=WALK_SPEED*cos(tmprady.r);//these are only based on + } else { + tmpx=0; + tmpz=0; + } snprintf(tmp,sizeof(tmp)-1,"%s move +%f +%f +%f\n",global.user,tmpx,tmpy,tmpz); selfcommand(tmp); } else { -- cgit v1.2.3 From 35b84411ef9e69ab01bf0de789cce296d302110e Mon Sep 17 00:00:00 2001 From: epoch Date: Tue, 7 Apr 2020 03:17:13 -0500 Subject: added a hackvr file to test exporting --- tests/export_test.hackvr | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 tests/export_test.hackvr diff --git a/tests/export_test.hackvr b/tests/export_test.hackvr new file mode 100755 index 0000000..8484bb9 --- /dev/null +++ b/tests/export_test.hackvr @@ -0,0 +1,7 @@ +a addshape 4 2 0 0 0 1 1 1 +b addshape 4 2 1 1 1 2 1 1 +a move 3 4 5 +b move 5 6 7 +b move +6 +9 +8 +a move +4 +2 +9 +user export * -- cgit v1.2.3 From 1cca9c35f1837ba0eb324593cdb8d5778fa9b7e3 Mon Sep 17 00:00:00 2001 From: epoch Date: Tue, 7 Apr 2020 06:51:48 -0500 Subject: moved hackvr_coproc into main bin dir. added example uristart.conf file for hackvr URIs. fixed calvr makefile to not do hackvr_coproc --- bin/hackvr_coproc | 2 ++ share/hackvr/examples/calendar/Makefile | 3 +-- share/hackvr/examples/calendar/hackvr_coproc | 2 -- share/hackvr/examples/uristart.conf | 2 ++ 4 files changed, 5 insertions(+), 4 deletions(-) create mode 100755 bin/hackvr_coproc delete mode 100755 share/hackvr/examples/calendar/hackvr_coproc create mode 100644 share/hackvr/examples/uristart.conf diff --git a/bin/hackvr_coproc b/bin/hackvr_coproc new file mode 100755 index 0000000..d79de92 --- /dev/null +++ b/bin/hackvr_coproc @@ -0,0 +1,2 @@ +#!/bin/sh +exec socat "exec:hackvr_uri" "exec:$*" diff --git a/share/hackvr/examples/calendar/Makefile b/share/hackvr/examples/calendar/Makefile index 2027b18..1646279 100644 --- a/share/hackvr/examples/calendar/Makefile +++ b/share/hackvr/examples/calendar/Makefile @@ -1,8 +1,7 @@ PREFIX:=/usr/local -all: calvr hackvr_coproc +all: calvr @echo using PREFIX: $(PREFIX) install: install -t $(PREFIX)/bin calvr - install -t $(PREFIX)/bin hackvr_coproc diff --git a/share/hackvr/examples/calendar/hackvr_coproc b/share/hackvr/examples/calendar/hackvr_coproc deleted file mode 100755 index 8d2e127..0000000 --- a/share/hackvr/examples/calendar/hackvr_coproc +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec socat exec:hackvr "exec:$*" diff --git a/share/hackvr/examples/uristart.conf b/share/hackvr/examples/uristart.conf new file mode 100644 index 0000000..d48e8d1 --- /dev/null +++ b/share/hackvr/examples/uristart.conf @@ -0,0 +1,2 @@ +hackvr: if [ "%u" ];then USER="%u";fi;ncat '%d' '%P' -c "echo $USER action %p;hackvr_uri" +hackvr+ssh: if [ '%u' ];then u='%u@';fi ; if [ "%P" ];then P='-p %P';fi; hackvr_coproc ssh "$u"'%d' $P "/var/hackvr/hackvr-subsystem" '%p' -- cgit v1.2.3 From 7ffc20e9ae8297ea8b6f796310cf065d4186aa5b Mon Sep 17 00:00:00 2001 From: epoch Date: Tue, 7 Apr 2020 06:52:56 -0500 Subject: added a script hackvr_open to just open a file in hackvr without hackvr exiting from EOF --- bin/hackvr_open | 4 ++++ 1 file changed, 4 insertions(+) create mode 100755 bin/hackvr_open diff --git a/bin/hackvr_open b/bin/hackvr_open new file mode 100755 index 0000000..3121f46 --- /dev/null +++ b/bin/hackvr_open @@ -0,0 +1,4 @@ +#!/bin/sh +### you may want to force this pipeline through a new x-terminal-emulator if you want to be able to write to stdin by hand. +### for debugging purposes? I'll probably do that soon. +nonblocktail "$1" /dev/stdin | hackvr -- cgit v1.2.3