forked from mirror/joycontrol
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ee00561ae0 | |||
| b6309bd1c1 | |||
| 335f48002e | |||
| c36ec55ee2 | |||
| cbcaae4002 | |||
| 80de0365a3 | |||
| 5a60f2e811 | |||
| ec9f2da4e3 | |||
| 1d75012a3a | |||
| 84a5768f38 | |||
| 1f4c1a33c0 | |||
| 052299e430 | |||
| d6627dfe3e | |||
| 269567f4f3 | |||
| 0df9a11c2d | |||
| f97156f503 | |||
| 138d742342 | |||
| 21508b1124 | |||
| b878f05b5c |
+52
@@ -0,0 +1,52 @@
|
|||||||
|
jc() {
|
||||||
|
screen -S joycontrol -X stuff "$1^M"
|
||||||
|
}
|
||||||
|
|
||||||
|
jcupdate() {
|
||||||
|
cd ~/joycontrol
|
||||||
|
git pull --ff-only
|
||||||
|
cd
|
||||||
|
cp -f ~/joycontrol/.jc_aliases ~
|
||||||
|
cp -f ~/joycontrol/macro/* ~
|
||||||
|
}
|
||||||
|
|
||||||
|
jcstart() {
|
||||||
|
jcupdate
|
||||||
|
screen -dmS joycontrol sudo python3 ~/joycontrol/run_controller_cli.py PRO_CONTROLLER -r 98:E2:55:92:E8:81
|
||||||
|
}
|
||||||
|
|
||||||
|
jcstop() {
|
||||||
|
screen -S joycontrol -X quit
|
||||||
|
}
|
||||||
|
|
||||||
|
jcrestart() {
|
||||||
|
jcstop
|
||||||
|
jcstart
|
||||||
|
}
|
||||||
|
|
||||||
|
jcmacro() {
|
||||||
|
buttonDelay='0.08'
|
||||||
|
if [[ ! -z $2 ]]; then
|
||||||
|
buttonDelay=$2
|
||||||
|
fi
|
||||||
|
|
||||||
|
macro=$(~/joycontrol/expand_nested_loops.sh "$1")
|
||||||
|
echo "$macro"
|
||||||
|
|
||||||
|
while read -r line; do
|
||||||
|
if [[ ${line:0:1} != "#" ]]; then
|
||||||
|
jc "$line"
|
||||||
|
jc "sleep $buttonDelay"
|
||||||
|
fi
|
||||||
|
done <<< $macro
|
||||||
|
}
|
||||||
|
|
||||||
|
jclist() {
|
||||||
|
ls ~/joycontrol/macro
|
||||||
|
}
|
||||||
|
|
||||||
|
if screen -ls | grep joycontrol; then
|
||||||
|
echo "joycontrol already running, restart id needed"
|
||||||
|
else
|
||||||
|
jcstart
|
||||||
|
fi
|
||||||
Executable
+32
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Recursively read lines until EOF or a "loopend" is encountered.
|
||||||
|
# Prints everything it reads, expanding any nested loops.
|
||||||
|
expand() {
|
||||||
|
local line repeat body
|
||||||
|
# Read one line at a time
|
||||||
|
while IFS= read -r line; do
|
||||||
|
# If this is the start of a loop, grab the count
|
||||||
|
if [[ $line =~ ^[[:space:]]*loop[[:space:]]+([0-9]+)[[:space:]]*$ ]]; then
|
||||||
|
repeat=${BASH_REMATCH[1]}
|
||||||
|
# Recursively collect inner block into an array
|
||||||
|
mapfile -t body < <( expand )
|
||||||
|
# Print that block "repeat" times
|
||||||
|
for ((i=0; i<repeat; i++)); do
|
||||||
|
printf '%s\n' "${body[@]}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# If this is the end of the current loop, return to caller
|
||||||
|
elif [[ $line =~ ^[[:space:]]*loopend[[:space:]]*$ ]]; then
|
||||||
|
return
|
||||||
|
|
||||||
|
# Otherwise, just print the line verbatim
|
||||||
|
else
|
||||||
|
printf '%s\n' "$line"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Kick it off: read from file if given, otherwise stdin
|
||||||
|
expand < "${1:-/dev/stdin}"
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# close game
|
||||||
|
home
|
||||||
|
x
|
||||||
|
a
|
||||||
|
# go to settings
|
||||||
|
hold down
|
||||||
|
sleep 1
|
||||||
|
release down
|
||||||
|
hold right
|
||||||
|
sleep 1.5
|
||||||
|
release right
|
||||||
|
left
|
||||||
|
a
|
||||||
|
sleep 1.2
|
||||||
|
# go to system settings
|
||||||
|
loop 16
|
||||||
|
down
|
||||||
|
loopend
|
||||||
|
a
|
||||||
|
sleep 0.5
|
||||||
|
# go to date settings
|
||||||
|
loop 7
|
||||||
|
down
|
||||||
|
loopend
|
||||||
|
a
|
||||||
|
sleep 0.5
|
||||||
|
# open time settings
|
||||||
|
down
|
||||||
|
down
|
||||||
|
a
|
||||||
|
sleep 0.5
|
||||||
|
# change day
|
||||||
|
right
|
||||||
|
up
|
||||||
|
loop 6
|
||||||
|
a
|
||||||
|
loopend
|
||||||
|
# back to game
|
||||||
|
home
|
||||||
|
a
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
loop 5
|
||||||
|
loop 6
|
||||||
|
#release mon
|
||||||
|
sleep 0.2
|
||||||
|
right
|
||||||
|
loopend
|
||||||
|
right
|
||||||
|
down
|
||||||
|
loopend
|
||||||
|
down
|
||||||
|
down
|
||||||
|
down
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# go to settings
|
||||||
|
hold down
|
||||||
|
sleep 1
|
||||||
|
release down
|
||||||
|
hold right
|
||||||
|
sleep 1.5
|
||||||
|
release right
|
||||||
|
left
|
||||||
|
a
|
||||||
|
sleep 1.2
|
||||||
|
#go to controller settings
|
||||||
|
hold down
|
||||||
|
sleep 2
|
||||||
|
release down
|
||||||
|
loop 8
|
||||||
|
up
|
||||||
|
loopend
|
||||||
|
a
|
||||||
|
sleep 1.2
|
||||||
|
# go to test inputs
|
||||||
|
loop 12
|
||||||
|
down
|
||||||
|
loopend
|
||||||
|
a
|
||||||
|
sleep 1.2
|
||||||
|
a
|
||||||
|
sleep 1
|
||||||
|
# test buttons
|
||||||
|
up
|
||||||
|
right
|
||||||
|
down
|
||||||
|
left
|
||||||
|
a
|
||||||
|
b
|
||||||
|
x
|
||||||
|
y
|
||||||
|
plus
|
||||||
|
minus
|
||||||
|
l
|
||||||
|
r
|
||||||
|
zl
|
||||||
|
zr
|
||||||
|
l_stick
|
||||||
|
r_stick
|
||||||
@@ -264,6 +264,15 @@ def _register_commands_with_controller_state(controller_state, cli):
|
|||||||
|
|
||||||
cli.add_command(nfc.__name__, nfc)
|
cli.add_command(nfc.__name__, nfc)
|
||||||
|
|
||||||
|
#sleep
|
||||||
|
async def sleep(*args):
|
||||||
|
"""
|
||||||
|
sleep - waits specified amount of seconds
|
||||||
|
"""
|
||||||
|
await asyncio.sleep(float(args[0]))
|
||||||
|
|
||||||
|
cli.add_command(sleep.__name__, sleep)
|
||||||
|
|
||||||
|
|
||||||
async def _main(args):
|
async def _main(args):
|
||||||
# parse the spi flash
|
# parse the spi flash
|
||||||
|
|||||||
Executable
+1
@@ -0,0 +1 @@
|
|||||||
|
sudo python3 run_controller_cli.py PRO_CONTROLLER -r 98:E2:55:92:E8:81
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
98:E2:55:92:E8:81
|
||||||
Reference in New Issue
Block a user