diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md new file mode 100644 index 0000000..5fbd1e5 --- /dev/null +++ b/README.md @@ -0,0 +1,62 @@ +# Hosting a Mayhem Party + +## Requirements + +1. [`rusty-pipe`](https://gogs.inhome.blapointe.com/bel/rusty-pipe) +1. [`mayhem-party`](https://gogs.inhome.blapointe.com/bel/mayhem-party) +1. [`stt`](https://gogs.inhome.blapointe.com/bel/stt) + +# Clients + +## Distribute `rusty-pipe` + +```bash +# https://www.reddit.com/r/rust/comments/5k8uab/crosscompiling_from_ubuntu_to_windows_with_rustup/ +( + echo '[target.x86_64-pc-windows-gnu]' + echo 'linker = "x86_64-w64-mingw32-gcc"' + echo 'ar = "x86_64-w64-mingw32-gcc-ar"' +) >> $HOME/.cargo/config +sudo apt install mingw-w64 +rustup target add x86_64-pc-windows-gnu +echo windows +cargo build --release --target x86_64-pc-windows-gnu && ls target/x86_64-pc-windows-gnu/release/rusty-pipe.exe +echo local +cargo install --path ./ +``` + +Each client needs 1 executable and 1 env file with a unique set of buttons + +> 10 buttons per player +> `go doc key Undef | grep Key | grep -v Undef | wc -l` total (51) + +The server cannot be a client because math. Maybe a VM on the client as a server would work tho. + +See `./config.d/rusty-pipe.d` + +# Server + +## TTS + +`cd /home/breel/Go/src/gogs.inhome.blapointe.com/tts/larynx.d; bash run.sh` + +## STT + +`cd /home/breel/Go/src/gogs.inhome.blapointe.com/stt.d/whisper-2023; HOTWORDS=/home/breel/Go/src/gogs.inhome.blapointe.com/mayhem-party.d/host.d/config.d/stt.d/hotwords.txt MIC_TIMEOUT=2 URL=http://localhost:17071/config HEADERS=say='Eye herd {{hotword}}' BODY='[{"op":"replace", "path":"/Quiet", "value":true}]' python3 ./hotwords.py' + +## `mayhem-party` + +### Configs + +`cd ./config.d/mayhem-party.d/remap.d; bash ./rotate.sh` + +> rotate anytime via stdin or `pkill -SIGUSR1 -f rotate.sh` + +### Binary + +`bash -c 'true; source ./config.d/mayhem-party.d/env.env; mayhem-party'` + +## Game Playing + +Foreground + diff --git a/config.d/mayhem-party.d/env.env b/config.d/mayhem-party.d/env.env new file mode 100644 index 0000000..3f6810f --- /dev/null +++ b/config.d/mayhem-party.d/env.env @@ -0,0 +1,11 @@ +export DEBUG=true +export MAIN_INTERVAL_DURATION=5ms + +export RAW_UDP=17070 + +export PARSE_V01=true +export V01_CONFIG=./config.d/mayhem-party.d/v01.yaml + +export WRAP_REFRESH_ON_SIGUSR1=true + +export OUTPUT_KEYBOARD=false diff --git a/config.d/mayhem-party.d/remap.d/.players_offset.py b/config.d/mayhem-party.d/remap.d/.players_offset.py new file mode 100644 index 0000000..d6ecf80 --- /dev/null +++ b/config.d/mayhem-party.d/remap.d/.players_offset.py @@ -0,0 +1,31 @@ +import yaml +from sys import argv +from sys import stderr + +def log(*args): + print(*args, file=stderr) + +def main(args): + players = [] + for i in range(1, 5+1): + with open(f"../../rusty-pipe.d/{i}.yaml", "r") as f: + players.append(yaml.safe_load(f)["streams"]["input"]["engine"]["gui"]["buttons"]) + log(players[-1]) + for arg in args: + offset = int(arg) + for i in range(len(players)): + j = (i+offset)%len(players) + if i == j: + break + keys = players[i] + values = players[j] + log(f"player {i+1} plays as player {j+1}") + print(f"# player {i+1} controls {j+1}") + for k in keys: + key = keys[k] + value = values[k] + print(f"'{key}': '{value}'") + +if __name__ == "__main__": + from sys import argv + main(argv[1:]) diff --git a/config.d/mayhem-party.d/remap.d/live.yaml b/config.d/mayhem-party.d/remap.d/live.yaml new file mode 120000 index 0000000..94cf0e4 --- /dev/null +++ b/config.d/mayhem-party.d/remap.d/live.yaml @@ -0,0 +1 @@ +players_offset_2.yaml \ No newline at end of file diff --git a/config.d/mayhem-party.d/remap.d/players_offset_0.yaml b/config.d/mayhem-party.d/remap.d/players_offset_0.yaml new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/config.d/mayhem-party.d/remap.d/players_offset_0.yaml @@ -0,0 +1 @@ +{} diff --git a/config.d/mayhem-party.d/remap.d/players_offset_1.yaml b/config.d/mayhem-party.d/remap.d/players_offset_1.yaml new file mode 100644 index 0000000..e12aabf --- /dev/null +++ b/config.d/mayhem-party.d/remap.d/players_offset_1.yaml @@ -0,0 +1,55 @@ +# player 1 controls 2 +'1': 'q' +'2': 'w' +'3': 'e' +'4': 'r' +'5': 't' +'6': 'y' +'7': 'u' +'8': 'i' +'9': 'o' +'0': 'p' +# player 2 controls 3 +'q': 'a' +'w': 's' +'e': 'd' +'r': 'f' +'t': 'g' +'y': 'h' +'u': 'j' +'i': 'k' +'o': 'l' +'p': ';' +# player 3 controls 4 +'a': 'z' +'s': 'x' +'d': 'c' +'f': 'v' +'g': 'b' +'h': 'n' +'j': 'm' +'k': ',' +'l': '-' +';': '/' +# player 4 controls 5 +'z': '!' +'x': '@' +'c': '#' +'v': '$' +'b': '%' +'n': '^' +'m': '&' +',': '*' +'-': '(' +'/': ')' +# player 5 controls 1 +'!': '1' +'@': '2' +'#': '3' +'$': '4' +'%': '5' +'^': '6' +'&': '7' +'*': '8' +'(': '9' +')': '0' diff --git a/config.d/mayhem-party.d/remap.d/players_offset_2.yaml b/config.d/mayhem-party.d/remap.d/players_offset_2.yaml new file mode 100644 index 0000000..1d3c173 --- /dev/null +++ b/config.d/mayhem-party.d/remap.d/players_offset_2.yaml @@ -0,0 +1,55 @@ +# player 1 controls 3 +'1': 'a' +'2': 's' +'3': 'd' +'4': 'f' +'5': 'g' +'6': 'h' +'7': 'j' +'8': 'k' +'9': 'l' +'0': ';' +# player 2 controls 4 +'q': 'z' +'w': 'x' +'e': 'c' +'r': 'v' +'t': 'b' +'y': 'n' +'u': 'm' +'i': ',' +'o': '-' +'p': '/' +# player 3 controls 5 +'a': '!' +'s': '@' +'d': '#' +'f': '$' +'g': '%' +'h': '^' +'j': '&' +'k': '*' +'l': '(' +';': ')' +# player 4 controls 1 +'z': '1' +'x': '2' +'c': '3' +'v': '4' +'b': '5' +'n': '6' +'m': '7' +',': '8' +'-': '9' +'/': '0' +# player 5 controls 2 +'!': 'q' +'@': 'w' +'#': 'e' +'$': 'r' +'%': 't' +'^': 'y' +'&': 'u' +'*': 'i' +'(': 'o' +')': 'p' diff --git a/config.d/mayhem-party.d/remap.d/players_offset_3.yaml b/config.d/mayhem-party.d/remap.d/players_offset_3.yaml new file mode 100644 index 0000000..bb66f1f --- /dev/null +++ b/config.d/mayhem-party.d/remap.d/players_offset_3.yaml @@ -0,0 +1,55 @@ +# player 1 controls 4 +'1': 'z' +'2': 'x' +'3': 'c' +'4': 'v' +'5': 'b' +'6': 'n' +'7': 'm' +'8': ',' +'9': '-' +'0': '/' +# player 2 controls 5 +'q': '!' +'w': '@' +'e': '#' +'r': '$' +'t': '%' +'y': '^' +'u': '&' +'i': '*' +'o': '(' +'p': ')' +# player 3 controls 1 +'a': '1' +'s': '2' +'d': '3' +'f': '4' +'g': '5' +'h': '6' +'j': '7' +'k': '8' +'l': '9' +';': '0' +# player 4 controls 2 +'z': 'q' +'x': 'w' +'c': 'e' +'v': 'r' +'b': 't' +'n': 'y' +'m': 'u' +',': 'i' +'-': 'o' +'/': 'p' +# player 5 controls 3 +'!': 'a' +'@': 's' +'#': 'd' +'$': 'f' +'%': 'g' +'^': 'h' +'&': 'j' +'*': 'k' +'(': 'l' +')': ';' diff --git a/config.d/mayhem-party.d/remap.d/players_offset_4.yaml b/config.d/mayhem-party.d/remap.d/players_offset_4.yaml new file mode 100644 index 0000000..f694f4f --- /dev/null +++ b/config.d/mayhem-party.d/remap.d/players_offset_4.yaml @@ -0,0 +1,55 @@ +# player 1 controls 5 +'1': '!' +'2': '@' +'3': '#' +'4': '$' +'5': '%' +'6': '^' +'7': '&' +'8': '*' +'9': '(' +'0': ')' +# player 2 controls 1 +'q': '1' +'w': '2' +'e': '3' +'r': '4' +'t': '5' +'y': '6' +'u': '7' +'i': '8' +'o': '9' +'p': '0' +# player 3 controls 2 +'a': 'q' +'s': 'w' +'d': 'e' +'f': 'r' +'g': 't' +'h': 'y' +'j': 'u' +'k': 'i' +'l': 'o' +';': 'p' +# player 4 controls 3 +'z': 'a' +'x': 's' +'c': 'd' +'v': 'f' +'b': 'g' +'n': 'h' +'m': 'j' +',': 'k' +'-': 'l' +'/': ';' +# player 5 controls 4 +'!': 'z' +'@': 'x' +'#': 'c' +'$': 'v' +'%': 'b' +'^': 'n' +'&': 'm' +'*': ',' +'(': '-' +')': '/' diff --git a/config.d/mayhem-party.d/remap.d/rotate.sh b/config.d/mayhem-party.d/remap.d/rotate.sh new file mode 100644 index 0000000..744fe5d --- /dev/null +++ b/config.d/mayhem-party.d/remap.d/rotate.sh @@ -0,0 +1,21 @@ +#! /bin/bash + +mayhem_party_rotate() { + local currently=$(realpath live.yaml | grep -o '[0-9].yaml$' | grep -o '^[0-9]') + local next=${NEXT:-$((RANDOM%5))} + while [ -z "$NEXT" ] && [ "$next" == "$currently" ]; do + next=$((RANDOM%5)) + done + rm live.yaml + ln -s players_offset_$next.yaml live.yaml + pkill -SIGUSR1 -f mayhem-party +} + +trap mayhem_party_rotate SIGUSR1 + +if [ "$0" == "$BASH_SOURCE" ]; then + NEXT=0 mayhem_party_rotate + while read -p "$(date) > [press enter to rotate]"; do + mayhem_party_rotate + done +fi diff --git a/config.d/mayhem-party.d/v01.yaml b/config.d/mayhem-party.d/v01.yaml new file mode 100644 index 0000000..da2363d --- /dev/null +++ b/config.d/mayhem-party.d/v01.yaml @@ -0,0 +1,23 @@ +feedback: + addr: :17071 + ttsurl: http://localhost:15002 +users: + bel: + player: 2 + message: its bel + broadcast: + message: 8 +players: +- {} +- transformation: + w: t + a: f + s: g + d: h + q: r + e: y + 1: 5 + 2: 6 + 3: 7 + 4: 8 +quiet: false diff --git a/config.d/rusty-pipe.d/1.yaml b/config.d/rusty-pipe.d/1.yaml new file mode 100644 index 0000000..a052e75 --- /dev/null +++ b/config.d/rusty-pipe.d/1.yaml @@ -0,0 +1,30 @@ +streams: + input: + debug: false + engine: + name: gui + gui: + user: bel + feedback: + url: http://mayhem-party.home.blapointe.com:17071?user=bel + press: {prefix: "", suffix: ""} + release: {prefix: "", suffix: ""} + format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}' + buttons: + up: 'w' + down: 's' + left: 'a' + right: 'd' + l: 'e' + r: 'q' + a: '1' + b: '2' + x: '3' + y: '4' + output: + debug: false + engine: + name: udp + udp: + host: mayhem-party.home.blapointe.com + port: 17070 diff --git a/config.d/rusty-pipe.d/2.yaml b/config.d/rusty-pipe.d/2.yaml new file mode 100644 index 0000000..f966ee4 --- /dev/null +++ b/config.d/rusty-pipe.d/2.yaml @@ -0,0 +1,30 @@ +streams: + input: + debug: false + engine: + name: gui + gui: + user: zach + feedback: + url: http://mayhem-party.home.blapointe.com:17071?user=zach + press: {prefix: "", suffix: ""} + release: {prefix: "", suffix: ""} + format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}' + buttons: + up: 'w' + down: 's' + left: 'a' + right: 'd' + l: 'e' + r: 'q' + a: '1' + b: '2' + x: '3' + y: '4' + output: + debug: false + engine: + name: udp + udp: + host: mayhem-party.home.blapointe.com + port: 17070 diff --git a/config.d/rusty-pipe.d/3.yaml b/config.d/rusty-pipe.d/3.yaml new file mode 100644 index 0000000..979c71e --- /dev/null +++ b/config.d/rusty-pipe.d/3.yaml @@ -0,0 +1,30 @@ +streams: + input: + debug: false + engine: + name: gui + gui: + user: chase + feedback: + url: http://mayhem-party.home.blapointe.com:17071?user=chase + press: {prefix: "", suffix: ""} + release: {prefix: "", suffix: ""} + format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}' + buttons: + up: 'w' + down: 's' + left: 'a' + right: 'd' + l: 'e' + r: 'q' + a: '1' + b: '2' + x: '3' + y: '4' + output: + debug: false + engine: + name: udp + udp: + host: mayhem-party.home.blapointe.com + port: 17070 diff --git a/config.d/rusty-pipe.d/4.yaml b/config.d/rusty-pipe.d/4.yaml new file mode 100644 index 0000000..2ab7a7c --- /dev/null +++ b/config.d/rusty-pipe.d/4.yaml @@ -0,0 +1,30 @@ +streams: + input: + debug: false + engine: + name: gui + gui: + user: mason + feedback: + url: http://mayhem-party.home.blapointe.com:17071?user=mason + press: {prefix: "", suffix: ""} + release: {prefix: "", suffix: ""} + format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}' + buttons: + up: 'w' + down: 's' + left: 'a' + right: 'd' + l: 'e' + r: 'q' + a: '1' + b: '2' + x: '3' + y: '4' + output: + debug: false + engine: + name: udp + udp: + host: mayhem-party.home.blapointe.com + port: 17070 diff --git a/config.d/rusty-pipe.d/5.yaml b/config.d/rusty-pipe.d/5.yaml new file mode 100644 index 0000000..ee1d810 --- /dev/null +++ b/config.d/rusty-pipe.d/5.yaml @@ -0,0 +1,30 @@ +streams: + input: + debug: false + engine: + name: gui + gui: + user: nat + feedback: + url: http://mayhem-party.home.blapointe.com:17071?user=nat + press: {prefix: "", suffix: ""} + release: {prefix: "", suffix: ""} + format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}' + buttons: + up: 'w' + down: 's' + left: 'a' + right: 'd' + l: 'e' + r: 'q' + a: '1' + b: '2' + x: '3' + y: '4' + output: + debug: false + engine: + name: udp + udp: + host: mayhem-party.home.blapointe.com + port: 17070 diff --git a/config.d/rusty-pipe.d/6.yaml b/config.d/rusty-pipe.d/6.yaml new file mode 100644 index 0000000..1fc15d8 --- /dev/null +++ b/config.d/rusty-pipe.d/6.yaml @@ -0,0 +1,30 @@ +streams: + input: + debug: false + engine: + name: gui + gui: + user: roxy + feedback: + url: http://mayhem-party.home.blapointe.com:17071?user=roxy + press: {prefix: "", suffix: ""} + release: {prefix: "", suffix: ""} + format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}' + buttons: + up: 'w' + down: 's' + left: 'a' + right: 'd' + l: 'e' + r: 'q' + a: '1' + b: '2' + x: '3' + y: '4' + output: + debug: false + engine: + name: udp + udp: + host: mayhem-party.home.blapointe.com + port: 17070 diff --git a/config.d/rusty-pipe.d/7.yaml b/config.d/rusty-pipe.d/7.yaml new file mode 100644 index 0000000..5a507ac --- /dev/null +++ b/config.d/rusty-pipe.d/7.yaml @@ -0,0 +1,30 @@ +streams: + input: + debug: false + engine: + name: gui + gui: + user: bill + feedback: + url: http://mayhem-party.home.blapointe.com:17071?user=bill + press: {prefix: "", suffix: ""} + release: {prefix: "", suffix: ""} + format: '{"T":{{ms}},"U":"{{user}}","Y":"{{pressed}}","N":"{{released}}"}' + buttons: + up: 'w' + down: 's' + left: 'a' + right: 'd' + l: 'e' + r: 'q' + a: '1' + b: '2' + x: '3' + y: '4' + output: + debug: false + engine: + name: udp + udp: + host: mayhem-party.home.blapointe.com + port: 17070 diff --git a/config.d/rusty-pipe.d/rusty-pipe.exe b/config.d/rusty-pipe.d/rusty-pipe.exe new file mode 120000 index 0000000..5c68ed5 --- /dev/null +++ b/config.d/rusty-pipe.d/rusty-pipe.exe @@ -0,0 +1 @@ +../../../rusty-pipe.d/target/x86_64-pc-windows-gnu/release/rusty-pipe.exe \ No newline at end of file diff --git a/config.d/stt.d/hotwords.txt b/config.d/stt.d/hotwords.txt new file mode 100644 index 0000000..94bbfcc --- /dev/null +++ b/config.d/stt.d/hotwords.txt @@ -0,0 +1,5 @@ +mario +party +yo +win +die