/// <summary> /// Obtains the correct trackpad and trigger button values directly from VRPN and sets /// ClusterInput entries to correct value. Implemented because initial values /// from ClusterInput are incorrect. /// </summary> private static System.Collections.IEnumerator endOfFrameForMaster() { yield return new WaitForEndOfFrame(); //Trackpad button updates ClusterInput.SetButton("leftTrackpad", VRPN.vrpnButton("CC_FLAT_WAND0@" + CC_CONFIG.serverIP, 32)); ClusterInput.SetButton("rightTrackpad", VRPN.vrpnButton("CC_FLAT_WAND1@" + CC_CONFIG.serverIP, 32)); //Trackpad axis updates ClusterInput.SetAxis("leftXAxis", (float)VRPN.vrpnAnalog("CC_FLAT_WAND0@" + CC_CONFIG.serverIP, 0)); ClusterInput.SetAxis("leftYAxis", (float)VRPN.vrpnAnalog("CC_FLAT_WAND0@" + CC_CONFIG.serverIP, 1)); ClusterInput.SetAxis("rightXAxis", (float)VRPN.vrpnAnalog("CC_FLAT_WAND1@" + CC_CONFIG.serverIP, 0)); ClusterInput.SetAxis("rightYAxis", (float)VRPN.vrpnAnalog("CC_FLAT_WAND1@" + CC_CONFIG.serverIP, 1)); //Trigger button updates ClusterInput.SetButton("leftTrigger", VRPN.vrpnButton("CC_FLAT_WAND0@" + CC_CONFIG.serverIP, 33)); ClusterInput.SetButton("rightTrigger", VRPN.vrpnButton("CC_FLAT_WAND1@" + CC_CONFIG.serverIP, 33)); //Trigger axis updates ClusterInput.SetAxis("leftTriggerAxis", (float)VRPN.vrpnAnalog("CC_FLAT_WAND0@" + CC_CONFIG.serverIP, 2)); ClusterInput.SetAxis("rightTriggerAxis", (float)VRPN.vrpnAnalog("CC_FLAT_WAND1@" + CC_CONFIG.serverIP, 2)); }
// Update is called once per frame void Update() { if (ClusterNetwork.IsMasterOfCluster()) { Vector3 mousepos = Input.mousePosition; mousepos.x /= Screen.width; mousepos.y /= Screen.height; ClusterInput.SetAxis("MouseTestX", mousepos.x); ClusterInput.SetAxis("MouseTestY", mousepos.y); Debug.Log("SetAxis to" + mousepos.ToString()); } Vector2 pos = new Vector2(); pos.x = ClusterInput.GetAxis("MouseTestX"); pos.y = ClusterInput.GetAxis("MouseTestY"); this.transform.position = new Vector3(pos.x, pos.y, 5.0f); Debug.Log("getAxis" + pos.ToString()); }
public void SetValue(float f) { ClusterInput.SetAxis(inputName, f); }