aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2020-04-13 00:09:12 -0500
committerepoch <epoch@hacking.allowed.org>2020-04-13 00:09:12 -0500
commitdd737c645037d32bd67a6ca6f377787297921421 (patch)
tree0b533d9a79d45d6bf184f93c90c5dcbcad142d07
parent36da2549891d0d67ed267b3bc5336bf14b2c64de (diff)
parent7ffc20e9ae8297ea8b6f796310cf065d4186aa5b (diff)
downloadhackvr-dd737c645037d32bd67a6ca6f377787297921421.tar.gz
hackvr-dd737c645037d32bd67a6ca6f377787297921421.zip
merged some derp in hackvr_term
-rwxr-xr-xbin/hackvr_coproc2
-rwxr-xr-xbin/hackvr_open4
-rw-r--r--share/hackvr/examples/calendar/Makefile3
-rwxr-xr-xshare/hackvr/examples/calendar/hackvr_coproc2
-rw-r--r--share/hackvr/examples/hackvr_term/hackvr_term.c2
-rw-r--r--share/hackvr/examples/hackvr_term/pty.c25
-rwxr-xr-xshare/hackvr/examples/hackvr_term/read_line.sh5
-rw-r--r--share/hackvr/examples/uristart.conf2
-rw-r--r--src/hackvr.c23
-rwxr-xr-xtests/export_test.hackvr7
10 files changed, 51 insertions, 24 deletions
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/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
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/hackvr_term/hackvr_term.c b/share/hackvr/examples/hackvr_term/hackvr_term.c
index 5fcf42c..b044498 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]);
diff --git a/share/hackvr/examples/hackvr_term/pty.c b/share/hackvr/examples/hackvr_term/pty.c
index a3d9951..6903bc3 100644
--- a/share/hackvr/examples/hackvr_term/pty.c
+++ b/share/hackvr/examples/hackvr_term/pty.c
@@ -1,12 +1,15 @@
+#define _XOPEN_SOURCE 500 //ptsname
+#define _XOPEN_SOURCE_EXTENDED
#include <stdio.h>
#include <fcntl.h>
#include <sys/wait.h>
-#include <unistd.h>
#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
int main(int argc,char *argv[]) {
char *pts;
- char in[256];//I dunno.
+ char in;//I dunno.
int r;
int pid;
int eof1,eof2;
@@ -45,22 +48,22 @@ int main(int argc,char *argv[]) {
default:
break;
}
-eof1=0;
-eof2=0;
- for(;!eof1 && !eof2;) {
+ 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: eof1=1;//EOF
- case -1: break;//EAGAIN probably.
- default: write(master,in,r);
+ case 0: eof1=1;;//EOF
+ 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
- default: write(1,in,r);
+ case 0: eof2=1;;//EOF
+ case -1: if(errno != EAGAIN) eof2=1; break;//EAGAIN probably
+ default: write(1,&in,r);
}
usleep(100);//kek
}
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'
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'
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 {
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 *