예제 #1
0
        protected override void Awake()
        {
            _wearableDeviceConfig      = new WearableDeviceConfig();
            _finalWearableDeviceConfig = new WearableDeviceConfig();

            _accelerometerSensor = new WearableSensor(this, SensorId.Accelerometer);
            _gyroscopeSensor     = new WearableSensor(this, SensorId.Gyroscope);
            _rotationSensor      = new WearableSensor(this, SensorId.Rotation);

            // populate wearable gesture dictionary
            _wearableGestures = new Dictionary <GestureId, WearableGesture>();
            for (var i = 0; i < WearableConstants.GestureIds.Length; ++i)
            {
                if (WearableConstants.GestureIds[i] != GestureId.None)
                {
                    _wearableGestures[WearableConstants.GestureIds[i]] =
                        new WearableGesture(this, WearableConstants.GestureIds[i]);
                }
            }

            // Activate the default provider depending on the platform
                        #if UNITY_EDITOR
            SetActiveProvider(GetOrCreateProvider(_editorDefaultProvider));
                        #else
            SetActiveProvider(GetOrCreateProvider(_runtimeDefaultProvider));
                        #endif

            base.Awake();
        }
예제 #2
0
            public void SetDeviceConfiguration(WearableDeviceConfig config)
            {
                if (_wearablePlugin != null)
                {
                    bool[] sensors = new bool[WearableConstants.SensorIds.Length];
                    for (int i = 0; i < WearableConstants.SensorIds.Length; i++)
                    {
                        sensors[i] = config.GetSensorConfig(WearableConstants.SensorIds[i]).isEnabled;
                    }
                    IntPtr sensorsJava = AndroidJNIHelper.ConvertToJNIArray(sensors);

                    bool[] gestures = new bool[WearableConstants.GestureIds.Length - 1];                   // -1 to Exclude .None
                    for (int i = 1; i < WearableConstants.GestureIds.Length; i++)
                    {
                        gestures[i - 1] = config.GetGestureConfig(WearableConstants.GestureIds[i]).isEnabled;
                    }
                    IntPtr gesturesJava = AndroidJNIHelper.ConvertToJNIArray(gestures);

                    // The AndroidJavaObject.Call method doesn't support arrays, so we have to convert & pass them more deliberately.
                    jvalue[] args = new jvalue[4];
                    args[0].l = sensorsJava;
                    args[1].l = gesturesJava;
                    args[2].i = (int)config.updateInterval;
                    IntPtr setMethod = AndroidJNIHelper.GetMethodID(_wearablePlugin.GetRawClass(), SetDeviceConfigurationMethod);
                    AndroidJNI.CallVoidMethod(_wearablePlugin.GetRawObject(), setMethod, args);
                }
            }
예제 #3
0
        /// <summary>
        /// Sets the override <see cref="WearableDeviceConfig"/> config that will take priority over any
        /// requirement resolved <see cref="WearableDeviceConfig"/>.
        /// </summary>
        /// <param name="config"></param>
        internal void RegisterOverrideConfig(WearableDeviceConfig config)
        {
            _overrideDeviceConfig     = config;
            _isOverridingDeviceConfig = true;

            LockDeviceStateUpdate();
        }
예제 #4
0
        public WearableDeviceConfig Clone()
        {
            var result = new WearableDeviceConfig();

            result.CopyValuesFrom(this);
            return(result);
        }
예제 #5
0
        internal override void SetDeviceConfiguration(WearableDeviceConfig config)
        {
                        #if UNITY_EDITOR
            USBDeviceConfiguration deviceConfig = new USBDeviceConfiguration
            {
                intervalMilliseconds  = (int)WearableTools.SensorUpdateIntervalToMilliseconds(config.updateInterval),
                sensorRotationNineDof = config.rotationNineDof.isEnabled ? 1 : 0,
                sensorRotationSixDof  = config.rotationSixDof.isEnabled ? 1 : 0,
                sensorGyroscope       = config.gyroscope.isEnabled ? 1 : 0,
                sensorAccelerometer   = config.accelerometer.isEnabled ? 1 : 0,
                gestureHeadNod        = config.headNodGesture.isEnabled ? 1 : 0,
                gestureHeadShake      = config.headShakeGesture.isEnabled ? 1 : 0,
                gestureDoubleTap      = config.doubleTapGesture.isEnabled ? 1 : 0,
                gestureTouchAndHold   = config.touchAndHoldGesture.isEnabled ? 1 : 0,
                gestureInput          = config.inputGesture.isEnabled ? 1 : 0,
                gestureAffirmative    = config.affirmativeGesture.isEnabled ? 1 : 0,
                gestureNegative       = config.negativeGesture.isEnabled ? 1 : 0
            };

            WearableUSBSetDeviceConfiguration(deviceConfig);
                        #endif

            // Assume the configuration succeeded, because it generally will. Failed configs will show up when we poll
            // for status flags, and adjust the internal config as necessary.
            _config = config.Clone();
        }
