diff --git a/joy360.py b/joy360.py new file mode 100644 index 0000000..af021da --- /dev/null +++ b/joy360.py @@ -0,0 +1,148 @@ +#!/bin/env python + +# Only really useful for VRChat joycon with Driver4VR + +import time +import collections +import itertools + + +import openvr + +from pyjoycon import JoyCon, get_R_id, get_L_id, ButtonEventJoyCon +import logging + +import threading + +import time +import pprint + +import vgamepad as vg + +gamepad = vg.VX360Gamepad() + + + +class VibrationReceiver(object): + + def __init__(self): + pass + + def poll(self,cons): + new_event = openvr.VREvent_t() + while openvr.VRSystem().pollNextEvent(new_event): + self.checkHaptics(new_event,cons) + + def checkHaptics(self, event, cons): + if event.eventType == openvr.VREvent_HapticVibration_t: + print("VREvent_HapticVibration_t????") + return + if event.eventType != openvr.VREvent_Input_HapticVibration: + return + role = openvr.VRSystem().getControllerRoleForTrackedDeviceIndex(event.data.hapticVibration.containerHandle) + fDurationSeconds = event.data.hapticVibration.fDurationSeconds + con=False + if role == openvr.TrackedControllerRole_RightHand: + print(" right controller trigger") + con=cons[1] + elif role == openvr.TrackedControllerRole_LeftHand: + print(" left controller trigger ") + con=cons[0] + else: + print("getControllerRoleForTrackedDeviceIndex=",role,"???") + if con: + con[2].rumble_simple() + con[4]=time.time()+max(min(fDurationSeconds,3),0) + +class VibeStatus(): + pass #TODO Send vibrate cmd every 0.5 seconds + +def handleVibe(con): + if not con[4]: + return + if time.time()