public override void OnSCStart() { base.OnSCStart(); if (Application.platform != RuntimePlatform.Android) { bool isConnected = false; if (inputDeviceGCPart.inputDeviceGC.SimulateInEditorMode == true) { if (inputDeviceGCPart.PartType == InputDevicePartType.GCOne) { isConnected = inputDeviceBT3DofPart.inputDeviceBT3Dof.OneGCActive; if (isConnected) { InputDataBT3Dof.StatusDataList.Add(new InputDataBT3Dof.StatusData() { isConnected = isConnected, deviceID = (int)BT3DofIndex.BT3DofOne }); } } else if (inputDeviceGCPart.PartType == InputDevicePartType.GCTwo) { isConnected = inputDeviceBT3DofPart.inputDeviceBT3Dof.TwoGCActive; if (isConnected) { InputDataBT3Dof.StatusDataList.Add(new InputDataBT3Dof.StatusData() { isConnected = isConnected, deviceID = (int)BT3DofIndex.BT3DofTwo }); } } } } else if (Application.platform == RuntimePlatform.Android) { if (inputDeviceGCPart.PartType == InputDevicePartType.GCOne) { bool isConnected = AndroidPluginBase.ObjectFunctionCall <int>(AndroidPluginBT3Dof.BT3DofManager, "isHandShankConnected", 0) != 0 ? true : false; if (isConnected) { InputDataBT3Dof.StatusDataList.Add(new InputDataBT3Dof.StatusData() { isConnected = isConnected, deviceID = (int)BT3DofIndex.BT3DofOne }); } } else if (inputDeviceGCPart.PartType == InputDevicePartType.GCTwo) { bool isConnected = AndroidPluginBase.ObjectFunctionCall <int>(AndroidPluginBT3Dof.BT3DofManager, "isHandShankConnected", 1) != 0 ? true : false; if (isConnected) { InputDataBT3Dof.StatusDataList.Add(new InputDataBT3Dof.StatusData() { isConnected = isConnected, deviceID = (int)BT3DofIndex.BT3DofTwo }); } } } }
public override void OnSCDestroy() { base.OnSCDestroy(); bT3DofConnectListener = null; if (Application.platform == RuntimePlatform.Android) { AndroidPluginBase.ObjectAddListener(AndroidPluginBT3Dof.BT3DofManager, "setHandShankConnStateCallback", null); } }
public override void OnSCAwake() { base.OnSCAwake(); if (Application.platform == RuntimePlatform.Android) { bT3DofConnectListener = new BT3DofConnectListener(this); AndroidPluginBase.ObjectAddListener(AndroidPluginBT3Dof.BT3DofManager, "setHandShankConnStateCallback", bT3DofConnectListener); } }
protected virtual bool UpdateDeviceInfo(InputDeviceBT3DofPart part, bool isClear = false) { if (isClear == true) { part.inputDataGC.GCType = GCType.Null; part.inputDataGC.GCName = ""; part.inputDataGC.SoftVesion = -1; DebugMy.LogError("UpdateDeviceInfo Clear!", this); return(false); } BT3DofIndex index = part.inputDataBT3Dof.index; if (index != BT3DofIndex.BT3DofOne && index != BT3DofIndex.BT3DofTwo) { DebugMy.LogError("UpdateDeviceInfo Error:" + index, this); return(false); } try { string typeFlag = AndroidPluginBase.ObjectFunctionCall <string>(AndroidPluginBT3Dof.BT3DofManager, "getManufacturerModel", (int)index); if (K07Name == typeFlag) { part.inputDataGC.GCType = GCType.K07; } else if (K02Name == typeFlag) { part.inputDataGC.GCType = GCType.K02; } else { part.inputDataGC.GCType = GCType.K02; } if (part.inputDataGC.GCType != GCType.K02 && part.inputDataGC.GCType != GCType.K07) { DebugMy.LogError("UpdateDeviceInfo Error:" + part.inputDataGC.GCType, this); return(false); } part.inputDataGC.GCName = part.inputDataGC.GCType.ToString(); part.inputDataGC.SoftVesion = 0; DebugMy.Log("UpdateDeviceInfo : " + " isConnected: " + part.inputDataGC.isConnected + " GCName: " + part.inputDataGC.GCName + " SoftVesion: " + part.inputDataGC.SoftVesion , this, true); } catch (Exception e) { Debug.Log(e); } return(true); }
public InputDataGetBT3DofKey(InputDataGetBT3Dof _inputDataGetBT3Dof) : base(_inputDataGetBT3Dof) { inputDataGetBT3Dof = _inputDataGetBT3Dof; if (isInvokeOnce == false) { isInvokeOnce = true; if (Application.platform == RuntimePlatform.Android) { BT3DofKeyListener = new BT3DofKeyListener(this); AndroidPluginBase.ObjectAddListener(AndroidPluginBT3Dof.BT3DofManager, "setHandShankKeyEventCallback", BT3DofKeyListener); } } }
public override int[] GetGyro() { if (inputDataGetBT3Dof.inputDeviceBT3DofPart.PartType == InputDevicePartType.GCOne) { temp1 = AndroidPluginBase.ObjectFunctionCall <int[]>(AndroidPluginBT3Dof.BT3DofManager, "getGyro", 0); } else if (inputDataGetBT3Dof.inputDeviceBT3DofPart.PartType == InputDevicePartType.GCTwo) { temp1 = AndroidPluginBase.ObjectFunctionCall <int[]>(AndroidPluginBT3Dof.BT3DofManager, "getGyro", 1); } if (temp1 != null) { return(temp1); } return(temp); }
public override void UpdateTpPosition() { TpPosition[0] = TpPosition[1] = 0; if(inputDataGetBT3Dof.inputDeviceBT3DofPart.PartType == InputDevicePartType.GCOne) { pos = AndroidPluginBase.ObjectFunctionCall<int[]>(AndroidPluginBT3Dof.BT3DofManager, "getTouchPosition", 0); } else if(inputDataGetBT3Dof.inputDeviceBT3DofPart.PartType == InputDevicePartType.GCTwo) { pos = AndroidPluginBase.ObjectFunctionCall<int[]>(AndroidPluginBT3Dof.BT3DofManager, "getTouchPosition", 1); } else { return; } if(pos == null) return; TpPosition.x = pos[0]; TpPosition.y = pos[1]; }
protected override void UpdateRotation() { if (inputDataGetBT3Dof.inputDeviceBT3DofPart.PartType == InputDevicePartType.GCOne) { array = AndroidPluginBase.ObjectFunctionCall <float[]>(AndroidPluginBT3Dof.BT3DofManager, "get3DofMatrix", 0); } else if (inputDataGetBT3Dof.inputDeviceBT3DofPart.PartType == InputDevicePartType.GCTwo) { array = AndroidPluginBase.ObjectFunctionCall <float[]>(AndroidPluginBT3Dof.BT3DofManager, "get3DofMatrix", 1); } else { return; } if (Application.platform != RuntimePlatform.Android) { if (SvrManager.Instance != null && SvrManager.Instance.gameObject.activeSelf) { inputDataGetBT3Dof.inputDeviceBT3DofPart.inputDataBT3Dof.rotation = SvrManager.Instance.head.rotation; } return; } if (array == null) { return; } else { for (int index = 0; index < 16; index++) { mPoseMatrix1[index] = array[index]; } mPoseMatrix1 = FLIP_Z * mPoseMatrix1.inverse * FLIP_Z; rotation = Quaternion.LookRotation(mPoseMatrix1.GetColumn(2), mPoseMatrix1.GetColumn(1)); } EffectByCalibrationKey(); rotation = Quaternion.Euler(deltaEulerAngles + rotation.eulerAngles); inputDataGetBT3Dof.inputDeviceBT3DofPart.inputDataBT3Dof.rotation = Quaternion.Lerp(inputDataGetBT3Dof.inputDeviceBT3DofPart.inputDataBT3Dof.rotation, rotation, 0.4f); }