コード例 #1
0
ファイル: WearableUSBProvider.cs プロジェクト: vell2x/Raxplay
        internal override DynamicDeviceInfo GetDynamicDeviceInfo()
        {
            // This approach of non-blocking & rate-limiting the USB DynamicDeviceInfo polling occurs on
            // the USB provider for two reasons:
            // * TAP has seen delays in response to commands that would not be conducive to a blocking call.
            // * The USB provider builds up a queue of commands, and we're hesitant to request device information
            //   between 30-60x/sec.
            // Ultimately, the result of this polling means that events and data from the DynamicDeviceInfo may come
            // later than expected by the duration of the update interval in the worst case.
            float time = Time.unscaledTime;

            if (time >= _nextDynamicDeviceInfoTime)
            {
                _nextDynamicDeviceInfoTime = time + WearableConstants.DeviceUSBDynamicInfoUpdateIntervalInSeconds;

                                #if UNITY_EDITOR
                unsafe
                {
                    USBDynamicDeviceInfo dynamicUSBInfo = new USBDynamicDeviceInfo();
                    WearableUSBGetDynamicDeviceInfo(&dynamicUSBInfo);
                    _latestDynamicDeviceInfo.deviceStatus       = dynamicUSBInfo.deviceStatus;
                    _latestDynamicDeviceInfo.transmissionPeriod = dynamicUSBInfo.transmissionPeriod;
                }
                                #endif
            }


            return(_latestDynamicDeviceInfo);
        }
コード例 #2
0
        internal override DynamicDeviceInfo GetDynamicDeviceInfo()
        {
            // This approach of non-blocking & rate-limiting the USB DynamicDeviceInfo polling occurs on
            // the USB provider for two reasons:
            // * TAP has seen delays in response to commands that would not be conducive to a blocking call.
            // * The USB provider builds up a queue of commands, and we're hesitant to request device information
            //   between 30-60x/sec.
            // Ultimately, the result of this polling means that events and data from the DynamicDeviceInfo may come
            // later than expected by the duration of the update interval in the worst case.
            float time = Time.unscaledTime;

            if (time >= _nextDynamicDeviceInfoTime)
            {
                _nextDynamicDeviceInfoTime = time + WearableConstants.DEVICE_USB_DYNAMIC_INFO_UPDATE_INTERVAL_IN_SECONDS;

                                #if UNITY_EDITOR
                unsafe
                {
                    USBDynamicDeviceInfo dynamicUSBInfo = new USBDynamicDeviceInfo();
                    WearableUSBGetDynamicDeviceInfo(&dynamicUSBInfo);

                    _latestDynamicDeviceInfo.deviceStatus                             = dynamicUSBInfo.deviceStatus;
                    _latestDynamicDeviceInfo.transmissionPeriod                       = dynamicUSBInfo.transmissionPeriod;
                    _latestDynamicDeviceInfo.activeNoiseReductionMode                 = (ActiveNoiseReductionMode)dynamicUSBInfo.activeNoiseReductionMode;
                    _latestDynamicDeviceInfo.controllableNoiseCancellationLevel       = dynamicUSBInfo.controllableNoiseCancellationLevel;
                    _latestDynamicDeviceInfo.controllableNoiseCancellationEnabled     = dynamicUSBInfo.controllableNoiseCancellationEnabled == 1? true : false;
                    _latestDynamicDeviceInfo.totalControllableNoiseCancellationLevels = dynamicUSBInfo.totalControllableNoiseCancellationLevels;
                }
                                #endif
            }


            return(_latestDynamicDeviceInfo);
        }