private void SendTrackingEvents(OVRInput.Controller ovrController, int ovrIndex, int deviceIndex) { if (!OVRInput.GetControllerPositionTracked(ovrController)) { return; } var localPosition = OVRInput.GetLocalControllerPosition(ovrController); var localRotation = OVRInput.GetLocalControllerRotation(ovrController); if (localPosition == m_LastPositionValues[ovrIndex] && localRotation == m_LastRotationValues[ovrIndex]) { return; } var inputEvent = InputSystem.CreateEvent <VREvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = deviceIndex; inputEvent.localPosition = localPosition; inputEvent.localRotation = localRotation; m_LastPositionValues[ovrIndex] = inputEvent.localPosition; m_LastRotationValues[ovrIndex] = inputEvent.localRotation; InputSystem.QueueEvent(inputEvent); }
private void SendAxisEvents(int steamDeviceIndex, int deviceIndex) { int a = 0; for (int axis = (int)EVRButtonId.k_EButton_Axis0; axis <= (int)EVRButtonId.k_EButton_Axis4; ++axis) { Vector2 axisVec = SteamVR_Controller.Input(steamDeviceIndex).GetAxis((EVRButtonId)axis); for (XorY xy = XorY.X; (int)xy <= (int)XorY.Y; xy++, a++) { var value = xy == XorY.X ? axisVec.x : axisVec.y; const float kDeadZone = 0.05f; if (Mathf.Abs(value) < kDeadZone) { value = 0f; } if (Mathf.Approximately(m_LastAxisValues[steamDeviceIndex, a], value)) { continue; } var inputEvent = InputSystem.CreateEvent <GenericControlEvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = deviceIndex; inputEvent.controlIndex = a; inputEvent.value = value; m_LastAxisValues[steamDeviceIndex, a] = inputEvent.value; InputSystem.QueueEvent(inputEvent); } } }
private void SendButtonEvents(int steamDeviceIndex, int deviceIndex) { for (int i = 0; i < s_EnumValues.Length; i++) { var button = s_EnumValues[i]; // Don't double count the trigger if (button == EVRButtonId.k_EButton_SteamVR_Trigger) { continue; } var isDown = SteamVR_Controller.Input(steamDeviceIndex).GetPressDown(button); var isUp = SteamVR_Controller.Input(steamDeviceIndex).GetPressUp(button); var value = isDown ? 1.0f : 0.0f; var controlIndex = axisCount + (int)button; if (Mathf.Approximately(m_LastAxisValues[steamDeviceIndex, controlIndex], value)) { continue; } if (isDown || isUp) { var inputEvent = InputSystem.CreateEvent <GenericControlEvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = deviceIndex; inputEvent.controlIndex = controlIndex; inputEvent.value = value; m_LastAxisValues[steamDeviceIndex, controlIndex] = value; InputSystem.QueueEvent(inputEvent); } } }
void SendAxisEvents(VRInputDevice.Handedness hand, int deviceIndex) { for (var axis = 0; axis < k_AxisCount; ++axis) { float value; if (GetAxis(hand, (VRInputDevice.VRControl)axis, out value)) { if (Mathf.Approximately(m_LastAxisValues[(int)hand, axis], value)) { continue; } if (Mathf.Abs(value) < k_DeadZone) { value = 0; } var inputEvent = InputSystem.CreateEvent <GenericControlEvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = deviceIndex; inputEvent.controlIndex = axis; inputEvent.value = value; m_LastAxisValues[(int)hand, axis] = inputEvent.value; InputSystem.QueueEvent(inputEvent); } } }
private void SendButtonEvents() { for (int device = 0; device < controllerCount; ++device) { for (int btn = 0; btn < buttonCount; ++btn) { bool keyDown = UnityEngine.VR.InputTracking.GetKeyDown(device, btn); bool keyUp = UnityEngine.VR.InputTracking.GetKeyUp(device, btn); if (keyDown || keyUp) { var inputEvent = InputSystem.CreateEvent <GenericControlEvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = device; inputEvent.controlIndex = axisCount + btn; inputEvent.value = keyDown ? 1.0f : 0.0f; InputSystem.QueueEvent(inputEvent); } //bool keyDown = UnityEngine.VR.InputTracking.GetKeyDown(device, btn); //bool keyUp = UnityEngine.VR.InputTracking.GetKeyUp(device, btn); //if (keyDown || keyUp) //{ // var inputEvent = InputSystem.CreateEvent<KeyboardEvent>(); // inputEvent.deviceType = typeof(VRInputDevice); // inputEvent.deviceIndex = device; // inputEvent.key = (UnityEngine.KeyCode)btn; // inputEvent.isDown = keyDown; // InputSystem.QueueEvent(inputEvent); //} } } }
static void RecordJsonTest4() { //EvrVCR.FindActiveProxy(); Debug.Log("test start"); var input = InputSystem.CreateEvent <GenericControlEvent>(); input.time = 4.20f; input.deviceIndex = 3; input.value = 0.666f; input.controlIndex = 1; input.deviceType = typeof(VRInputDevice); var vrinput = InputSystem.CreateEvent <VREvent>(); vrinput.time = 6.66f; vrinput.deviceIndex = 3; vrinput.localPosition = new Vector3(0f, 1f, 0.5f); vrinput.localRotation = new Quaternion(0f, 0.5f, 1f, -0.5f); vrinput.deviceType = typeof(VRInputDevice); EvrVCR.RecordInput(input); EvrVCR.RecordInput(vrinput); EvrVCR.tape.label = "DEMO TAPE"; Debug.Log("pre-save"); EvrVCR.tape.SaveTapeJson(); }
private void SendAxisEvents(int steamDeviceIndex, int deviceIndex) { int a = 0; for (int axis = (int)EVRButtonId.k_EButton_Axis0; axis <= (int)EVRButtonId.k_EButton_Axis4; ++axis) { Vector2 axisVec = SteamVR_Controller.Input(steamDeviceIndex).GetAxis((EVRButtonId)axis); for (XorY xy = XorY.X; (int)xy <= (int)XorY.Y; xy++, a++) { var inputEvent = InputSystem.CreateEvent <GenericControlEvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = deviceIndex; inputEvent.controlIndex = a; inputEvent.value = xy == XorY.X ? axisVec.x : axisVec.y; if (Mathf.Approximately(m_LastAxisValues[steamDeviceIndex, a], inputEvent.value)) { //TODO Does continue need to be commented out for some reason? //continue; } m_LastAxisValues[steamDeviceIndex, a] = inputEvent.value; InputSystem.QueueEvent(inputEvent); } } }
void SendMoveEvent() { if (m_Ignore) { return; } var deltaX = Input.GetAxis("Mouse X"); var deltaY = Input.GetAxis("Mouse Y"); var deltaZero = (deltaX == 0.0f && deltaY == 0.0f); if (deltaZero && m_HaveSentResetEvent) { return; } var inputEvent = InputSystem.CreateEvent <PointerMoveEvent>(); inputEvent.deviceType = typeof(Mouse); inputEvent.deviceIndex = 0; inputEvent.delta = new Vector3(deltaX, deltaY, 0.0f); inputEvent.position = Input.mousePosition; InputSystem.QueueEvent(inputEvent); if (deltaZero) { m_HaveSentResetEvent = true; } else { m_HaveSentResetEvent = false; } }
private void SendButtonEvents(int sixenseDeviceIndex, int deviceIndex) { var controller = SixenseInput.Controllers[sixenseDeviceIndex]; foreach (SixenseButtons button in Enum.GetValues(typeof(SixenseButtons))) { bool isDown = controller.GetButtonDown(button); bool isUp = controller.GetButtonUp(button); if (isDown || isUp) { int buttonIndex = GetButtonIndex(button); if (buttonIndex >= 0) { var inputEvent = InputSystem.CreateEvent <GenericControlEvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = deviceIndex; inputEvent.controlIndex = buttonIndex; inputEvent.value = isDown ? 1.0f : 0.0f; InputSystem.QueueEvent(inputEvent); } } } }
private void SendTouchEvent(UnityEngine.InputNew.Touch touch) { var inputEvent = InputSystem.CreateEvent <TouchEvent>(); inputEvent.deviceType = typeof(Touchscreen); inputEvent.deviceIndex = 0; inputEvent.touch = touch; InputSystem.QueueEvent(inputEvent); }
void SendClickEvent(PointerControl controlIndex, bool clicked) { ////REVIEW: should this be a pointer-specific event type? var inputEvent = InputSystem.CreateEvent <GenericControlEvent>(); inputEvent.deviceType = typeof(Mouse); inputEvent.deviceIndex = 0; inputEvent.controlIndex = (int)controlIndex; inputEvent.value = clicked ? 1.0f : 0.0f; InputSystem.QueueEvent(inputEvent); }
void SendKeyboardEvent(KeyCode key, bool isDown) { var inputEvent = InputSystem.CreateEvent <KeyboardEvent>(); inputEvent.deviceType = typeof(Keyboard); inputEvent.deviceIndex = 0; inputEvent.key = key; inputEvent.isDown = isDown; ////TODO: modifiers InputSystem.QueueEvent(inputEvent); }
private void SendEvent(int deviceIndex, int controlIndex, float value) { if (value == m_LastValues[deviceIndex, controlIndex]) { return; } m_LastValues[deviceIndex, controlIndex] = value; var inputEvent = InputSystem.CreateEvent <GenericControlEvent>(); inputEvent.deviceType = typeof(Gamepad); inputEvent.deviceIndex = deviceIndex; inputEvent.controlIndex = controlIndex; inputEvent.value = value; InputSystem.QueueEvent(inputEvent); }
private void SendButtonEvents(int steamDeviceIndex, int deviceIndex) { foreach (EVRButtonId button in Enum.GetValues(typeof(EVRButtonId))) { bool isDown = SteamVR_Controller.Input(steamDeviceIndex).GetPressDown(button); bool isUp = SteamVR_Controller.Input(steamDeviceIndex).GetPressUp(button); if (isDown || isUp) { var inputEvent = InputSystem.CreateEvent <GenericControlEvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = deviceIndex; inputEvent.controlIndex = axisCount + (int)button; inputEvent.value = isDown ? 1.0f : 0.0f; InputSystem.QueueEvent(inputEvent); } } }
private void SendAxisEvents(int sixenseDeviceIndex, int deviceIndex) { for (var axis = 0; axis < kAxisCount; ++axis) { var inputEvent = InputSystem.CreateEvent <GenericControlEvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = deviceIndex; inputEvent.controlIndex = axis; inputEvent.value = GetAxis(sixenseDeviceIndex, (VRInputDevice.VRControl)axis); if (Mathf.Approximately(m_LastAxisValues[sixenseDeviceIndex, axis], inputEvent.value)) { continue; } m_LastAxisValues[sixenseDeviceIndex, axis] = inputEvent.value; InputSystem.QueueEvent(inputEvent); } }
void SendButtonEvents(VRInputDevice.Handedness hand, int deviceIndex) { foreach (VRInputDevice.VRControl button in k_Buttons) { var axis = GetButtonAxis(hand, button); bool isDown = UnityEngine.Input.GetButtonDown(axis); bool isUp = UnityEngine.Input.GetButtonUp(axis); if (isDown || isUp) { var inputEvent = InputSystem.CreateEvent <GenericControlEvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = deviceIndex; inputEvent.controlIndex = (int)button; inputEvent.value = isDown ? 1.0f : 0.0f; InputSystem.QueueEvent(inputEvent); } } }
private void SendTrackingEvents() { for (int device = 0; device < controllerCount; ++device) { var inputEvent = InputSystem.CreateEvent <VREvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = device; inputEvent.localPosition = UnityEngine.VR.InputTracking.GetLocalPosition((VRNode)device); inputEvent.localRotation = UnityEngine.VR.InputTracking.GetLocalRotation((VRNode)device); if (inputEvent.localPosition == m_LastPositionValues[device] && inputEvent.localRotation == m_LastRotationValues[device]) { continue; } m_LastPositionValues[device] = inputEvent.localPosition; m_LastRotationValues[device] = inputEvent.localRotation; InputSystem.QueueEvent(inputEvent); } }
private void SendTrackingEvents(int sixenseDeviceIndex, int deviceIndex) { var controller = SixenseInput.Controllers[sixenseDeviceIndex]; var inputEvent = InputSystem.CreateEvent <VREvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = deviceIndex; inputEvent.localPosition = (m_RotationOffset * controller.Position * kHydraUnits) + m_ControllerOffsets[sixenseDeviceIndex]; inputEvent.localRotation = m_RotationOffset * controller.Rotation; if (inputEvent.localPosition == m_LastPositionValues[sixenseDeviceIndex] && inputEvent.localRotation == m_LastRotationValues[sixenseDeviceIndex]) { return; } m_LastPositionValues[sixenseDeviceIndex] = inputEvent.localPosition; m_LastRotationValues[sixenseDeviceIndex] = inputEvent.localRotation; InputSystem.QueueEvent(inputEvent); }
private void SendTrackingEvents(int steamDeviceIndex, int deviceIndex, TrackedDevicePose_t[] poses) { var inputEvent = InputSystem.CreateEvent <VREvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = deviceIndex; var pose = new SteamVR_Utils.RigidTransform(poses[steamDeviceIndex].mDeviceToAbsoluteTracking); inputEvent.localPosition = pose.pos; inputEvent.localRotation = pose.rot; if (inputEvent.localPosition == m_LastPositionValues[steamDeviceIndex] && inputEvent.localRotation == m_LastRotationValues[steamDeviceIndex]) { return; } m_LastPositionValues[steamDeviceIndex] = inputEvent.localPosition; m_LastRotationValues[steamDeviceIndex] = inputEvent.localRotation; InputSystem.QueueEvent(inputEvent); }
private void SendButtonEvents(OVRInput.Controller ovrController, int deviceIndex) { foreach (OVRInput.Button button in Enum.GetValues(typeof(OVRInput.Button))) { int buttonIndex = GetButtonIndex(button); if (buttonIndex >= 0) { bool isDown = OVRInput.GetDown(button, ovrController); bool isUp = OVRInput.GetUp(button, ovrController); if (isDown || isUp) { var inputEvent = InputSystem.CreateEvent <GenericControlEvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = deviceIndex; inputEvent.controlIndex = buttonIndex; inputEvent.value = isDown ? 1.0f : 0.0f; InputSystem.QueueEvent(inputEvent); } } } }
private void SendAxisEvents() { for (int device = 0; device < controllerCount; ++device) { for (int axis = 0; axis < axisCount; ++axis) { var inputEvent = InputSystem.CreateEvent <GenericControlEvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = device; inputEvent.controlIndex = axis; inputEvent.value = UnityEngine.VR.InputTracking.GetAxis(device, axis); if (Mathf.Approximately(m_LastAxisValues[device, axis], inputEvent.value)) { continue; } m_LastAxisValues[device, axis] = inputEvent.value; Debug.Log("Axis event: " + inputEvent); InputSystem.QueueEvent(inputEvent); } } }
void SendTrackingEvents(VRInputDevice.Handedness hand, int deviceIndex) { #pragma warning disable 618 var node = hand == VRInputDevice.Handedness.Left ? XRNode.LeftHand : XRNode.RightHand; var localPosition = InputTracking.GetLocalPosition(node); var localRotation = InputTracking.GetLocalRotation(node); #pragma warning restore 618 if (localPosition == m_LastPositionValues[(int)hand] && localRotation == m_LastRotationValues[(int)hand]) { return; } var inputEvent = InputSystem.CreateEvent <VREvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = deviceIndex; inputEvent.localPosition = localPosition; inputEvent.localRotation = localRotation; m_LastPositionValues[(int)hand] = inputEvent.localPosition; m_LastRotationValues[(int)hand] = inputEvent.localRotation; InputSystem.QueueEvent(inputEvent); }
private void SendAxisEvents(OVRInput.Controller controller, int ovrIndex, int deviceIndex) { for (var axis = 0; axis < k_AxisCount; ++axis) { float value; if (GetAxis(controller, (VRInputDevice.VRControl)axis, out value)) { if (Mathf.Approximately(m_LastAxisValues[ovrIndex, axis], value)) { continue; } var inputEvent = InputSystem.CreateEvent <GenericControlEvent>(); inputEvent.deviceType = typeof(VRInputDevice); inputEvent.deviceIndex = deviceIndex; inputEvent.controlIndex = axis; inputEvent.value = value; m_LastAxisValues[ovrIndex, axis] = inputEvent.value; InputSystem.QueueEvent(inputEvent); } } }