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 --- share/hackvr/examples/calendar/Makefile | 3 +-- share/hackvr/examples/calendar/hackvr_coproc | 2 -- share/hackvr/examples/uristart.conf | 2 ++ 3 files changed, 3 insertions(+), 4 deletions(-) delete mode 100755 share/hackvr/examples/calendar/hackvr_coproc create mode 100644 share/hackvr/examples/uristart.conf (limited to 'share/hackvr/examples') 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 36da2549891d0d67ed267b3bc5336bf14b2c64de Mon Sep 17 00:00:00 2001 From: epoch Date: Tue, 7 Apr 2020 07:00:06 -0500 Subject: made hackvr_term not bother with background squares for now. added an exec and pipefail to hackvr_data_decode.sh --- share/hackvr/examples/hackvr_term/hackvr_data_decode.sh | 5 +++-- share/hackvr/examples/hackvr_term/hackvr_term.c | 2 +- share/hackvr/examples/hackvr_term/pty.c | 11 ++++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'share/hackvr/examples') diff --git a/share/hackvr/examples/hackvr_term/hackvr_data_decode.sh b/share/hackvr/examples/hackvr_term/hackvr_data_decode.sh index 0ac04f2..85c64af 100755 --- a/share/hackvr/examples/hackvr_term/hackvr_data_decode.sh +++ b/share/hackvr/examples/hackvr_term/hackvr_data_decode.sh @@ -1,2 +1,3 @@ -#!/bin/sh -grep --line-buffered '^[^ ]* data ' | stdbuf -oL tr -s ' ' | stdbuf -oL cut '-d ' -f3- | stdbuf -o0 xxd -r -p +#!/usr/bin/env bash +set -eo pipefail +exec grep --line-buffered '^[^ ]* data ' | stdbuf -oL tr -s ' ' | stdbuf -oL cut '-d ' -f3- | stdbuf -o0 xxd -r -p diff --git a/share/hackvr/examples/hackvr_term/hackvr_term.c b/share/hackvr/examples/hackvr_term/hackvr_term.c index 71f2492..5fcf42c 100644 --- a/share/hackvr/examples/hackvr_term/hackvr_term.c +++ b/share/hackvr/examples/hackvr_term/hackvr_term.c @@ -60,7 +60,7 @@ void preload_glyphs() { void hackvr_draw_character(int c,int r,const TMTCHAR *ch) { char *line; int i,ret=0; - printf("term_%02d_%02d addshape %d 4 -1 -3 0 5 -3 0 5 7 0 -1 7 0\n",c,r,ch->a.bg+15); + //printf("term_%02d_%02d addshape %d 4 -1 -3 0 5 -3 0 5 7 0 -1 7 0\n",c,r,ch->a.bg+15); for(i=0,line=glyphs[ch->c][0];line[0];i++,line=glyphs[ch->c][i]) { ret=1; printf("term_%02d_%02d addshape %d %s",c,r,ch->a.fg == -1 ? 17 : ch->a.fg + 15,line+strlen("XX addshape X")); diff --git a/share/hackvr/examples/hackvr_term/pty.c b/share/hackvr/examples/hackvr_term/pty.c index 1011e38..a3d9951 100644 --- a/share/hackvr/examples/hackvr_term/pty.c +++ b/share/hackvr/examples/hackvr_term/pty.c @@ -1,12 +1,15 @@ #include #include #include +#include +#include int main(int argc,char *argv[]) { char *pts; char in[256];//I dunno. int r; int pid; + int eof1,eof2; int master,slave; master=open("/dev/ptmx",O_RDWR); if(master == -1) return 1; @@ -42,18 +45,20 @@ 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); } 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); } -- cgit v1.2.3 From 22ccae8d0d34a7a38f309c700f9008042d5ee938 Mon Sep 17 00:00:00 2001 From: epoch Date: Sun, 12 Apr 2020 23:59:27 -0500 Subject: rewrote tic-tac-toe a bit until it worked again --- share/hackvr/examples/tictactoe/game.sh | 52 ++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'share/hackvr/examples') diff --git a/share/hackvr/examples/tictactoe/game.sh b/share/hackvr/examples/tictactoe/game.sh index b4187dd..92192cc 100755 --- a/share/hackvr/examples/tictactoe/game.sh +++ b/share/hackvr/examples/tictactoe/game.sh @@ -4,30 +4,34 @@ BOARDFILE=board_orig cat camera.pos $BOARDFILE echo "go. player: $turn" >&2 grep --line-buffered action \ - | while read user derp group;do -# echo FUCK >&2 - if grep "_reset" <<<$group >/dev/null;then - printf "%s deleteallexcept .\n" "$user" - cat $BOARDFILE - continue - elif grep "_exit" <<<$group >/dev/null;then #this doesn't work in local games. :/ - exit 0 - elif grep "_" <<<$group >/dev/null;then -# xmessage "CUT IT OUT" - echo CUT IT OUT > /dev/stderr - continue - else - turn=$(expr \( $turn + 1 \) % 2) - #printf "# turn: %d\n" "$turn" > /dev/stderr - printf "$user deletegroup %s\n" "$group" - #printf "$user deletegroup %s\n" "$group" > /dev/stderr + | while read user action group;do + if [ $action = "action" ];then + if grep "_reset" <<<$group >/dev/null;then + printf "%s deleteallexcept %s\n" "$user" "$user" + cat $BOARDFILE + continue + elif grep "_exit" <<<$group >/dev/null;then + #if a program wants to exit, it should just exit. + #the program may have been ran by some other program. + #maybe just filter out server-side quit messages for your own username? + #any user quit will cause any hackvr to quit? + #printf "%s quit\n" "$user" + exit 0 + elif grep "_" <<<$group >/dev/null;then + echo CUT IT OUT > /dev/stderr + continue + elif grep "^board" <<<$group >/dev/null;then + turn=$(expr \( $turn + 1 \) % 2) + #printf "# turn: %d\n" "$turn" > /dev/stderr + printf "%s deletegroup %s\n" "$user" "$group" + #printf "$user deletegroup %s\n" "$group" > /dev/stderr #need to get the first point of the group clicked and translate the new shape by that much - translatex="$(grep "$group" $BOARDFILE | grep -v '^#' | tr -s ' ' | cut '-d ' -f5)" - translatey="$(grep "$group" $BOARDFILE | grep -v '^#' | tr -s ' ' | cut '-d ' -f6)" - cat "marker$turn" | offsetshape.sh $translatex "$(expr "$translatey" - 2 )" 0 -# printf "%s move %s %s 2\n" "_marker" "$(expr "$translatex")" "$(expr "$translatey" - 2 )" - #printf "%s move %s %s 2\n" "_marker" "$(expr "$translatex")" "$(expr "$translatey" - 2 )" >/dev/stderr - grep "$group" $BOARDFILE | sed "s/$group/_marker2/g" #this is to make it still show the square around it. - printf "%s renamegroup _marker _marker%s%s\n" "$user" "$(date +%s)" "$RANDOM" + translatex="$(grep "$group" $BOARDFILE | grep -v '^#' | tr -s ' ' | cut '-d ' -f5)" + translatey="$(grep "$group" $BOARDFILE | grep -v '^#' | tr -s ' ' | cut '-d ' -f6)" + cat "marker$turn" | offsetshape.sh $translatex "$(expr "$translatey" - 2 )" 0 + grep "$group" $BOARDFILE | sed "s/$group/_marked/g" + else + xmessage "what? $group" + fi fi done -- cgit v1.2.3 From ff2e3e4dcf06bda47fd88f1f17232e3257da93ed Mon Sep 17 00:00:00 2001 From: epoch Date: Mon, 13 Apr 2020 00:00:13 -0500 Subject: I do not remember why I have two of these boards, but both should work with the recent changed to game.sh --- share/hackvr/examples/tictactoe/board | 18 +++++++++--------- share/hackvr/examples/tictactoe/board_orig | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'share/hackvr/examples') diff --git a/share/hackvr/examples/tictactoe/board b/share/hackvr/examples/tictactoe/board index 607ebf3..e7494fd 100644 --- a/share/hackvr/examples/tictactoe/board +++ b/share/hackvr/examples/tictactoe/board @@ -1,13 +1,13 @@ _reset addshape 2 3 -4 6 4 -5 6 4 -4 5 4 -topleft addshape 2 4 -3 13 4 -1 13 4 -1 11 4 -3 11 4 -topcenter addshape 2 4 -1 13 4 1 13 4 1 11 4 -1 11 4 -topright addshape 2 4 1 13 4 3 13 4 3 11 4 1 11 4 +boardtopleft addshape 2 4 -3 13 4 -1 13 4 -1 11 4 -3 11 4 +boardtopcenter addshape 2 4 -1 13 4 1 13 4 1 11 4 -1 11 4 +boardtopright addshape 2 4 1 13 4 3 13 4 3 11 4 1 11 4 -middleleft addshape 2 4 -3 11 4 -1 11 4 -1 9 4 -3 9 4 -middlecenter addshape 2 4 -1 11 4 1 11 4 1 9 4 -1 9 4 -middleright addshape 2 4 1 11 4 3 11 4 3 9 4 1 9 4 +boardmiddleleft addshape 2 4 -3 11 4 -1 11 4 -1 9 4 -3 9 4 +boardmiddlecenter addshape 2 4 -1 11 4 1 11 4 1 9 4 -1 9 4 +boardmiddleright addshape 2 4 1 11 4 3 11 4 3 9 4 1 9 4 -bottomleft addshape 2 4 -3 9 4 -1 9 4 -1 7 4 -3 7 4 -bottomcenter addshape 2 4 -1 9 4 1 9 4 1 7 4 -1 7 4 -bottomright addshape 2 4 1 9 4 3 9 4 3 7 4 1 7 4 +boardbottomleft addshape 2 4 -3 9 4 -1 9 4 -1 7 4 -3 7 4 +boardbottomcenter addshape 2 4 -1 9 4 1 9 4 1 7 4 -1 7 4 +boardbottomright addshape 2 4 1 9 4 3 9 4 3 7 4 1 7 4 diff --git a/share/hackvr/examples/tictactoe/board_orig b/share/hackvr/examples/tictactoe/board_orig index bc97ee4..2fff3ba 100644 --- a/share/hackvr/examples/tictactoe/board_orig +++ b/share/hackvr/examples/tictactoe/board_orig @@ -1,14 +1,14 @@ _reset addshape 2 3 -4 -4 4 -5 -4 4 -4 -5 4 _exit addshape 2 3 4 -4 4 5 -4 4 4 -5 4 -topleft addshape 2 4 -3 3 4 -1 3 4 -1 1 4 -3 1 4 -topcenter addshape 2 4 -1 3 4 1 3 4 1 1 4 -1 1 4 -topright addshape 2 4 1 3 4 3 3 4 3 1 4 1 1 4 +boardtopleft addshape 2 4 -3 3 4 -1 3 4 -1 1 4 -3 1 4 +boardtopcenter addshape 2 4 -1 3 4 1 3 4 1 1 4 -1 1 4 +boardtopright addshape 2 4 1 3 4 3 3 4 3 1 4 1 1 4 -middleleft addshape 2 4 -3 1 4 -1 1 4 -1 -1 4 -3 -1 4 -middlecenter addshape 2 4 -1 1 4 1 1 4 1 -1 4 -1 -1 4 -middleright addshape 2 4 1 1 4 3 1 4 3 -1 4 1 -1 4 +boardmiddleleft addshape 2 4 -3 1 4 -1 1 4 -1 -1 4 -3 -1 4 +boardmiddlecenter addshape 2 4 -1 1 4 1 1 4 1 -1 4 -1 -1 4 +boardmiddleright addshape 2 4 1 1 4 3 1 4 3 -1 4 1 -1 4 -bottomleft addshape 2 4 -3 -1 4 -1 -1 4 -1 -3 4 -3 -3 4 -bottomcenter addshape 2 4 -1 -1 4 1 -1 4 1 -3 4 -1 -3 4 -bottomright addshape 2 4 1 -1 4 3 -1 4 3 -3 4 1 -3 4 +boardbottomleft addshape 2 4 -3 -1 4 -1 -1 4 -1 -3 4 -3 -3 4 +boardbottomcenter addshape 2 4 -1 -1 4 1 -1 4 1 -3 4 -1 -3 4 +boardbottomright addshape 2 4 1 -1 4 3 -1 4 3 -3 4 1 -3 4 -- cgit v1.2.3 From d30c6246ef2bd08d6420278c0c94e7173fa4a925 Mon Sep 17 00:00:00 2001 From: epoch Date: Mon, 13 Apr 2020 00:00:58 -0500 Subject: why was I printing an informative message to stdout? --- share/hackvr/examples/tictactoe/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share/hackvr/examples') diff --git a/share/hackvr/examples/tictactoe/run b/share/hackvr/examples/tictactoe/run index bf9c87a..54d712a 100755 --- a/share/hackvr/examples/tictactoe/run +++ b/share/hackvr/examples/tictactoe/run @@ -1,4 +1,4 @@ #!/usr/bin/env bash turn=$( expr $RANDOM % 2) -echo "go. player: $turn" +echo "# go. player: $turn" >&2 hackvr_coproc ./game.sh -- cgit v1.2.3