예제 #1
0
        internal override void SearchForDevices(
            AppIntentProfile appIntentProfile,
            Action <Device[]> onDevicesUpdated,
            bool autoReconnect,
            float autoReconnectTimeout)
        {
            base.SearchForDevices(appIntentProfile, onDevicesUpdated, autoReconnect, autoReconnectTimeout);

            if (autoReconnect)
            {
                throw new NotImplementedException();
            }

            _transmitIndex = 0;
            WearableProxyClientProtocol.EncodeInitiateDeviceSearch(_transmitBuffer, ref _transmitIndex);
            SendTransmitBuffer();
            _searchingForDevices = true;
        }
예제 #2
0
        private bool HasDeviceSpecificGesturesEnabled(AppIntentProfile profile)
        {
            for (int i = 0; i < WearableConstants.GestureIds.Length; i++)
            {
                GestureId id = WearableConstants.GestureIds[i];

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

                if (profile.GetGestureInProfile(id) && id.IsGestureDeviceSpecific())
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        private void DrawIntentsSection()
        {
            bool isDeviceConnected = _wearableControl.ConnectedDevice.HasValue;

            var status = _wearableControl.GetIntentValidationStatus();

            var profileProperty         = serializedObject.FindProperty(INTENT_PROFILE_FIELD);
            AppIntentProfile oldProfile = profileProperty.objectReferenceValue as AppIntentProfile;

            EditorGUILayout.ObjectField(profileProperty, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
            AppIntentProfile newProfile = profileProperty.objectReferenceValue as AppIntentProfile;

            if (newProfile == null)
            {
                EditorGUILayout.HelpBox(SPECIFY_INTENT_WARNING, MessageType.Warning);
                return;
            }

            // If the profile changed at runtime, and there's a device connected, check intents again.
            if (oldProfile != newProfile && isDeviceConnected)
            {
                _wearableControl.SetIntentProfile(newProfile);
            }

            // Profile description
            EditorGUILayout.HelpBox(newProfile.ToString(), MessageType.None);

            if (!Application.isPlaying || !isDeviceConnected)
            {
                return;
            }

            // Re-validate warning
            if (status == IntentValidationStatus.Unknown)
            {
                EditorGUILayout.HelpBox(INTENT_PROFILE_CHANGED, MessageType.Warning);

                bool validateAgain = GUILayout.Button(VALIDATE_INTENTS_TITLE, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                if (validateAgain)
                {
                    _wearableControl.SetIntentProfile(newProfile);
                    _wearableControl.ValidateIntentProfile();
                }
            }
            else
            {
                // Status box
                switch (status)
                {
                // "Unknown" is checked above, so no need to check it here.
                case IntentValidationStatus.Validating:
                    EditorGUILayout.HelpBox(INTENT_VALIDATION_IN_PROGRESS, MessageType.Info);
                    break;

                case IntentValidationStatus.Success:
                    EditorGUILayout.HelpBox(INTENT_VALIDATION_SUCCEEDED, MessageType.Info);
                    break;

                case IntentValidationStatus.Failure:
                    EditorGUILayout.HelpBox(INTENT_VALIDATION_FAILED, MessageType.Error);
                    break;

                case IntentValidationStatus.Disabled:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
예제 #4
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            GUI.changed = false;

            AppIntentProfile profile = target as AppIntentProfile;

            if (profile == null)
            {
                // Nothing we can do, so give up.
                return;
            }

            // Sensors
            EditorGUILayout.LabelField(SensorsLabel, EditorStyles.boldLabel);
            _newSensors.Clear();
            bool sensorsChanged = false;

            for (int i = 0; i < WearableConstants.SensorIds.Length; i++)
            {
                SensorId id = WearableConstants.SensorIds[i];

                bool prior = profile.GetSensorInProfile(id);
                bool post  = EditorGUILayout.Toggle(id.ToString(), prior, WearableConstants.EmptyLayoutOptions);
                sensorsChanged |= prior != post;

                if (post)
                {
                    _newSensors.Add(id);
                }
            }

            if (sensorsChanged)
            {
                profile.SetSensorIntent(_newSensors);
            }

            // Intervals
            GUILayoutTools.LineSeparator();
            EditorGUILayout.LabelField(IntervalsLabel, EditorStyles.boldLabel);
            _newIntervals.Clear();
            bool intervalsChanged = false;

            for (int i = 0; i < WearableConstants.UpdateIntervals.Length; i++)
            {
                SensorUpdateInterval interval = WearableConstants.UpdateIntervals[i];
                string label = string.Format(
                    IntervalFormat,
                    ((int)WearableTools.SensorUpdateIntervalToMilliseconds(interval)).ToString());
                bool prior = profile.GetIntervalInProfile(interval);
                bool post  = EditorGUILayout.Toggle(label, prior, WearableConstants.EmptyLayoutOptions);
                intervalsChanged |= prior != post;

                if (post)
                {
                    _newIntervals.Add(interval);
                }
            }

            if (intervalsChanged)
            {
                profile.SetIntervalIntent(_newIntervals);
            }


            // Gestures
            GUILayoutTools.LineSeparator();
            EditorGUILayout.LabelField(GesturesLabel, EditorStyles.boldLabel);

            _newGestures.Clear();
            bool gesturesChanged = false;

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

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

                bool prior = profile.GetGestureInProfile(id);
                bool post  = EditorGUILayout.Toggle(id.ToString(), prior, WearableConstants.EmptyLayoutOptions);
                gesturesChanged |= prior != post;

                if (post)
                {
                    _newGestures.Add(id);
                }
            }

            if (gesturesChanged)
            {
                profile.SetGestureIntent(_newGestures);
            }

            if (HasDeviceSpecificGesturesEnabled(profile))
            {
                EditorGUILayout.HelpBox(WearableConstants.DeviceSpecificGestureDiscouragedWarning, MessageType.Warning);
            }

            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
                EditorUtility.SetDirty(target);
            }
        }
예제 #5
0
        private void DrawIntentsSection()
        {
            bool isDeviceConnected = _wearableControl.ConnectedDevice.HasValue;

            var status = _wearableControl.GetIntentValidationStatus();

            var profileProperty         = serializedObject.FindProperty(IntentProfileField);
            AppIntentProfile oldProfile = profileProperty.objectReferenceValue as AppIntentProfile;

            EditorGUILayout.ObjectField(profileProperty, WearableConstants.EmptyLayoutOptions);
            AppIntentProfile newProfile = profileProperty.objectReferenceValue as AppIntentProfile;

            if (newProfile == null)
            {
                EditorGUILayout.HelpBox(SpecifyIntentWarning, MessageType.Warning);
                return;
            }

            // If the profile changed at runtime, and there's a device connected, check intents again.
            if (oldProfile != newProfile && isDeviceConnected)
            {
                _wearableControl.SetIntentProfile(newProfile);
            }

            // Profile description
            EditorGUILayout.HelpBox(newProfile.ToString(), MessageType.None);

            if (!Application.isPlaying || !isDeviceConnected)
            {
                return;
            }

            // Re-validate warning
            if (status == IntentValidationStatus.Unknown)
            {
                EditorGUILayout.HelpBox(IntentProfileChanged, MessageType.Warning);

                bool validateAgain = GUILayout.Button(ValidateIntentsTitle, WearableConstants.EmptyLayoutOptions);
                if (validateAgain)
                {
                    _wearableControl.SetIntentProfile(newProfile);
                    _wearableControl.ValidateIntentProfile();
                }
            }
            else
            {
                // Status box
                switch (status)
                {
                // "Unknown" is checked above, so no need to check it here.
                case IntentValidationStatus.Validating:
                    EditorGUILayout.HelpBox(IntentValidationInProgress, MessageType.Info);
                    break;

                case IntentValidationStatus.Success:
                    EditorGUILayout.HelpBox(IntentValidationSucceeded, MessageType.Info);
                    break;

                case IntentValidationStatus.Failure:
                    EditorGUILayout.HelpBox(IntentValidationFailed, MessageType.Error);
                    break;

                case IntentValidationStatus.Disabled:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
예제 #6
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            GUI.changed = false;

            AppIntentProfile profile = target as AppIntentProfile;

            if (profile == null)
            {
                // Nothing we can do, so give up.
                return;
            }

            // Sensors
            EditorGUILayout.LabelField(SENSORS_LABEL, EditorStyles.boldLabel);
            _newSensors.Clear();
            bool sensorsChanged = false;

            for (int i = 0; i < WearableConstants.SENSOR_IDS.Length; i++)
            {
                SensorId id = WearableConstants.SENSOR_IDS[i];

                bool prior = profile.GetSensorInProfile(id);
                bool post  = EditorGUILayout.Toggle(id.ToString(), prior, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                sensorsChanged |= prior != post;

                if (post)
                {
                    _newSensors.Add(id);
                }
            }

            if (sensorsChanged)
            {
                profile.SetSensorIntent(_newSensors);
            }

            // Intervals
            GUILayoutTools.LineSeparator();
            EditorGUILayout.LabelField(INTERVALS_LABEL, EditorStyles.boldLabel);
            _newIntervals.Clear();
            bool intervalsChanged = false;

            for (int i = 0; i < WearableConstants.UPDATE_INTERVALS.Length; i++)
            {
                SensorUpdateInterval interval = WearableConstants.UPDATE_INTERVALS[i];
                string label = string.Format(
                    INTERVAL_FORMAT,
                    ((int)WearableTools.SensorUpdateIntervalToMilliseconds(interval)).ToString());
                bool prior = profile.GetIntervalInProfile(interval);
                bool post  = EditorGUILayout.Toggle(label, prior, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                intervalsChanged |= prior != post;

                if (post)
                {
                    _newIntervals.Add(interval);
                }
            }

            if (intervalsChanged)
            {
                profile.SetIntervalIntent(_newIntervals);
            }


            // Gestures
            GUILayoutTools.LineSeparator();
            EditorGUILayout.LabelField(GESTURES_LABEL, EditorStyles.boldLabel);

            _newGestures.Clear();
            bool gesturesChanged = false;

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

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

                bool prior = profile.GetGestureInProfile(id);
                bool post  = EditorGUILayout.Toggle(id.ToString(), prior, WearableEditorConstants.EMPTY_LAYOUT_OPTIONS);
                gesturesChanged |= prior != post;

                if (post)
                {
                    _newGestures.Add(id);
                }
            }

            if (gesturesChanged)
            {
                profile.SetGestureIntent(_newGestures);
            }

            if (HasDeviceSpecificGesturesEnabled(profile))
            {
                EditorGUILayout.HelpBox(WearableEditorConstants.DEVICE_SPECIFIC_GESTURE_DISCOURAGED_WARNING, MessageType.Warning);
            }

            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
                EditorUtility.SetDirty(target);
            }
        }
예제 #7
0
 protected override void RequestIntentProfileValidationInternal(AppIntentProfile appIntentProfile)
 {
     // FIXME: Temporarily force this to succeed until the proxy functionality is implemented
     OnReceivedIntentValidationResponse(true);
 }