void populateMyTouch() { #if UNITY_EDITOR currentlyTouching = (Input.GetMouseButton(0) && !Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.LeftAlt)); touchDevice = (Input.GetKey(KeyCode.H)) ? EasyInputConstants.TOUCH_DEVICE.HMD : EasyInputConstants.TOUCH_DEVICE.MotionController; if (currentlyTouching) { if (!previousTouching) { //start of a touch (wasn't touching previous) puts in -1 to 1 range myTouch.originalTouchPosition.x = (((Input.mousePosition.x / (float)Screen.width) - .5f) * 2f); myTouch.originalTouchPosition.y = (((Input.mousePosition.y / (float)Screen.height) - .5f) * 2f); myTouch.currentTouchPosition.x = (((Input.mousePosition.x / (float)Screen.width) - .5f) * 2f); myTouch.currentTouchPosition.y = (((Input.mousePosition.y / (float)Screen.height) - .5f) * 2f); myTouch.currentTouchBeginTimestamp = Time.time; } else { //continue of touch puts in -1 to 1 range myTouch.currentTouchPosition.x = (((Input.mousePosition.x / (float)Screen.width) - .5f) * 2f); myTouch.currentTouchPosition.y = (((Input.mousePosition.y / (float)Screen.height) - .5f) * 2f); } } #endif #if !UNITY_EDITOR && UNITY_ANDROID if (isGearVR) { currentlyTouching = OVRInput.Get(OVRInput.Touch.PrimaryTouchpad); touchDevice = (OVRInput.GetActiveController() == OVRInput.Controller.LTrackedRemote || OVRInput.GetActiveController() == OVRInput.Controller.RTrackedRemote) ? EasyInputConstants.TOUCH_DEVICE.MotionController : EasyInputConstants.TOUCH_DEVICE.HMD; } if (currentlyTouching) { if (!previousTouching) { //start of a touch (wasn't touching previous) if (isGearVR) { myTouch.originalTouchPosition.x = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).x; myTouch.originalTouchPosition.y = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).y; myTouch.currentTouchPosition.x = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).x; myTouch.currentTouchPosition.y = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).y; myTouch.currentTouchBeginTimestamp = Time.time; } } else { //normal continue of touch if (isGearVR) { myTouch.currentTouchPosition.x = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).x; myTouch.currentTouchPosition.y = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).y; } } } #endif }
void Update() { currentDevice = EasyInputHelper.touchDevice; }