예제 #6
0
        static WearableConstants()
        {
            // Ensure that empty frame has a valid rotation quaternion
            EMPTY_FRAME = new SensorFrame
            {
                rotationNineDof = new SensorQuaternion {
                    value = Quaternion.identity
                },
                rotationSixDof = new SensorQuaternion {
                    value = Quaternion.identity
                }
            };

            CONNECTING_STATES = new List <ConnectionStatus>
            {
                ConnectionStatus.FirmwareUpdateRequired,
                ConnectionStatus.FirmwareUpdateAvailable,
                ConnectionStatus.Connecting,
                ConnectionStatus.AutoReconnect,
                ConnectionStatus.SecurePairingRequired
            };

            EMPTY_DEVICE_LIST = new Device[0];

            GESTURE_IDS                        = (GestureId[])Enum.GetValues(typeof(GestureId));
            SENSOR_IDS                         = (SensorId[])Enum.GetValues(typeof(SensorId));
            UPDATE_INTERVALS                   = (SensorUpdateInterval[])Enum.GetValues(typeof(SensorUpdateInterval));
            SIGNAL_STRENGTHS                   = (SignalStrength[])Enum.GetValues(typeof(SignalStrength));
            ACTIVE_NOISE_REDUCTION_MODES       = (ActiveNoiseReductionMode[])Enum.GetValues(typeof(ActiveNoiseReductionMode));
            EMPTY_ACTIVE_NOISE_REDUCTION_MODES = new ActiveNoiseReductionMode[0];
            DEVICE_STATUS_FLAGS                = (DeviceStatusFlags[])Enum.GetValues(typeof(DeviceStatusFlags));
            OS_PERMISSIONS                     = (OSPermission[])Enum.GetValues(typeof(OSPermission));
            OS_SERVICES                        = (OSService[])Enum.GetValues(typeof(OSService));

            DISABLED_DEVICE_CONFIG = new WearableDeviceConfig();
            DISABLED_DEVICE_CONFIG.DisableAllSensors();
            DISABLED_DEVICE_CONFIG.DisableAllGestures();

                        #pragma warning disable 618
            DISALLOWED_EDITOR_PROVIDERS  = new[] { ProviderId.BluetoothProvider };
            DISALLOWED_RUNTIME_PROVIDERS = new[] { ProviderId.USBProvider };
                        #pragma warning restore 618

            DEBUG_PROVIDER_DEFAULT_AVAILABLE_ANR_MODES = new[] {
                ActiveNoiseReductionMode.Off,
                ActiveNoiseReductionMode.Low,
                ActiveNoiseReductionMode.High
            };

            EMPTY_DEVICE_STATUS       = new DeviceStatus();
            EMPTY_DYNAMIC_DEVICE_INFO = new DynamicDeviceInfo
            {
                transmissionPeriod                       = -1,
                activeNoiseReductionMode                 = ActiveNoiseReductionMode.Invalid,
                availableActiveNoiseReductionModes       = WearableTools.GetActiveNoiseReductionModesAsInt(EMPTY_ACTIVE_NOISE_REDUCTION_MODES),
                controllableNoiseCancellationLevel       = 0,
                controllableNoiseCancellationEnabled     = false,
                totalControllableNoiseCancellationLevels = 0
            };
        }
