IMHOTEP Framework
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
ViveControllerInputDevice.cs
1 using UnityEngine;
2 using UnityEngine.EventSystems;
3 using System.Collections;
4 using UI;
5 
7 
8  public InputDeviceManager.InputDeviceType getDeviceType ()
9  {
10  return InputDeviceManager.InputDeviceType.ViveController;
11  }
12 
13  private Vector2 texCoordDelta;
14 
15  private ButtonInfo buttonInfo = new ButtonInfo();
16  private Camera fakeCamera;
17 
18  public Ray createRay()
19  {
20  Ray ray;
21  ray = new Ray(this.gameObject.transform.position, this.gameObject.transform.forward);
22  return ray;
23  }
24 
25  public Vector2 getTexCoordMovement()
26  {
27  return texCoordDelta;
28  }
29  public Vector3 getMovement()
30  {
31  return positionDelta;
32  }
33 
34  public bool isLeftButtonDown()
35  {
36  return triggerPressed ();
37  }
38  public bool isRightButtonDown()
39  {
40  // Controller has no right mouse button, so return false:
41  return false;
42  }
43  public bool isMiddleButtonDown()
44  {
45  // Controller has no middle mouse button, so return false:
46  return false;
47  }
48 
49  // Use this for initialization
50  new public void Start () {
51  base.Start ();
52 
53  //register device
54  if (InputDeviceManager.instance != null)
55  {
56  InputDeviceManager.instance.registerInputDevice(this);
57  Debug.Log("Vive controller registered");
58  }
59 
60  fakeCamera = gameObject.AddComponent<Camera> () as Camera;
61  fakeCamera.enabled = false;
62  fakeCamera.nearClipPlane = 0.0001f;
63  }
64 
65  public ButtonInfo updateButtonInfo ()
66  {
67  buttonInfo.buttonStates [ButtonType.Trigger] = triggerButtonState;
68 
69  return buttonInfo;
70  }
71 
72 
73  public Camera getEventCamera() {
74  return fakeCamera;
75  }
76 
77  public Vector2 getTexCoordDelta() {
78  return texCoordDelta;
79  }
80  public Vector3 get3DDelta() {
81  return positionDelta;
82  }
83 
84  public void setTexCoordDelta( Vector2 delta ) {
85  texCoordDelta = delta;
86  }
87  public Vector2 getScrollDelta() {
88  return touchpadDelta;
89  }
90 }
Vector3 positionDelta
The movement of the controller since the previous frame in world space:
Definition: Controller.cs:56
bool triggerPressed()
Definition: Controller.cs:180