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); }
/// <summary> /// Returns true if a device supports using a sensor with <see cref="SensorId"/> /// <paramref name="sensorId"/>, otherwise false if it does not. /// </summary> /// <param name="sensorId"></param> /// <returns></returns> public bool IsSensorAvailable(SensorId sensorId) { var sensorFlag = WearableTools.GetSensorFlag(sensorId); return((availableSensors & sensorFlag) == sensorFlag); }