/// <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; } } } }
/// <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); } }