// Update is called once per frame void Update() { #if UNITY_ANDROID if (controllerlink.neoserviceStarted) { if (controllerlink.controller0Connected) { var pose0 = controllerlink.GetCvControllerPoseData(0); controllerlink.Controller0.Rotation = new Quaternion(pose0[0], pose0[1], pose0[2], pose0[3]); controllerlink.Controller0.Position = new Vector3(pose0[4] / 1000.0f, pose0[5] / 1000.0f, -pose0[6] / 1000.0f); var key0 = controllerlink.GetCvControllerKeyData(0); controllerlink.Controller0.TouchPadPosition = new Vector2(key0[0], key0[1]); SetSwipeData(controllerlink.Controller0); SetTouchPadClick(controllerlink.Controller0); TransformData(controllerlink.Controller0.HomeKey, key0[2]); TransformData(controllerlink.Controller0.AppKey, key0[3]); TransformData(controllerlink.Controller0.TouchKey, key0[4]); TransformData(controllerlink.Controller0.VolumeUpKey, key0[5]); TransformData(controllerlink.Controller0.VolumeDownKey, key0[6]); controllerlink.Controller0.TriggerNum = key0[7]; SetTriggerClick(controllerlink.Controller0.TriggerKey, key0[7]); controllerlink.Controller0.Battery = key0[8]; } if (controllerlink.controller1Connected) { var pose1 = controllerlink.GetCvControllerPoseData(1); controllerlink.Controller1.Rotation = new Quaternion(pose1[0], pose1[1], pose1[2], pose1[3]); controllerlink.Controller1.Position = new Vector3(pose1[4] / 1000.0f, pose1[5] / 1000.0f, -pose1[6] / 1000.0f); var key1 = controllerlink.GetCvControllerKeyData(1); controllerlink.Controller1.TouchPadPosition = new Vector2(key1[0], key1[1]); SetSwipeData(controllerlink.Controller1); SetTouchPadClick(controllerlink.Controller1); TransformData(controllerlink.Controller1.HomeKey, key1[2]); TransformData(controllerlink.Controller1.AppKey, key1[3]); TransformData(controllerlink.Controller1.TouchKey, key1[4]); TransformData(controllerlink.Controller1.VolumeUpKey, key1[5]); TransformData(controllerlink.Controller1.VolumeDownKey, key1[6]); controllerlink.Controller1.TriggerNum = key1[7]; SetTriggerClick(controllerlink.Controller1.TriggerKey, key1[7]); controllerlink.Controller1.Battery = key1[8]; } } //Goblin controller if (controllerlink.goblinserviceStarted && controllerlink.controller0Connected) { var pose0 = controllerlink.GetHBControllerPoseData(); var jpose = JsonMapper.ToObject(pose0); controllerlink.Controller0.Rotation = new Quaternion(Convert.ToSingle(jpose[1].ToString()), Convert.ToSingle(jpose[2].ToString()), Convert.ToSingle(jpose[3].ToString()), Convert.ToSingle(jpose[0].ToString())); PLOG.D("PvrLog GoblinController X:" + controllerlink.Controller0.Rotation.eulerAngles.x + " Y:" + controllerlink.Controller0.Rotation.eulerAngles.y + " Z:" + controllerlink.Controller0.Rotation.eulerAngles.z); var key0 = controllerlink.GetHBControllerKeyData(); var jkey = JsonMapper.ToObject(key0); controllerlink.Controller0.TouchPadPosition = new Vector2(Convert.ToInt16(jkey[0].ToString()), Convert.ToInt16(jkey[1].ToString())); SetSwipeData(controllerlink.Controller0); SetTouchPadClick(controllerlink.Controller0); TransformData(controllerlink.Controller0.HomeKey, Convert.ToInt16(jkey[2].ToString())); TransformData(controllerlink.Controller0.AppKey, Convert.ToInt16(jkey[3].ToString())); TransformData(controllerlink.Controller0.TouchKey, Convert.ToInt16(jkey[4].ToString())); TransformData(controllerlink.Controller0.VolumeUpKey, Convert.ToInt16(jkey[5].ToString())); TransformData(controllerlink.Controller0.VolumeDownKey, Convert.ToInt16(jkey[6].ToString())); controllerlink.Controller0.Battery = Convert.ToInt16(jkey[7].ToString()); TransformData(controllerlink.Controller0.TriggerKey, controllerlink.GetTriggerKeyEvent()); } SetSystemKey(); #endif }