Ejemplo n.º 1
0
    // Token: 0x0600570A RID: 22282 RVA: 0x001DFABC File Offset: 0x001DDEBC
    public override void GenerateHapticEvent(VRCTracking.ID id, float duration, float amplitude, float frequency)
    {
        CVRSystem system = OpenVR.System;

        if (system == null)
        {
            return;
        }
        ETrackedControllerRole unDeviceType = ETrackedControllerRole.Invalid;

        if (id != VRCTracking.ID.HandTracker_LeftWrist)
        {
            if (id == VRCTracking.ID.HandTracker_RightWrist)
            {
                unDeviceType = ETrackedControllerRole.RightHand;
            }
        }
        else
        {
            unDeviceType = ETrackedControllerRole.LeftHand;
        }
        VRCTrackingTouch.HapticWave hapticWave = default(VRCTrackingTouch.HapticWave);
        hapticWave.controllerIndex = system.GetTrackedDeviceIndexForControllerRole(unDeviceType);
        hapticWave.duration        = duration;
        hapticWave.strength        = Mathf.Clamp01(amplitude);
        hapticWave.frequency       = frequency;
        if (this.currentHapticLoop[(int)((UIntPtr)hapticWave.controllerIndex)] != null)
        {
            base.StopCoroutine(this.currentHapticLoop[(int)((UIntPtr)hapticWave.controllerIndex)]);
        }
        this.currentHapticLoop[(int)((UIntPtr)hapticWave.controllerIndex)] = base.StartCoroutine("HapticLoop", hapticWave);
    }
Ejemplo n.º 2
0
    // Token: 0x06005706 RID: 22278 RVA: 0x001DF8A4 File Offset: 0x001DDCA4
    private IEnumerator HapticLoop(VRCTrackingTouch.HapticWave wave)
    {
        float timeElapsed     = 0f;
        float cycleWait       = 0.005f;
        float pulseLengthUSec = wave.strength * 3998f + 1f;
        float pulseLength     = pulseLengthUSec / 1000000f;
        float period          = 0.5f / wave.frequency;

        if (period < pulseLength + cycleWait)
        {
            period = pulseLength + cycleWait;
        }
        else
        {
            cycleWait = period - pulseLength;
        }
        while (timeElapsed < wave.duration * 0.5f)
        {
            Debug.LogWarning("Touch Controller Not Fully Implemented");
        }
        this.currentHapticLoop[(int)((UIntPtr)wave.controllerIndex)] = null;
        yield return(null);

        yield break;
    }