Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 01401d3221 |
57
OSCWalker.py
57
OSCWalker.py
@ -1,10 +1,6 @@
|
|||||||
from pythonosc.udp_client import SimpleUDPClient
|
from pythonosc.udp_client import SimpleUDPClient
|
||||||
|
from pynput import keyboard
|
||||||
import time
|
import time
|
||||||
import pygame
|
|
||||||
pygame.init()
|
|
||||||
screen = pygame.display.set_mode((200,200))
|
|
||||||
running = True
|
|
||||||
clock = pygame.time.Clock()
|
|
||||||
|
|
||||||
ip = "127.0.0.1"
|
ip = "127.0.0.1"
|
||||||
port = 9000
|
port = 9000
|
||||||
@ -14,49 +10,54 @@ client = SimpleUDPClient(ip, port) # Create client
|
|||||||
right = True
|
right = True
|
||||||
left = True
|
left = True
|
||||||
|
|
||||||
movingAmount = 40 # Change for moving duration
|
movingAmount = 50 # Change for moving duration
|
||||||
|
|
||||||
moving = 0
|
moving = 0
|
||||||
|
|
||||||
steps = 0
|
steps = 0
|
||||||
|
|
||||||
|
# Main movement code
|
||||||
|
|
||||||
|
def on_press(key):
|
||||||
|
|
||||||
# Movement
|
# What am I doing...
|
||||||
while running:
|
global steps, left, right, moving
|
||||||
|
|
||||||
for event in pygame.event.get():
|
# If left step taken and right step was taken before
|
||||||
if event.type == pygame.QUIT:
|
if key == keyboard.Key.f13 and left == True:
|
||||||
running = False
|
global steps
|
||||||
|
|
||||||
keys=pygame.key.get_pressed()
|
|
||||||
screen.fill("orange")
|
|
||||||
|
|
||||||
#Code for alternating steps
|
|
||||||
|
|
||||||
if keys[pygame.K_F13] and left == True:
|
|
||||||
steps += 1
|
steps += 1
|
||||||
moving = movingAmount
|
moving = movingAmount
|
||||||
left = False
|
left = False
|
||||||
client.send_message("/input/MoveForward", 1) # Move forward
|
client.send_message("/input/MoveForward", 1) # Move forward
|
||||||
right = True
|
right = True
|
||||||
print(steps)
|
print(steps)
|
||||||
|
# If right step taken and left step was taken before
|
||||||
if keys[pygame.K_F14] and right == True:
|
if key == keyboard.Key.f14 and right == True:
|
||||||
steps += 1
|
steps += 1
|
||||||
moving = movingAmount
|
moving = movingAmount
|
||||||
right = False
|
|
||||||
client.send_message("/input/MoveForward", 1) # Move forward
|
|
||||||
left = True
|
left = True
|
||||||
|
client.send_message("/input/MoveForward", 1) # Move forward
|
||||||
|
right = False
|
||||||
print(steps)
|
print(steps)
|
||||||
|
|
||||||
#Constant move forward code with grace period to allow non-stop steps.
|
# I think this is right... it's working so far...
|
||||||
|
|
||||||
if moving == 0:
|
listener = keyboard.Listener(
|
||||||
client.send_message("/input/MoveForward", 0)
|
on_press=on_press,
|
||||||
else:
|
)
|
||||||
|
|
||||||
|
#Start listening for keyboard inputs... I think... This is why you don't copy code kids
|
||||||
|
listener.start()
|
||||||
|
|
||||||
|
|
||||||
|
# Loop for moving grace period, essentially a timer before actually stopping movement
|
||||||
|
while True:
|
||||||
|
if moving > 0:
|
||||||
moving -= 1
|
moving -= 1
|
||||||
|
|
||||||
pygame.display.flip()
|
if moving == 0:
|
||||||
|
client.send_message("/input/MoveForward", 0)
|
||||||
|
print("Stopped moving")
|
||||||
|
|
||||||
clock.tick(100)
|
time.sleep(0.01)
|
||||||
@ -8,7 +8,7 @@ Extremely simple program that allows to track inputs from a Wii Balance Board in
|
|||||||
|
|
||||||
- VRChat (It was kind of made for... specifically VRChat)<br>
|
- VRChat (It was kind of made for... specifically VRChat)<br>
|
||||||
- Bluetooth<br>
|
- Bluetooth<br>
|
||||||
- Uses Pygame (pip install pygame)<br>
|
- Uses Pynput (pip install pynput)<br>
|
||||||
- Uses python-osc (pip install python-osc)
|
- Uses python-osc (pip install python-osc)
|
||||||
- [Uses Python](https://www.python.org/)<br>
|
- [Uses Python](https://www.python.org/)<br>
|
||||||
- [Uses WiiBalanceWalker by Shachar Liberman](https://github.com/lshachar/WiiBalanceWalker)<br>
|
- [Uses WiiBalanceWalker by Shachar Liberman](https://github.com/lshachar/WiiBalanceWalker)<br>
|
||||||
@ -29,14 +29,13 @@ Extremely simple program that allows to track inputs from a Wii Balance Board in
|
|||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
|
If there is a release, download and use that, otherwise:
|
||||||
|
|
||||||
- Download the zip file by pressing the big green "Code" button, then "Download ZIP".
|
- Download the zip file by pressing the big green "Code" button, then "Download ZIP".
|
||||||
- Extract the folder and open it.
|
- Extract the folder and open it.
|
||||||
- While inside the folder, right click empty space and click "Open in Terminal"
|
- While inside the folder, right click empty space and click "Open in Terminal"
|
||||||
- Type and run "python OSCWalker.py"
|
- Type and run "python OSCWalker.py"
|
||||||
|
|
||||||
**You may want to run pygame while within VSCode/Codium in order to view terminal logs**
|
|
||||||
|
|
||||||
## Troubleshoot
|
## Troubleshoot
|
||||||
- Ensure that pygame is installed.
|
|
||||||
- Ensure that the pygame window is focused.
|
|
||||||
- Ensure OSC is enabled in the VRChat quick menu.
|
- Ensure OSC is enabled in the VRChat quick menu.
|
||||||
Reference in New Issue
Block a user