# How to use the SDK
# Example of use
There is a sample scene named HowToUse_SteamVR in the Assets/Sample/ folder. In this scene, button input generates vibration, joystick movement, and finger bending display.
This page uses this scene to demonstrate how to use the ContactGlove API.
# Access to ContactGlove API
From the object that ContactGloveManagerWithSteamVR.cs is attached to By getting the component, you can access the ContactGlove API.
IContactGloveManager gloveManager = GetComponent<IContactGloveManager>();
In the example scene, an object named ContactGloveManage ContactGloveManagerWithSteamVR is attached.
In HowToUse.cs attached to an object named HowToUse , I am getting the IContactGloveManager inside the Start function
void Start()
{
this.cgManager = contactGloveObj.GetComponent<IContactGloveManager>();
}
Through the IContactGloveManager obtained in this way You have access to the ContactGlove API.
# Occurrence of vibration
In the HowToUse scene, keyboard input causes vibration.
void Update()
{
if (Input.GetKeyDown(KeyCode.F))
{
cgManager.SetVibration(HandSides.Left, 0.2f, 160.0f, 0.5f);
}
if (Input.GetKeyDown(KeyCode.J))
{
cgManager.SetVibration(HandSides.Right, 0.2f, 160.0f, 0.5f);
}
}
# Get the amount of finger joint rotation
float flex = cgManager.GetFingerRotationAmplitude(HandSides.Left, FingerRotationAmplitude_e.IndexDistal);
The above code obtains the amount of rotation of the first joint of the index finger of the left hand.
# controller input
Code that generates vibration when there is a specific controller input.
void Start()
{
this.cgManager.AddOnControllerInputHandler(HandSides.Left, ControllerBoolInputType.A, () =>
{
cgManager.SetVibration(HandSides.Left, 0.5f, 160, 0.1f);
});
}
The above code generates vibration for 0.1 seconds when the A button on the left hand is pressed.
And if you want to get the controller input value, you can do it like this:
bool leftA = cgManager.GetControllerInput(HandSides.Left, ControllerBoolInputType.A);
float rightX = cgManager.GetControllerInput(HandSides.Right, ControllerFloatInputType.JoystickX);
For more detailed usage, please refer to Documentation.
← Setup Documentation →