예제 #7
0
            public WearableDeviceConfig GetDeviceConfiguration()
            {
                const string GetSampleRateMethod     = "GetSamplePeriod";
                const string GetSensorEnabledMethod  = "GetSensorIsEnabled";
                const string GetGestureEnabledMethod = "GetGestureIsEnabled";

                WearableDeviceConfig config = new WearableDeviceConfig();

                if (_wearablePlugin != null)
                {
                    AndroidJavaObject deviceConfig = _wearablePlugin.Call <AndroidJavaObject>(GetDeviceConfigurationMethod);

                    config.updateInterval                = (SensorUpdateInterval)deviceConfig.Call <int>(GetSampleRateMethod);
                    config.accelerometer.isEnabled       = deviceConfig.Call <bool>(GetSensorEnabledMethod, (int)SensorId.Accelerometer);
                    config.gyroscope.isEnabled           = deviceConfig.Call <bool>(GetSensorEnabledMethod, (int)SensorId.Gyroscope);
                    config.rotationSixDof.isEnabled      = deviceConfig.Call <bool>(GetSensorEnabledMethod, (int)SensorId.RotationSixDof);
                    config.rotationNineDof.isEnabled     = deviceConfig.Call <bool>(GetSensorEnabledMethod, (int)SensorId.RotationNineDof);
                    config.doubleTapGesture.isEnabled    = deviceConfig.Call <bool>(GetGestureEnabledMethod, (int)GestureId.DoubleTap);
                    config.headNodGesture.isEnabled      = deviceConfig.Call <bool>(GetGestureEnabledMethod, (int)GestureId.HeadNod);
                    config.headShakeGesture.isEnabled    = deviceConfig.Call <bool>(GetGestureEnabledMethod, (int)GestureId.HeadShake);
                    config.touchAndHoldGesture.isEnabled = deviceConfig.Call <bool>(GetGestureEnabledMethod, (int)GestureId.TouchAndHold);
                    config.inputGesture.isEnabled        = deviceConfig.Call <bool>(GetGestureEnabledMethod, (int)GestureId.Input);
                    config.affirmativeGesture.isEnabled  = deviceConfig.Call <bool>(GetGestureEnabledMethod, (int)GestureId.Affirmative);
                    config.negativeGesture.isEnabled     = deviceConfig.Call <bool>(GetGestureEnabledMethod, (int)GestureId.Negative);
                }

                return(config);
            }
예제 #8
0
 /// <summary>
 /// Copy only the sensor configuration from another <see cref="WearableDeviceConfig"/>. Includes the sensor
 /// update interval.
 /// </summary>
 /// <param name="config"></param>
 public void CopySensorConfigFrom(WearableDeviceConfig config)
 {
     for (int i = 0; i < WearableConstants.SENSOR_IDS.Length; i++)
     {
         SensorId sensorId = WearableConstants.SENSOR_IDS[i];
         GetSensorConfig(sensorId).isEnabled = config.GetSensorConfig(sensorId).isEnabled;
     }
     updateInterval = config.updateInterval;
 }
예제 #9
0
                #pragma warning restore CS0414

        internal WearableUSBProvider()
        {
            _statusMessageSeparators = new[] { '\n' };
            _sessionStatus           = SessionStatus.Closed;
            _statusMessage           = new StringBuilder(8192);
            _uidBuilder             = new StringBuilder(256);
            _nameBuilder            = new StringBuilder(256);
            _firmwareVersionBuilder = new StringBuilder(256);

            _config = new WearableDeviceConfig();
        }
예제 #10
0
        /// <summary>
        /// Copy only the gesture configuration from another <see cref="WearableDeviceConfig"/>.
        /// </summary>
        /// <param name="config"></param>
        public void CopyGestureConfigFrom(WearableDeviceConfig config)
        {
            for (int i = 0; i < WearableConstants.GESTURE_IDS.Length; i++)
            {
                GestureId gestureId = WearableConstants.GESTURE_IDS[i];

                if (gestureId == GestureId.None)
                {
                    continue;
                }

                GetGestureConfig(gestureId).isEnabled = config.GetGestureConfig(gestureId).isEnabled;
            }
        }
