40 lines
946 B
Python
40 lines
946 B
Python
"""
|
|
VRCCC (VRChat Custom Camera) is a simple Python script to
|
|
override camera options in VRChat using OSC.
|
|
"""
|
|
|
|
import json
|
|
|
|
from pythonosc import udp_client, osc_server
|
|
from pythonosc.dispatcher import Dispatcher
|
|
|
|
from camera import Camera
|
|
|
|
overrides = {}
|
|
|
|
def onCameraEnabled(cam: Camera):
|
|
"""
|
|
Camera enabled callback.
|
|
This will load the overrides.
|
|
"""
|
|
|
|
for address, value in overrides.items():
|
|
cam.oscClient.send_message(address, value)
|
|
|
|
with open('cameraOverrides.json', 'r', encoding='utf-8') as f:
|
|
overrides = json.loads(f.read())
|
|
|
|
client = udp_client.SimpleUDPClient('127.0.0.1', 9000, timeout=2.5)
|
|
dispatcher = Dispatcher()
|
|
camera = Camera(dispatcher, client, onCameraEnabled)
|
|
server = osc_server.ThreadingOSCUDPServer(('127.0.0.1', 9001), dispatcher, timeout=2.5)
|
|
|
|
try:
|
|
server.serve_forever() # Serve, queen 💅
|
|
except KeyboardInterrupt:
|
|
pass
|
|
|
|
camera.close()
|
|
server.server_close()
|
|
client.close()
|