-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTouchpad.cs
49 lines (43 loc) · 1.67 KB
/
Touchpad.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Valve.VR;
public class Touchpad : MonoBehaviour
{
SteamVR_Controller.Device device;
SteamVR_TrackedObject trackedObject;
public Slider sliderX, sliderY;
void Start()
{
trackedObject = GetComponent<SteamVR_TrackedObject>();
device = SteamVR_Controller.Input((int)trackedObject.index);
}
void FixedUpdate()
{
Debug.Log("X Axis " + device.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).x);
Debug.Log("Y Axis " + device.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).y);
sliderX.value = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).x;
sliderY.value = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).y;
if(device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && device.GetAxis(Valve.VR.EVRButtonId
.k_EButton_Axis0).y > 0.8f)
{
Debug.Log("Dpad Up...!!!");
}
if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && device.GetAxis(Valve.VR.EVRButtonId
.k_EButton_Axis0).y < -0.8f)
{
Debug.Log("Dpad Down...!!!");
}
if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && device.GetAxis(Valve.VR.EVRButtonId
.k_EButton_Axis0).x < -0.8f)
{
Debug.Log("Dpad Left...!!!");
}
if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && device.GetAxis(Valve.VR.EVRButtonId
.k_EButton_Axis0).x > 0.8f)
{
Debug.Log("Dpad Right...!!!");
}
}
}