예제 #11
0
        /// <summary>
        /// True if the device state needs to be updated because it differs from our the
        /// <see cref="WearableDeviceConfig"/> <paramref name="config"/>, otherwise false.
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        private bool ShouldUpdateDeviceState(WearableDeviceConfig config)
        {
            // Check all sensors to see if we need to update the device.
            var deviceShouldBeUpdated = false;

            for (var i = 0; i < WearableConstants.SensorIds.Length; i++)
            {
                var sensorId     = WearableConstants.SensorIds[i];
                var sensorConfig = config.GetSensorConfig(sensorId);

                if (sensorConfig.isEnabled != GetSensorActive(sensorId))
                {
                    deviceShouldBeUpdated = true;
                }
            }

            // Check the sensor update interval to see if we need to update the device.
            if (config.updateInterval != UpdateInterval)
            {
                deviceShouldBeUpdated = true;
            }

            // Check the rotation source to see if we need to update the device.
            if (config.rotationSource != RotationSource)
            {
                deviceShouldBeUpdated = true;
            }

            // Check all gestures to see if we need to update the device state.
            if (!deviceShouldBeUpdated)
            {
                for (var i = 0; i < WearableConstants.GestureIds.Length; i++)
                {
                    if (WearableConstants.GestureIds[i] == GestureId.None)
                    {
                        continue;
                    }

                    var gestureConfig = config.GetGestureConfig(WearableConstants.GestureIds[i]);
                    if (gestureConfig.isEnabled != GetGestureEnabled(WearableConstants.GestureIds[i]))
                    {
                        deviceShouldBeUpdated = true;
                        break;
                    }
                }
            }

            return(deviceShouldBeUpdated);
        }
        /// <summary>
        /// Used internally by WearableControl to get the latest buffer of SensorFrame updates from
        /// the Wearable Device; the newest frame in that batch is set as the CurrentSensorFrame.
        /// </summary>
        private void GetLatestSensorUpdates()
        {
            _currentSensorFrames.Clear();

            GetLatestSensorUpdatesInternal();

            if (_currentSensorFrames.Count > 0)
            {
                _lastSensorFrame = _currentSensorFrames[_currentSensorFrames.Count - 1];

                OnSensorsUpdated(_lastSensorFrame);
            }

            _currentGestureData.Clear();

            GetLatestGestureUpdatesInternal();

            if (_currentGestureData.Count > 0)
            {
                for (int currentGestureIndex = 0; currentGestureIndex < _currentGestureData.Count; ++currentGestureIndex)
                {
                    OnGestureDetected(_currentGestureData[currentGestureIndex].gestureId);
                }
            }

            if (_pollForConfigStatus)
            {
                ConfigStatus sensor  = GetSensorConfigStatusInternal();
                ConfigStatus gesture = GetGestureConfigStatusInternal();

                if (!(sensor == ConfigStatus.Pending || sensor == ConfigStatus.Idle) &&
                    !(gesture == ConfigStatus.Pending || gesture == ConfigStatus.Idle))
                {
                    _pollForConfigStatus = false;
                }

                if (sensor == ConfigStatus.Failure || gesture == ConfigStatus.Failure)
                {
                    OnConfigurationFailed(sensor, gesture);
                }

                if (sensor == ConfigStatus.Success && gesture == ConfigStatus.Success)
                {
                    OnConfigurationSucceeded();
                }
            }

            _config = GetDeviceConfigurationInternal();
        }
        /// <summary>
        /// Invokes any callbacks registered by <see cref="RequestDeviceConfiguration"/> and marks the request as
        /// complete.
        /// </summary>
        /// <param name="config"></param>
        internal void OnReceivedDeviceConfiguration(WearableDeviceConfig config)
        {
            if (!_enabled)
            {
                return;
            }

            if (_waitingForDeviceConfig && DeviceConfigRequestSubscribers != null)
            {
                DeviceConfigRequestSubscribers.Invoke(config);
            }

            _waitingForDeviceConfig        = false;
            DeviceConfigRequestSubscribers = null;
        }
