how to implement oculus vr haptic feedback

I want to implement haptic feedback for our oculus vr game, but I don’t understand how. I went to the documentation which was confusing. A lot of those types aren’t recognised. The following code sample is provided by the document.

uint8_t amplitude = (uint8_t)round(handTrigger[t] * 255);

    result = ovr_GetControllerVibrationState(Session, touchController[t], &state);
    if (result != ovrSuccess || state.SamplesQueued >= kLowLatencyBufferSizeInSamples)
    {
        DefaultChannel.LogWarningF("%s Haptics skipped. Queue size %d", kTouchStr[t], state.SamplesQueued);
        continue;
    }

    for (int32_t i = 0; i < kLowLatencyBufferSizeInSamples; ++i)
        samples.push_back(amplitude);

    if (samples.size() > 0)
    {
        ovrHapticsBuffer buffer;
        buffer.SubmitMode = ovrHapticsBufferSubmit_Enqueue;
        buffer.SamplesCount = (uint32_t)samples.size();
        buffer.Samples = samples.data();
        result = ovr_SubmitControllerVibration(Session, touchController[t], &buffer);
        if (result != ovrSuccess)
        {
            // Something bad happened
            DefaultChannel.LogErrorF("%s: Haptics submit failed %d", kTouchStr[t], result);
        }
    }

Could someone please explain to me how to implement this?

This snippet might help:

public enum VibrationForce
{
    Light,
    Medium,
    Hard,
}


public class OculusHaptics : MonoBehaviour
{

    [SerializeField]
    OVRInput.Controller controllerMask;

    private OVRHapticsClip clipLight;
    private OVRHapticsClip clipMedium;
    private OVRHapticsClip clipHard;

    public  float lowViveHaptics { get; private set; }
    public  float mediumViveHaptics { get; private set; }
    public float hardViveHaptics { get; private set; }

    
    private void Start()
    {
        InitializeOVRHaptics();
    }

    private void InitializeOVRHaptics()
    {
        
        int cnt = 10;
        clipLight = new OVRHapticsClip(cnt);
        clipMedium = new OVRHapticsClip(cnt);
        clipHard = new OVRHapticsClip(cnt);
        for (int i = 0; i < cnt; i++)
        {
            clipLight.Samples *= i % 2 == 0 ? (byte)0 : (byte)45;*

clipMedium.Samples = i % 2 == 0 ? (byte)0 : (byte)100;
clipHard.Samples = i % 2 == 0 ? (byte)0 : (byte)180;
}

clipLight = new OVRHapticsClip(clipLight.Samples, clipLight.Samples.Length);
clipMedium = new OVRHapticsClip(clipMedium.Samples, clipMedium.Samples.Length);
clipHard = new OVRHapticsClip(clipHard.Samples, clipHard.Samples.Length);
}

void OnEnable()
{
InitializeOVRHaptics();
}

public void Vibrate(VibrationForce vibrationForce)
{
var channel = OVRHaptics.RightChannel;
if (controllerMask == OVRInput.Controller.LTouch)
channel = OVRHaptics.LeftChannel;

switch (vibrationForce)
{
case VibrationForce.Light:
channel.Preempt(clipLight);
break;
case VibrationForce.Medium:
channel.Preempt(clipMedium);
break;
case VibrationForce.Hard:
channel.Preempt(clipHard);
break;
}
}

public IEnumerator VibrateTime(VibrationForce force, float time)
{
forcedHaptic = true;
var channel = OVRHaptics.RightChannel;
if (controllerMask == OVRInput.Controller.LTouch)
channel = OVRHaptics.LeftChannel;

for (float t = 0; t <= time; t += Time.deltaTime)
{
switch (force)
{
case VibrationForce.Light:
channel.Queue(clipLight);
break;
case VibrationForce.Medium:
channel.Queue(clipMedium);
break;
case VibrationForce.Hard:
channel.Queue(clipHard);
break;
}
}
yield return new WaitForSeconds(time);
channel.Clear();
forcedHaptic = false;
yield return null;

}
Attach it to the Controller Anchor and set it accordingly (Ltouch or RTouch), then just call the methods Vibrate or the coroutine VibrateTime.