示例#1
0
        internal override void SearchForDevices(
            AppIntentProfile appIntentProfile,
            Action <Device[]> onDevicesUpdated,
            bool autoReconnect,
            float autoReconnectTimeout)
        {
                        #if UNITY_EDITOR
            StopSearchingForDevices();

            base.SearchForDevices(appIntentProfile, onDevicesUpdated, autoReconnect, autoReconnectTimeout);

            if (onDevicesUpdated == null)
            {
                return;
            }

            USBAppIntentProfile usbProfile = MakeUSBProfile(appIntentProfile);
            unsafe
            {
                WearableUSBSetAppIntentProfile(&usbProfile);
            }
            WearableUSBRefreshDeviceList();
            _performDeviceSearch  = true;
            _nextDeviceSearchTime = Time.unscaledTime + WearableConstants.DeviceUSBConnectUpdateIntervalInSeconds;

            OnConnectionStatusChanged(autoReconnect ? ConnectionStatus.AutoReconnect : ConnectionStatus.Searching);
                        #else
            Debug.LogError(WearableConstants.UnsupportedPlatformError);
            OnReceivedSearchDevices(WearableConstants.EmptyDeviceList);
                        #endif // UNITY_EDITOR
        }
        internal override void SearchForDevices(
            AppIntentProfile appIntentProfile,
            Action <Device[]> onDevicesUpdated,
            bool autoReconnect,
            float autoReconnectTimeout)
        {
                        #if UNITY_EDITOR
            StopSearchingForDevices();

            base.SearchForDevices(appIntentProfile, onDevicesUpdated, autoReconnect, autoReconnectTimeout);

            USBAppIntentProfile usbProfile = MakeUSBProfile(appIntentProfile);
            unsafe
            {
                WearableUSBSetAppIntentProfile(&usbProfile);
            }
            WearableUSBRefreshDeviceList();
            _performDeviceSearch  = true;
            _nextDeviceSearchTime = Time.unscaledTime + WearableConstants.DEVICE_USB_CONNECT_UPDATE_INTERVAL_IN_SECONDS;

            OnConnectionStatusChanged(autoReconnect ? ConnectionStatus.AutoReconnect : ConnectionStatus.Searching);
                        #else
            Debug.LogError(WearableConstants.UNSUPPORTED_PLATFORM_ERROR);
            OnReceivedSearchDevices(WearableConstants.EMPTY_DEVICE_LIST);
                        #endif // UNITY_EDITOR
        }
示例#3
0
 protected override void RequestIntentProfileValidationInternal(AppIntentProfile appIntentProfile)
 {
                 #if UNITY_EDITOR
     unsafe
     {
         USBAppIntentProfile usbProfile = MakeUSBProfile(appIntentProfile);
         bool valid = WearableUSBCheckAppIntentProfileForConnectedDevice(&usbProfile);
         OnReceivedIntentValidationResponse(valid);
     }
                 #endif
 }
示例#4
0
        private USBAppIntentProfile MakeUSBProfile(AppIntentProfile appIntentProfile)
        {
            USBAppIntentProfile usbProfile = new USBAppIntentProfile();

            if (appIntentProfile != null)
            {
                // Sensors
                usbProfile.sensorBitmask = 0;
                for (int i = 0; i < WearableConstants.SensorIds.Length; i++)
                {
                    SensorId sensor = WearableConstants.SensorIds[i];

                    // Does this profile require this sensor?
                    if (appIntentProfile.GetSensorInProfile(sensor))
                    {
                        SensorFlags sensorBit = WearableTools.GetSensorFlag(sensor);
                        usbProfile.sensorBitmask |= (int)sensorBit;
                    }
                }

                // Gestures
                usbProfile.gestureBitmask = 0;
                for (int i = 0; i < WearableConstants.GestureIds.Length; i++)
                {
                    GestureId gesture = WearableConstants.GestureIds[i];

                    // Does this profile require this gesture?
                    if (appIntentProfile.GetGestureInProfile(gesture))
                    {
                        GestureFlags gestureBit = WearableTools.GetGestureFlag(gesture);
                        usbProfile.gestureBitmask |= (int)gestureBit;
                    }
                }

                usbProfile.updateIntervalBitmask = 0;
                for (int i = 0; i < WearableConstants.UpdateIntervals.Length; i++)
                {
                    SensorUpdateInterval interval = WearableConstants.UpdateIntervals[i];

                    // Does this profile require this update interval?
                    if (appIntentProfile.GetIntervalInProfile(interval))
                    {
                        int intervalBit = WearableTools.SensorUpdateIntervalToBit(interval);
                        usbProfile.updateIntervalBitmask |= intervalBit;
                    }
                }
            }

            return(usbProfile);
        }