예제 #14
0
        static WearableConstants()
        {
            // Ensure that empty frame has a valid rotation quaternion
            EmptyFrame = new SensorFrame
            {
                rotationNineDof = new SensorQuaternion {
                    value = Quaternion.identity
                },
                rotationSixDof = new SensorQuaternion {
                    value = Quaternion.identity
                }
            };

            ConnectingStates = new List <ConnectionStatus>
            {
                ConnectionStatus.FirmwareUpdateRequired,
                ConnectionStatus.FirmwareUpdateAvailable,
                ConnectionStatus.Connecting,
                ConnectionStatus.AutoReconnect,
                ConnectionStatus.SecurePairingRequired
            };

            EmptyDeviceList = new Device[0];

            EmptyLayoutOptions = new GUILayoutOption[0];

            GestureIds      = (GestureId[])Enum.GetValues(typeof(GestureId));
            SensorIds       = (SensorId[])Enum.GetValues(typeof(SensorId));
            UpdateIntervals = (SensorUpdateInterval[])Enum.GetValues(typeof(SensorUpdateInterval));
            SignalStrengths = (SignalStrength[])Enum.GetValues(typeof(SignalStrength));

            DisabledDeviceConfig = new WearableDeviceConfig();
            DisabledDeviceConfig.DisableAllSensors();
            DisabledDeviceConfig.DisableAllGestures();

                        #pragma warning disable 618
            DisallowedEditorProviders  = new[] { ProviderId.MobileProvider, ProviderId.WearableDevice };
            DisallowedRuntimeProviders = new[] { ProviderId.MobileProvider, ProviderId.USBProvider };
                        #pragma warning restore 618

            EmptyDeviceStatus      = new DeviceStatus();
            EmptyDynamicDeviceInfo = new DynamicDeviceInfo {
                transmissionPeriod = -1
            };
        }
        /// <summary>
        /// Helper function to convert our WearableDeviceConfig to something more easily consumable
        /// by the bridge layer.
        /// </summary>
        private static WearableDeviceConfig CreateWearableConfig(BridgeDeviceConfiguration config)
        {
            WearableDeviceConfig wearableConfig = new WearableDeviceConfig();

            wearableConfig.updateInterval                = (SensorUpdateInterval)config.updateInterval;
            wearableConfig.accelerometer.isEnabled       = config.sensorAccelerometer != 0;
            wearableConfig.gyroscope.isEnabled           = config.sensorGyroscope != 0;
            wearableConfig.rotationNineDof.isEnabled     = config.sensorRotationNineDof != 0;
            wearableConfig.rotationSixDof.isEnabled      = config.sensorRotationSixDof != 0;
            wearableConfig.doubleTapGesture.isEnabled    = config.gestureDoubleTap != 0;
            wearableConfig.headNodGesture.isEnabled      = config.gestureHeadNod != 0;
            wearableConfig.headShakeGesture.isEnabled    = config.gestureHeadShake != 0;
            wearableConfig.touchAndHoldGesture.isEnabled = config.gestureTouchAndHold != 0;
            wearableConfig.inputGesture.isEnabled        = config.gestureInput != 0;
            wearableConfig.affirmativeGesture.isEnabled  = config.gestureAffirmative != 0;
            wearableConfig.negativeGesture.isEnabled     = config.gestureNegative != 0;

            return(wearableConfig);
        }
        /// <summary>
        /// Helper function to convert our WearableDeviceConfig to something more easily consumable
        /// by the bridge layer.
        /// </summary>
        private static BridgeDeviceConfiguration CreateBridgeConfig(WearableDeviceConfig config)
        {
            BridgeDeviceConfiguration bridgeConfig;

            bridgeConfig.updateInterval        = (int)config.updateInterval;
            bridgeConfig.sensorAccelerometer   = config.accelerometer.isEnabled ? 1 : 0;
            bridgeConfig.sensorGyroscope       = config.gyroscope.isEnabled ? 1 : 0;
            bridgeConfig.sensorRotationNineDof = config.rotationNineDof.isEnabled ? 1 : 0;
            bridgeConfig.sensorRotationSixDof  = config.rotationSixDof.isEnabled ? 1 : 0;
            bridgeConfig.gestureDoubleTap      = config.doubleTapGesture.isEnabled ? 1 : 0;
            bridgeConfig.gestureHeadNod        = config.headNodGesture.isEnabled ? 1 : 0;
            bridgeConfig.gestureHeadShake      = config.headShakeGesture.isEnabled ? 1 : 0;
            bridgeConfig.gestureTouchAndHold   = config.touchAndHoldGesture.isEnabled ? 1 : 0;
            bridgeConfig.gestureInput          = config.inputGesture.isEnabled ? 1 : 0;
            bridgeConfig.gestureAffirmative    = config.affirmativeGesture.isEnabled ? 1 : 0;
            bridgeConfig.gestureNegative       = config.negativeGesture.isEnabled ? 1 : 0;

            return(bridgeConfig);
        }
