/// <summary> /// OnPeripheralStateChange,Update State of Peripheral /// </summary> /// <param name="sender"></param> /// <param name="eventArguments"></param> private void OnPeripheralStateChange(object sender, PeripheralStateChangeEventArgs eventArguments) { Sdk.Logger.Log("Is " + eventArguments.Peripheral.Name + " Connected? " + eventArguments.Connected); //Connected if (eventArguments.Connected) { // Peripheral Type if (eventArguments.Peripheral is HmdPeripheral) { mHmdController = (HmdPeripheral)eventArguments.Peripheral; //Output the Info of Hmd OutputHmdInfo(mHmdController); } else { if (eventArguments.Peripheral.GetModelName() == MirageAR_DeviceConstants.CONTROLLER_UNIVERSAL_MODELNAME) { controllerType = MirageAR_DeviceConstants.ControllerType.UniversalController; mUniversalController = (ControllerPeripheral)eventArguments.Peripheral; } else if (eventArguments.Peripheral.GetModelName() == MirageAR_DeviceConstants.CONTROLLER_SABER_MODELNAME) { controllerType = MirageAR_DeviceConstants.ControllerType.SaberController; mSaberController = (ControllerPeripheral)eventArguments.Peripheral; } else { Sdk.Logger.Log("Unknow Controller" + mUniversalController.GetDeviceName()); } //Output the Info of Controller OutputControllerInfo(eventArguments.Peripheral); } } else //DisConnected { if (eventArguments.Peripheral is HmdPeripheral) { mHmdController = null; } else { if (eventArguments.Peripheral.GetModelName() == MirageAR_DeviceConstants.CONTROLLER_UNIVERSAL_MODELNAME) { mUniversalController = null; } else if (eventArguments.Peripheral.GetModelName() == MirageAR_DeviceConstants.CONTROLLER_SABER_MODELNAME) { mSaberController = null; } } } }
public static void Init(PlatformConfig platformConfig, HmdPeripheral hmd) { if (GetCallMade()) { return; } Log.Debug("[Init] " + platformConfig); (new GameObject("OneTimeCall")).AddComponent <OneTimeCall>().Send(platformConfig, hmd); }
/// <summary> /// Output the Info of Hmd /// </summary> private void OutputHmdInfo(HmdPeripheral hmdPeripheral) { if (!hmdPeripheral.Connected) { return; } Sdk.Logger.Log("HMD Device Name: " + hmdPeripheral.GetDeviceName()); Sdk.Logger.Log("HMD FW Info: " + hmdPeripheral.GetFirmwareVersion()); Sdk.Logger.Log("HMD Modle Name: " + hmdPeripheral.GetModelName()); Sdk.Logger.Log("HMD Serial Number: " + hmdPeripheral.GetSerialNumber()); Sdk.Logger.Log("HMD Battery: " + hmdPeripheral.GetBatteryLevel()); }
/// <summary> /// Init the Periphera Connected State /// </summary> private void InitPeripheraState() { //Init the Hmd Peripheral State HmdPeripheral hmdPeripheral = VisionSDK.Instance.Connections.GetPeripheral("XHawk-0") as HmdPeripheral; if (hmdPeripheral != null) { StartGameButton.GetComponent <Image>().color = (hmdPeripheral.Connected) ? Color.green : Color.white; } //Init the Controller Periphera State Peripheral controllerPeripheral = VisionSDK.Instance.Connections.GetPeripheral("XCobra-0"); if (controllerPeripheral != null) { PairButton.GetComponent <Image>().color = (controllerPeripheral.Connected) ? Color.green : Color.white; } }
/// <summary> /// Check the State of the Peripheral /// </summary> private void CheckPeripheralState() { //Check The Cotroller Peripheral State Peripheral controllerPeripheral = Sdk.Connections.GetPeripheral("XCobra-0"); if (controllerPeripheral != null && controllerPeripheral.Connected) { if (controllerPeripheral.GetModelName() == MirageAR_DeviceConstants.CONTROLLER_UNIVERSAL_MODELNAME) { controllerType = MirageAR_DeviceConstants.ControllerType.UniversalController; mUniversalController = (ControllerPeripheral)controllerPeripheral; } else if (controllerPeripheral.GetModelName() == MirageAR_DeviceConstants.CONTROLLER_SABER_MODELNAME) { controllerType = MirageAR_DeviceConstants.ControllerType.SaberController; mSaberController = (ControllerPeripheral)controllerPeripheral; } else { Sdk.Logger.Log("Unknow Controller" + controllerPeripheral.GetDeviceName()); } //Output the Info of Controller OutputControllerInfo(controllerPeripheral); } //Check The Hmd Peripheral State HmdPeripheral hmdPeripheral = (HmdPeripheral)Sdk.Connections.GetPeripheral("XHawk-0"); if (hmdPeripheral != null && hmdPeripheral.Connected) { mHmdController = hmdPeripheral; //Output the Info of Hmd OutputHmdInfo(mHmdController); } }
/// <summary> /// Check the Input of Hmd /// </summary> private void CheckHmdInput(HmdPeripheral mHmdController) { // Check Is Connected if (!(mHmdController.Input.connectionState == Ximmerse.InputSystem.DeviceConnectionState.Connected)) { return; } #region HmdSelect Button Events if (mHmdController.Input.GetButtonDown((uint)ButtonType.HmdSelect)) { if (HmdSelectPressDown != null) { HmdSelectPressDown(); } } if (mHmdController.Input.GetButton((uint)ButtonType.HmdSelect)) { if (HmdSelectPress != null) { HmdSelectPress(); } } if (mHmdController.Input.GetButtonUp((uint)ButtonType.HmdSelect)) { if (HmdSelectPressUp != null) { HmdSelectPressUp(); } } #endregion //HmdSelect Button Events #region HmdBack Button Events if (mHmdController.Input.GetButtonDown((uint)ButtonType.HmdBack)) { if (HmdBackPressDown != null) { HmdBackPressDown(); } } if (mHmdController.Input.GetButton((uint)ButtonType.HmdBack)) { if (HmdBackPress != null) { HmdBackPress(); } } if (mHmdController.Input.GetButtonUp((uint)ButtonType.HmdBack)) { if (HmdBackPressUp != null) { HmdBackPressUp(); } } #endregion //HmdBack Button Events #region HmdMenu Button Events if (mHmdController.Input.GetButtonDown((uint)ButtonType.HmdMenu)) { if (HmdMenuPressDown != null) { HmdMenuPressDown(); } } if (mHmdController.Input.GetButton((uint)ButtonType.HmdMenu)) { if (HmdMenuPress != null) { HmdMenuPress(); } } if (mHmdController.Input.GetButtonUp((uint)ButtonType.HmdMenu)) { if (HmdMenuPressUp != null) { HmdMenuPressUp(); } } #endregion //HmdMenu Button Events }
/// <summary> /// Send the call. /// </summary> private void Send(PlatformConfig platformConfig, HmdPeripheral hmd) { if (hmd == null || !hmd.Connected) { return; } int handle = XDevicePlugin.GetInputDeviceHandle("VRDevice"); const string SDKVersion = "3.0"; const string DeviceIDType = "HMD SN"; string DeviceID = XDevicePlugin.GetString(handle, XDevicePlugin.kField_HMDSN8Object, "HMD-SerialNumber-MISSING"); string OsVersion = XDevicePlugin.GetString(handle, XDevicePlugin.kField_FirmwareRevisionObject, "HMD-FirmwareVersion-MISSING"); string Language = Application.systemLanguage.ToString(); string Country = Language; if (System.Globalization.RegionInfo.CurrentRegion != null) { Country = System.Globalization.RegionInfo.CurrentRegion.TwoLetterISORegionName; } string DeviceModel = hmd.GetModelName(); if (string.IsNullOrEmpty(DeviceModel)) { DeviceModel = "HMD-ModelName-MISSING"; } const string Manufacturer = "Lenovo"; string Resolution = Screen.width.ToString() + "x" + Screen.height.ToString(); string BundleID = BundleVersion.Get(); string BundleCode = Application.isEditor ? "1" : BundleVersion.Get(false); string Channel = (Application.platform == RuntimePlatform.Android) ? "Google Play" : "iTunes"; string message = "HLog" + separator + SDKVersion + separator + DeviceIDType + separator + DeviceID + separator + platformConfig.Key + separator + OsVersion + separator + Language + separator + Country + separator + DeviceModel + separator + Manufacturer + separator + Resolution + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + "\n" + BundleID + separator + BundleCode + separator + Channel + // extra junk that OTC wants "\n" + "NULL" + separator + "0" + separator + "0" + separator + "0" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "NULL" + separator + "0" + separator + "0" + separator + "0" + separator + "0" + separator + "NULL\u0003" + "NULL\u0002" + "NULL\u0003" + "NULL"; if (testCall) { Log.Debug(message); } StartCoroutine(Upload(message, platformConfig)); ForceVisionAnalytics.LogOneTimeCall(DeviceID, Channel, Country, BundleCode, OsVersion, SDKVersion); }