private void HandleDeviceInput(IVRModuleDeviceStateRW deviceState) { var leftPressed = Input.GetMouseButton(0); var rightPressed = Input.GetMouseButton(1); var midPressed = Input.GetMouseButton(2); deviceState.SetButtonPress(VRModuleRawButton.Trigger, leftPressed); deviceState.SetButtonTouch(VRModuleRawButton.Trigger, leftPressed); deviceState.SetAxisValue(VRModuleRawAxis.Trigger, leftPressed ? 1f : 0f); deviceState.SetButtonPress(VRModuleRawButton.Grip, midPressed); deviceState.SetButtonTouch(VRModuleRawButton.Grip, midPressed); deviceState.SetAxisValue(VRModuleRawAxis.CapSenseGrip, midPressed ? 1f : 0f); deviceState.SetButtonPress(VRModuleRawButton.Touchpad, rightPressed); deviceState.SetButtonPress(VRModuleRawButton.ApplicationMenu, IsMenuKeyDown()); deviceState.SetButtonTouch(VRModuleRawButton.ApplicationMenu, IsMenuKeyDown()); if (VIUSettings.simulateTrackpadTouch && IsShiftKeyPressed()) { deviceState.SetButtonTouch(VRModuleRawButton.Touchpad, true); deviceState.SetAxisValue(VRModuleRawAxis.TouchpadX, deviceState.GetAxisValue(VRModuleRawAxis.TouchpadX) + (Input.GetAxisRaw("Mouse X") * 0.1f)); deviceState.SetAxisValue(VRModuleRawAxis.TouchpadY, deviceState.GetAxisValue(VRModuleRawAxis.TouchpadY) + (Input.GetAxisRaw("Mouse Y") * 0.1f)); } else { deviceState.SetButtonTouch(VRModuleRawButton.Touchpad, rightPressed); deviceState.SetAxisValue(VRModuleRawAxis.TouchpadX, 0f); deviceState.SetAxisValue(VRModuleRawAxis.TouchpadY, 0f); } }
private void HandleDeviceInput(IVRModuleDeviceStateRW deviceState) { //var leftPressed = Input.GetMouseButton(0); //var rightPressed = Input.GetMouseButton(1); //var midPressed = Input.GetMouseButton(2); bool leftPressed; bool rightPressed; bool midPressed; if ((PlatformType)Enum.Parse(typeof(PlatformType), PlayerPrefs.GetString("CurrentPlateform", "PC")) == PlatformType.PC) { leftPressed = Input.GetMouseButton(0); rightPressed = Input.GetMouseButton(1); midPressed = Input.GetMouseButton(2); } else if ((PlatformType)Enum.Parse(typeof(PlatformType), PlayerPrefs.GetString("CurrentPlateform", "PC")) == PlatformType.zSpace) { ZCore _zCore = GameObject.FindObjectOfType <ZCore>(); midPressed = _zCore.IsTargetButtonPressed(ZCore.TargetType.Primary, 1); leftPressed = _zCore.IsTargetButtonPressed(ZCore.TargetType.Primary, 0); rightPressed = _zCore.IsTargetButtonPressed(ZCore.TargetType.Primary, 2); } else { leftPressed = Input.GetMouseButton(0); rightPressed = Input.GetMouseButton(1); midPressed = Input.GetMouseButton(2); } //Debug.LogError(leftPressed+"|" + midPressed + "|" + midPressed); deviceState.SetButtonPress(VRModuleRawButton.Trigger, leftPressed); deviceState.SetButtonTouch(VRModuleRawButton.Trigger, leftPressed); deviceState.SetAxisValue(VRModuleRawAxis.Trigger, leftPressed ? 1f : 0f); deviceState.SetButtonPress(VRModuleRawButton.Grip, midPressed); deviceState.SetButtonTouch(VRModuleRawButton.Grip, midPressed); deviceState.SetAxisValue(VRModuleRawAxis.CapSenseGrip, midPressed ? 1f : 0f); deviceState.SetButtonPress(VRModuleRawButton.Touchpad, rightPressed); deviceState.SetButtonPress(VRModuleRawButton.ApplicationMenu, IsMenuKeyDown()); deviceState.SetButtonTouch(VRModuleRawButton.ApplicationMenu, IsMenuKeyDown()); if (VIUSettings.simulateTrackpadTouch && IsShiftKeyPressed()) { deviceState.SetButtonTouch(VRModuleRawButton.Touchpad, true); deviceState.SetAxisValue(VRModuleRawAxis.TouchpadX, deviceState.GetAxisValue(VRModuleRawAxis.TouchpadX) + (Input.GetAxisRaw("Mouse X") * 0.1f)); deviceState.SetAxisValue(VRModuleRawAxis.TouchpadY, deviceState.GetAxisValue(VRModuleRawAxis.TouchpadY) + (Input.GetAxisRaw("Mouse Y") * 0.1f)); } else { deviceState.SetButtonTouch(VRModuleRawButton.Touchpad, rightPressed); deviceState.SetAxisValue(VRModuleRawAxis.TouchpadX, 0f); deviceState.SetAxisValue(VRModuleRawAxis.TouchpadY, 0f); } }
private void ApplyVirtualArmAndSimulateInput(IVRModuleDeviceStateRW ctrlState, IVRModuleDeviceStateRW headState, Vector3 handSideMultiplier) { if (!ctrlState.isConnected) { return; } if (!VIUSettings.waveVRAddVirtualArmTo3DoFController && !VIUSettings.simulateWaveVR6DofController) { return; } var deviceType = (int)s_index2type[ctrlState.deviceIndex]; if (Interop.WVR_GetDegreeOfFreedom((WVR_DeviceType)deviceType) != WVR_NumDoF.WVR_NumDoF_3DoF) { return; } if (VIUSettings.simulateWaveVR6DofController) { if (Input.GetKeyDown(KeyCode.Alpha1)) { s_simulationMode = Simulate6DoFControllerMode.KeyboardWASD; } if (Input.GetKeyDown(KeyCode.Alpha2)) { s_simulationMode = Simulate6DoFControllerMode.KeyboardModifierTrackpad; } if (Input.GetKeyDown(KeyCode.BackQuote)) { s_simulatedCtrlPosArray[deviceType] = Vector3.zero; } var deltaMove = Time.unscaledDeltaTime; var rotY = Quaternion.Euler(0f, ctrlState.rotation.eulerAngles.y, 0f); var moveForward = rotY * Vector3.forward; var moveRight = rotY * Vector3.right; switch (s_simulationMode) { case Simulate6DoFControllerMode.KeyboardWASD: { if (Input.GetKey(KeyCode.D)) { s_simulatedCtrlPosArray[deviceType] += moveRight * deltaMove; } if (Input.GetKey(KeyCode.A)) { s_simulatedCtrlPosArray[deviceType] -= moveRight * deltaMove; } if (Input.GetKey(KeyCode.E)) { s_simulatedCtrlPosArray[deviceType] += Vector3.up * deltaMove; } if (Input.GetKey(KeyCode.Q)) { s_simulatedCtrlPosArray[deviceType] -= Vector3.up * deltaMove; } if (Input.GetKey(KeyCode.W)) { s_simulatedCtrlPosArray[deviceType] += moveForward * deltaMove; } if (Input.GetKey(KeyCode.S)) { s_simulatedCtrlPosArray[deviceType] -= moveForward * deltaMove; } break; } case Simulate6DoFControllerMode.KeyboardModifierTrackpad: { float speedModifier = 2f; float x = ctrlState.GetAxisValue(VRModuleRawAxis.TouchpadX) * speedModifier; float y = ctrlState.GetAxisValue(VRModuleRawAxis.TouchpadY) * speedModifier; if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) { s_simulatedCtrlPosArray[deviceType] += x * moveRight * deltaMove; s_simulatedCtrlPosArray[deviceType] += y * moveForward * deltaMove; } if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { s_simulatedCtrlPosArray[deviceType] += x * moveRight * deltaMove; s_simulatedCtrlPosArray[deviceType] += y * Vector3.up * deltaMove; } break; } } } if (VIUSettings.waveVRAddVirtualArmTo3DoFController) { var neckPose = new RigidPose(s_simulatedCtrlPosArray[deviceType], Quaternion.identity) * GetNeckPose(headState.pose); ctrlState.position = GetControllerPositionWithVirtualArm(neckPose, ctrlState.rotation, handSideMultiplier); } else { ctrlState.position += s_simulatedCtrlPosArray[deviceType]; } }