예제 #17
0
        /// <summary>
        /// Additively updates the final device config with <see cref="WearableDeviceConfig"/> <paramref name="config"/>
        /// </summary>
        /// <param name="config"></param>
        private void UpdateFinalDeviceConfig(WearableDeviceConfig config)
        {
            // Set all sensor state and update intervals
            for (var i = 0; i < WearableConstants.SensorIds.Length; i++)
            {
                var sensorId          = WearableConstants.SensorIds[i];
                var finalSensorConfig = _finalWearableDeviceConfig.GetSensorConfig(sensorId);
                var reqSensorConfig   = config.GetSensorConfig(sensorId);

                finalSensorConfig.isEnabled |= reqSensorConfig.isEnabled;
            }

            // Set all gesture state.
            for (var i = 0; i < WearableConstants.GestureIds.Length; i++)
            {
                if (WearableConstants.GestureIds[i] == GestureId.None)
                {
                    continue;
                }

                var finalGestureConfig = _finalWearableDeviceConfig.GetGestureConfig(WearableConstants.GestureIds[i]);
                var reqGestureConfig   = config.GetGestureConfig(WearableConstants.GestureIds[i]);

                finalGestureConfig.isEnabled |= reqGestureConfig.isEnabled;
            }

            if (config.HasAnySensorsEnabled())
            {
                if (_finalWearableDeviceConfig.updateInterval.IsSlowerThan(config.updateInterval))
                {
                    _finalWearableDeviceConfig.updateInterval = config.updateInterval;
                }
            }

            // If the config rotation sensor is enabled and the final config has a lower priority rotation
            // source, override it
            if (config.rotation.isEnabled &&
                _finalWearableDeviceConfig.rotationSource.IsLowerPriority(config.rotationSource))
            {
                _finalWearableDeviceConfig.rotationSource = config.rotationSource;
            }
        }
예제 #18
0
        /// <summary>
        /// Copy all the configuration values from the specified configuration.
        /// </summary>
        /// <param name="config"></param>
        public void CopyValuesFrom(WearableDeviceConfig config)
        {
            for (int i = 0; i < WearableConstants.SensorIds.Length; i++)
            {
                SensorId sensorId = WearableConstants.SensorIds[i];
                GetSensorConfig(sensorId).isEnabled = config.GetSensorConfig(sensorId).isEnabled;
            }

            for (int i = 0; i < WearableConstants.GestureIds.Length; i++)
            {
                GestureId gestureId = WearableConstants.GestureIds[i];

                if (gestureId == GestureId.None)
                {
                    continue;
                }

                GetGestureConfig(gestureId).isEnabled = config.GetGestureConfig(gestureId).isEnabled;
            }

            updateInterval = config.updateInterval;
        }
예제 #19
0
 public void SetDeviceConfigurationInternal(WearableDeviceConfig config)
 {
     AndroidPlugin.SetDeviceConfiguration(config);
 }
예제 #20
0
 /// <summary>
 /// Copy all the configuration values from the specified configuration.
 /// </summary>
 /// <param name="config"></param>
 public void CopyValuesFrom(WearableDeviceConfig config)
 {
     CopySensorConfigFrom(config);
     CopyGestureConfigFrom(config);
 }
 /// <summary>
 /// Set all relevant device information for a WearableDevice, including sensors, gestures, and update interval.
 /// </summary>
 /// <param name="config"></param>
 internal abstract void SetDeviceConfiguration(WearableDeviceConfig config);
 public void SetDeviceConfigurationInternal(WearableDeviceConfig config)
 {
     WearableSetDeviceConfiguration(CreateBridgeConfig(config));
 }
