// Update is called once per frame void Update() { currRate += Time.deltaTime; if (currRate > rate) { currRate = 0.0f; int wandKeyNum = InputKey.WandTriggerStrong - InputKey.WandMenu + 1; for (int i = 0; i < 2; i++) { InputType type = (InputType)i; for (int j = 0; j < (int)wandKeyNum; j++) { InputKey key = (InputKey)j; bool keystatus = TGInput.GetKey(type, key); if (keystatus) { ThreeGlassesUtils.Log("type=" + (InputType)i + "key=" + key); } } // ThreeGlassesUtils.Log("type=" + (InputType)i // + " trigger process=" + TGInput.GetTriggerProcess(type) // + " stick=" + TGInput.GetStick(type)); ThreeGlassesUtils.Log("type=" + (InputType)i + " trigger position=" + TGInput.GetPosition(type) + " rotation" + TGInput.GetRotation(type)); } } //transform.position = TGInput.GetPosition(InputType.LeftWand); transform.rotation = TGInput.GetRotation(InputType.RightWand); }
public ButtonEvent(uint status, byte trigger_value, byte[] stick, ThreeGlassesInterfaces.LeftOrRight LR) { KeyStatus = status; LeftOrRight = LR; MenuButton = (status & ButtonMask.MenuButton) == ButtonMask.MenuButton; BButton = (status & ButtonMask.BButton) == ButtonMask.BButton; LeftHandle = (status & ButtonMask.LeftHandle) == ButtonMask.LeftHandle; RightHandle = (status & ButtonMask.RightHandle) == ButtonMask.RightHandle; Trigger = (status & ButtonMask.Trigger) == ButtonMask.Trigger; TriggerPressEnd = (status & ButtonMask.TriggerPressEnd) == ButtonMask.TriggerPressEnd; StickXValue = 0.5f; StickYValue = 0.5f; if (LR == ThreeGlassesInterfaces.LeftOrRight.Left) { RefreshOnEvents(L_OLD_KEY_STATUS); L_OLD_KEY_STATUS = status; } else { RefreshOnEvents(R_OLD_KEY_STATUS); R_OLD_KEY_STATUS = status; } TriggerValue = trigger_value / (float)TriggerConst.MAX_VALUE; StickXValue = ThreeGlassesUtils.Lerp(0, 1.0f, stick[0] / (float)TriggerConst.MAX_VALUE); StickYValue = ThreeGlassesUtils.Lerp(0, 1.0f, stick[1] / (float)TriggerConst.MAX_VALUE); TriggerRawValue = trigger_value; StickXRawValue = stick[0]; StickYRawValue = stick[1]; }
void OnWandChange(ThreeGlassesWand.Wand pack) { // you can also get the wand struct info here // must bind ThreeGlassesWandBind script ThreeGlassesUtils.Log("wand=" + pack); }
// Update is called once per frame void Update() { ThreeGlassesUtils.Log("HMD's name is " + TGInput.GetHMDName()); ThreeGlassesUtils.Log("HMD's touchpad " + TGInput.GetHMDTouchPad()); if (TGInput.GetKey(InputType.HMD, InputKey.HmdMenu)) { ThreeGlassesUtils.Log("HMD's key menu is pressed "); } if (TGInput.GetKey(InputType.HMD, InputKey.HmdExit)) { ThreeGlassesUtils.Log("HMD's key exit is pressed "); } for (int i = (int)InputKey.WandMenu; i <= (int)InputKey.WandTriggerStrong; i++) { if (TGInput.GetKey(InputType.LeftWand, (InputKey)i)) { ThreeGlassesUtils.Log((InputKey)i + " is pressed"); } } // by get way if (useType == UseType.UseGet) { // set transform transform.localPosition = origin + TGInput.GetPosition(inputType) * moveScale; transform.localRotation = TGInput.GetRotation(inputType); float intensity = TGInput.GetTriggerProcess(inputType); mat.SetColor("_Color", new Color(intensity, intensity, intensity, 1)); // change bullet type if (TGInput.GetKey(inputType, InputKey.WandLeftSide)) { bulletType = (bulletType + 3) % 4; } if (TGInput.GetKey(inputType, InputKey.WandRightSide)) { bulletType = (++bulletType) % 4; } // create a bullet currRate += Time.deltaTime; if (currRate > fireRate) { currRate -= fireRate; if (TGInput.GetKey(inputType, InputKey.WandTriggerStrong)) { GameObject bullet = GameObject.CreatePrimitive((PrimitiveType)bulletType); bullet.transform.position = firePos.position; bullet.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); Rigidbody rb = bullet.AddComponent <Rigidbody>(); rb.AddForce(transform.forward * bulletSpeed, ForceMode.VelocityChange); Destroy(bullet, 10.0f); } } } // move control if (headDisplay != null) { Vector2 dir = TGInput.GetStick(inputType); if (inputType == InputType.LeftWand) { dir = dir * moveSpeed * Time.deltaTime; headDisplay.Translate(new Vector3(dir.x, 0, dir.y)); } else if (inputType == InputType.RightWand) { headDisplay.Rotate(headDisplay.up, dir.x * rotateSpeed * Time.deltaTime); headDisplay.Rotate(headDisplay.right, -dir.y * rotateSpeed * Time.deltaTime); } } }