예제 #23
0
        internal override void SetDeviceConfiguration(WearableDeviceConfig config)
        {
            if (_dynamicDeviceInfo.deviceStatus.ServiceSuspended)
            {
                Debug.LogWarning(WearableConstants.DebugProviderSetConfigWhileSuspendedWarning);
                _waitingToSendConfigFailure = true;
                _sendConfigFailureTime      = Time.unscaledTime + _simulatedDelayTime;
                return;
            }

            if (_verbose)
            {
                // Sensor info
                for (int i = 0; i < WearableConstants.SensorIds.Length; i++)
                {
                    SensorId sensorId  = WearableConstants.SensorIds[i];
                    bool     oldSensor = _config.GetSensorConfig(sensorId).isEnabled;
                    bool     newSensor = config.GetSensorConfig(sensorId).isEnabled;

                    if (newSensor == oldSensor)
                    {
                        continue;
                    }

                    Debug.LogFormat(
                        newSensor ? WearableConstants.DebugProviderStartSensor : WearableConstants.DebugProviderStopSensor,
                        Enum.GetName(typeof(SensorId), sensorId));
                }

                // Gesture info
                for (int i = 0; i < WearableConstants.GestureIds.Length; i++)
                {
                    GestureId gestureId = WearableConstants.GestureIds[i];

                    if (gestureId == GestureId.None)
                    {
                        continue;
                    }

                    bool oldGesture = _config.GetGestureConfig(gestureId).isEnabled;
                    bool newGesture = config.GetGestureConfig(gestureId).isEnabled;
                    if (newGesture == oldGesture)
                    {
                        continue;
                    }

                    Debug.LogFormat(
                        newGesture ? WearableConstants.DebugProviderEnableGesture : WearableConstants.DebugProviderDisableGesture,
                        Enum.GetName(typeof(GestureId), gestureId));
                }


                // Update interval
                SensorUpdateInterval oldInterval = _config.updateInterval;
                SensorUpdateInterval newInterval = config.updateInterval;
                if (oldInterval != newInterval)
                {
                    Debug.LogFormat(
                        WearableConstants.DebugProviderSetUpdateInterval,
                        Enum.GetName(typeof(SensorUpdateInterval), newInterval));
                }
            }

            _config.CopyValuesFrom(config);
            _waitingToSendConfigSuccess = true;
            _sendConfigSuccessTime      = Time.unscaledTime + _simulatedDelayTime;
        }
 public void SetDeviceConfigurationInternal(WearableDeviceConfig config)
 {
 }
 internal override void SetDeviceConfiguration(WearableDeviceConfig config)
 {
     SetDeviceConfigurationInternal(config);
     _pollForConfigStatus = true;
 }
 internal WearableBluetoothProvider()
 {
     _config = new WearableDeviceConfig();
 }
예제 #27
0
        internal WearableDebugProvider()
        {
            _virtualDevice = new Device
            {
                name              = _name,
                firmwareVersion   = _firmwareVersion,
                rssi              = _rssi,
                availableSensors  = _availableSensors,
                availableGestures = _availableGestures,
                productId         = _productId,
                variantId         = _variantId,
                uid = _uid,
                transmissionPeriod = 0,
                maximumPayloadPerTransmissionPeriod = 0,
                // NB: an extra sensor needs to be added to account for RotationSource
                maximumActiveSensors = WearableConstants.SensorIds.Length + 1
            };

            _name                    = WearableConstants.DebugProviderDefaultDeviceName;
            _firmwareVersion         = WearableConstants.DefaultFirmwareVersion;
            _boseArEnabled           = true;
            _firmwareUpdateAvailable = false;
            _acceptSecurePairing     = true;
            _rssi                    = WearableConstants.DebugProviderDefaultRSSI;
            _availableSensors        = WearableConstants.AllSensors;
            _availableGestures       = WearableConstants.AllGestures;
            _productId               = WearableConstants.DebugProviderDefaultProductId;
            _variantId               = WearableConstants.DebugProviderDefaultVariantId;
            _uid = WearableConstants.DebugProviderDefaultUID;
            _simulatedDelayTime = WearableConstants.DebugProviderDefaultDelayTime;

            _searchingForDevice = false;

            _verbose = true;

            _eulerSpinRate     = Vector3.zero;
            _axisAngleSpinRate = Vector3.up;

            _config = new WearableDeviceConfig();

            _pendingGestures = new Queue <GestureData>();

            _nextSensorUpdateTime = 0.0f;
            _rotation             = Quaternion.identity;

            _dynamicDeviceInfo = WearableConstants.EmptyDynamicDeviceInfo;

            _updateInformation = new FirmwareUpdateInformation
            {
                icon    = BoseUpdateIcon.Music,
                options = new[]
                {
                    new FirmwareUpdateAlertOption
                    {
                        style = AlertStyle.Affirmative
                    },
                    new FirmwareUpdateAlertOption
                    {
                        style = AlertStyle.Negative
                    }
                }
            };
        }
예제 #28
0
 internal WearableDeviceProvider()
 {
     _config = new WearableDeviceConfig();
 }