void Move(NotifyCollectionChangedEventArgs args)
{
- var count = args.OldItems.Count;
+ int count = args.OldItems?.Count ?? 0;
for (int n = 0; n < count; n++)
{
void Remove(NotifyCollectionChangedEventArgs args)
{
- var startIndex = args.OldStartingIndex + args.OldItems.Count - 1;
+ int count=args.OldItems?.Count ?? 0;
+ int startIndex = args.OldStartingIndex + count - 1;
for (int n = startIndex; n >= args.OldStartingIndex; n--)
{
RemoveAt(n);
}
// If we have a start index, we can be more clever about removing the group(s) (and get the nifty animations)
- var groupCount = args.OldItems.Count;
+ int groupCount = args.OldItems?.Count ?? 0;
var absolutePosition = GetAbsolutePosition(groups[groupIndex], 0);
void Replace(NotifyCollectionChangedEventArgs args)
{
- var groupCount = args.NewItems.Count;
-
- if (groupCount != args.OldItems.Count)
+ var newItems = args.NewItems;
+ var oldItems = args.OldItems;
+ if(newItems == null || oldItems == null)
+ {
+ return;
+ }
+ int groupCount = newItems.Count;
+ int oldCount = oldItems.Count;
+ if (groupCount != oldCount)
{
// The original and replacement sets are of unequal size; this means that most everything currently in
// view will have to be updated. So just reload the whole thing.
return;
}
- var newStartIndex = args.NewStartingIndex > -1 ? args.NewStartingIndex : groupSource.IndexOf(args.NewItems[0]);
- var oldStartIndex = args.OldStartingIndex > -1 ? args.OldStartingIndex : groupSource.IndexOf(args.OldItems[0]);
+ var newStartIndex = args.NewStartingIndex > -1 ? args.NewStartingIndex : groupSource.IndexOf(newItems[0]);
+ var oldStartIndex = args.OldStartingIndex > -1 ? args.OldStartingIndex : groupSource.IndexOf(oldItems[0]);
var newItemCount = CountItemsInGroups(newStartIndex, groupCount);
var oldItemCount = CountItemsInGroups(oldStartIndex, groupCount);
void Move(NotifyCollectionChangedEventArgs args)
{
- var itemCount = CountItemsInGroups(args.OldStartingIndex, args.OldItems.Count);
+ var itemCount = CountItemsInGroups(args.OldStartingIndex, args.OldItems?.Count ?? 0);
var start = Math.Min(args.OldStartingIndex, args.NewStartingIndex);
var end = Math.Max(args.OldStartingIndex, args.NewStartingIndex) + itemCount;
startIndex = AdjustPositionForHeader(startIndex);
// If we have a start index, we can be more clever about removing the item(s) (and get the nifty animations)
- var count = args.OldItems.Count;
+ int count = args.OldItems?.Count ?? 0;
if (count == 1)
{
void Replace(NotifyCollectionChangedEventArgs args)
{
+ var newItems = args.NewItems;
+ var oldItems = args.OldItems;
+ if (newItems == null || oldItems == null)
+ {
+ return;
+ }
var startIndex = args.NewStartingIndex > -1 ? args.NewStartingIndex : IndexOf(args.NewItems[0]);
startIndex = AdjustPositionForHeader(startIndex);
- var newCount = args.NewItems.Count;
-
- if (newCount == args.OldItems.Count)
+
+ int newCount = newItems.Count;
+ int oldCount = oldItems.Count;
+ if (newCount == oldCount)
{
// We are replacing one set of items with a set of equal size; we can do a simple item or range
// notification to the adapter
public static IntPtr AllocStructure<T>()
{
int size = SizeOf<T>();
+
+ Debug.Assert(size>0, "The memory size to be allocated should be greater than 0");
+
return Marshal.AllocHGlobal(size);
}
private IntPtr ToPointer()
{
IntPtr drawOptionsPtr = NativeInterop.AllocStructure<cpSpaceDebugDrawOptions>();
- if (Marshal.SizeOf(typeof(cpSpaceDebugDrawOptions)) == 0)
- {
- throw new ArgumentNullException("The size of type cpSpaceDebugDrawOptions should not be 0.");
- }
Marshal.StructureToPtr<cpSpaceDebugDrawOptions>(this, drawOptionsPtr, false);
* limitations under the License.
*
*/
-
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
namespace Tizen.NUI.Scene3D
{
internal static partial class Interop
{
internal static partial class Model
- {
+ {
[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Model_New_SWIG_0")]
public static extern global::System.IntPtr ModelNew(string modelUrl, string resourcePasth);
[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Model_LoadFacialAnimation_2")]
public static extern global::System.IntPtr LoadBlendShapeAnimationFromBuffer(global::System.Runtime.InteropServices.HandleRef model, string jsonBuffer, int jsonBufferLength);
+
+ // Signals
+ [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Model_MeshHitSignal_Connect")]
+ public static extern void MeshHitSignalConnect(global::System.Runtime.InteropServices.HandleRef model, global::System.Runtime.InteropServices.HandleRef handler);
+
+ [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionData_MeshHitSignal_Disconnect")]
+ public static extern void MeshHitSignalDisconnect(global::System.Runtime.InteropServices.HandleRef model, global::System.Runtime.InteropServices.HandleRef handler);
}
}
}
*
*/
+using System;
+using System.Runtime.InteropServices;
+
namespace Tizen.NUI.Scene3D
{
internal static partial class Interop
{
internal static partial class ModelNode
{
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct Vec3
+ {
+ internal float x, y, z;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct ElementIndex
+ {
+ internal Int32 index;
+ }
+
[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Model_Node_New_SWIG_0")]
public static extern global::System.IntPtr ModelNodeNew();
[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_Model_Node_GetChildModelNodeAt")]
public static extern global::System.IntPtr GetChildModelNodeAt(global::System.Runtime.InteropServices.HandleRef model, uint index);
+
+ [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_ModelNode_SetColliderMesh")]
+ public static extern global::System.IntPtr SetColliderMesh(global::System.Runtime.InteropServices.HandleRef modelNode,
+ Vec3[] vPtr,
+ Vec3[] nPtr, int vLength, int[] iPtr, int iLength);
}
}
}
public static extern float GetDuration(global::System.Runtime.InteropServices.HandleRef motionData);
[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionData_LoadBvh")]
- public static extern float LoadMotionCaptureAnimation(global::System.Runtime.InteropServices.HandleRef motionData, string motionCaptureFilename, global::System.Runtime.InteropServices.HandleRef scale, bool synchronousLoad);
+ public static extern void LoadMotionCaptureAnimation(global::System.Runtime.InteropServices.HandleRef motionData, string motionCaptureFilename, bool useRootTranslationOnly, global::System.Runtime.InteropServices.HandleRef scale, bool synchronousLoad);
[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionData_LoadBvhFromBuffer")]
- public static extern float LoadMotionCaptureAnimationFromBuffer(global::System.Runtime.InteropServices.HandleRef motionData, string motionCaptureBuffer, int motionCaptureBufferLength, global::System.Runtime.InteropServices.HandleRef scale, bool synchronousLoad);
+ public static extern void LoadMotionCaptureAnimationFromBuffer(global::System.Runtime.InteropServices.HandleRef motionData, string motionCaptureBuffer, int motionCaptureBufferLength, bool useRootTranslationOnly, global::System.Runtime.InteropServices.HandleRef scale, bool synchronousLoad);
[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionData_LoadFacialAnimation")]
- public static extern float LoadBlendShapeAnimation(global::System.Runtime.InteropServices.HandleRef motionData, string blendShapeFilename, bool synchronousLoad);
+ public static extern void LoadBlendShapeAnimation(global::System.Runtime.InteropServices.HandleRef motionData, string blendShapeFilename, bool synchronousLoad);
[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionData_LoadFacialAnimationFromBuffer")]
- public static extern float LoadBlendShapeAnimationFromBuffer(global::System.Runtime.InteropServices.HandleRef motionData, string blendShapeBuffer, int blendShapeBufferLength, bool synchronousLoad);
+ public static extern void LoadBlendShapeAnimationFromBuffer(global::System.Runtime.InteropServices.HandleRef motionData, string blendShapeBuffer, int blendShapeBufferLength, bool synchronousLoad);
// Signals
[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
public static extern bool IsUsingFramebuffer(global::System.Runtime.InteropServices.HandleRef sceneView);
+ [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_SceneView_SetResolution")]
+ public static extern void SetResolution(global::System.Runtime.InteropServices.HandleRef sceneView, uint width, uint height);
+
+ [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_SceneView_GetResolutionWidth")]
+ public static extern uint GetResolutionWidth(global::System.Runtime.InteropServices.HandleRef sceneView);
+
+ [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_SceneView_GetResolutionHeight")]
+ public static extern uint GetResolutionHeight(global::System.Runtime.InteropServices.HandleRef sceneView);
+
+ [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_SceneView_ResetResolution")]
+ public static extern void ResetResolution(global::System.Runtime.InteropServices.HandleRef sceneView);
+
[global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_SceneView_SetFramebufferMultiSamplingLevel")]
public static extern void SetFramebufferMultiSamplingLevel(global::System.Runtime.InteropServices.HandleRef sceneView, uint multiSamplingLevel);
*/
using System;
+using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.ComponentModel;
using Tizen.NUI;
{
Interop.Model.DeleteModel(swigCPtr);
}
+
+
+ private EventHandler<MeshHitEventArgs> meshHitEventHandler;
+ private MeshHitCallbackType meshHitCallback;
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ private delegate void MeshHitCallbackType(IntPtr motionData);
+
+ /// <summary>
+ /// MeshHitEventArgs
+ /// Contains arguments when MeshHitSignal called
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class MeshHitEventArgs : EventArgs
+ {
+ private ModelNode modelNode;
+
+ /// <summary>
+ /// ModelNode that's been hit
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ModelNode ModelNode
+ {
+ get
+ {
+ return modelNode;
+ }
+ set
+ {
+ modelNode = value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// EventHandler event.
+ /// It will be invoked when collider mesh is hit.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler<MeshHitEventArgs> ColliderMeshHitted
+ {
+ add
+ {
+ if (meshHitEventHandler == null)
+ {
+ meshHitCallback = MeshHitCollision;
+ Interop.Model.MeshHitSignalConnect(SwigCPtr, meshHitCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ }
+ meshHitEventHandler += value;
+ }
+ remove
+ {
+ meshHitEventHandler -= value;
+ if (meshHitEventHandler == null && meshHitCallback != null)
+ {
+ Interop.Model.MeshHitSignalDisconnect(SwigCPtr, meshHitCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ meshHitCallback = null;
+ }
+ }
+ }
+
+ private void MeshHitCollision(IntPtr modelNode)
+ {
+ if (meshHitEventHandler != null)
+ {
+ var args = new MeshHitEventArgs();
+ args.ModelNode = new ModelNode(modelNode, false);
+ meshHitEventHandler(this, args);
+ }
+ }
}
}
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
+ /// <summary>
+ /// Sets SceneView's resolution manually.
+ /// </summary>
+ /// <param name="width">The input width.</param>
+ /// <param name="height">The input height.</param>
+ /// <remarks>
+ /// This manual resolution is only available when the SceneView uses FBO for rendering by using FBO (UseFrameBuffer is true).
+ /// If the aspect ratio of input width/height is different with SceneView's aspect ratio, the rendered result is stretched to fill SceneView's area.
+ /// </remarks>
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetResolution(uint width, uint height)
+ {
+ Interop.SceneView.SetResolution(SwigCPtr, width, height);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ /// <summary>
+ /// Retrieves width of resolution of the SceneView.
+ /// </summary>
+ /// <remarks>
+ /// If the SceneView not uses FBO, this method returns SceneView's width.
+ /// </remarks>
+ /// <returns> Camera currently used in SceneView as a selected Camera.</returns>
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public uint GetResolutionWidth()
+ {
+ uint result = Interop.SceneView.GetResolutionWidth(SwigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return result;
+ }
+
+ /// <summary>
+ /// Retrieves height of resolution of the SceneView.
+ /// </summary>
+ /// <remarks>
+ /// If the SceneView not uses FBO, this method returns SceneView's height.
+ /// </remarks>
+ /// <returns> Camera currently used in SceneView as a selected Camera.</returns>
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public uint GetResolutionHeight()
+ {
+ uint result = Interop.SceneView.GetResolutionHeight(SwigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return result;
+ }
+
+ /// <summary>
+ /// Resets SceneView's resolution to the current size of SceneView.
+ /// </summary>
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ResetResolution()
+ {
+ Interop.SceneView.ResetResolution(SwigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
internal void SetUseFramebuffer(bool useFramebuffer)
{
Interop.SceneView.UseFramebuffer(SwigCPtr, useFramebuffer);
*/
using System;
+using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Collections.Generic;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
+
+ /// <summary>
+ /// Sets collider mesh on current node
+ /// </summary>
+ /// <param name="vertexList">List of vertices</param>
+ /// <param name="normalList">List of vertex normals</param>
+ /// <param name="indexList">List of mesh indices</param>
+ // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetColliderMesh(List<Vector3> vertexList, List<Vector3> normalList, List<int> indexList)
+ {
+ var vertices = new Interop.ModelNode.Vec3[vertexList.Count];
+ var idx = 0;
+ foreach (var vertex in vertexList)
+ {
+ vertices[idx].x = vertex.X;
+ vertices[idx].y = vertex.Y;
+ vertices[idx].z = vertex.Z;
+ ++idx;
+ }
+
+ var normals = new Interop.ModelNode.Vec3[normalList.Count];
+ idx = 0;
+ foreach (var normal in normalList)
+ {
+ normals[idx].x = normal.X;
+ normals[idx].y = normal.Y;
+ normals[idx].z = normal.Z;
+ ++idx;
+ }
+
+ Interop.ModelNode.SetColliderMesh(SwigCPtr,vertices, normals, vertexList.Count, indexList.ToArray(), indexList.Count);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
/// <summary>
/// Gets the number of ModelPrimitive objects in the ModelNode object.
/// <since_tizen> 11 </since_tizen>
public void LoadMotionCaptureAnimation(string motionCaptureFilename, Vector3 scale = null, bool synchronousLoad = false)
{
- Interop.MotionData.LoadMotionCaptureAnimation(SwigCPtr, motionCaptureFilename, Vector3.getCPtr(scale), synchronousLoad);
+ Interop.MotionData.LoadMotionCaptureAnimation(SwigCPtr, motionCaptureFilename, false, Vector3.getCPtr(scale), synchronousLoad);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ /// <summary>
+ /// Load motion capture animation.
+ /// We support bvh format.
+ /// After load completes, <see cref="LoadCompleted"/> event will be invoked.
+ /// </summary>
+ /// <remarks>
+ /// Scale is additional scale factor of motion capture animation. It is possible that
+ /// Model's scale may not match with motion capture animation scale.
+ /// If scale is null, default value will be used: <cref name="Vector3.ONE"/>
+ /// </remarks>
+ /// <param name="motionCaptureFilename">Name of motion capture format file.</param>
+ /// <param name="useRootTranslationOnly">True to use only root translation with rotation animation.</param>
+ /// <param name="scale">Scale value of motion capture animation match with model.</param>
+ /// <param name="synchronousLoad">Load synchronously or not. Default is async load.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void LoadMotionCaptureAnimation(string motionCaptureFilename, bool useRootTranslationOnly, Vector3 scale = null, bool synchronousLoad = false)
+ {
+ Interop.MotionData.LoadMotionCaptureAnimation(SwigCPtr, motionCaptureFilename, useRootTranslationOnly, Vector3.getCPtr(scale), synchronousLoad);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
/// <since_tizen> 11 </since_tizen>
public void LoadMotionCaptureAnimationFromBuffer(string motionCaptureBuffer, Vector3 scale = null, bool synchronousLoad = false)
{
- Interop.MotionData.LoadMotionCaptureAnimationFromBuffer(SwigCPtr, motionCaptureBuffer, motionCaptureBuffer.Length, Vector3.getCPtr(scale), synchronousLoad);
+ Interop.MotionData.LoadMotionCaptureAnimationFromBuffer(SwigCPtr, motionCaptureBuffer, motionCaptureBuffer.Length, false, Vector3.getCPtr(scale), synchronousLoad);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ /// <summary>
+ /// Load motion capture animation from string.
+ /// We support bvh format.
+ /// After load completes, <see cref="LoadCompleted"/> event will be invoked.
+ /// </summary>
+ /// <remarks>
+ /// Scale is additional scale factor of motion capture animation. It is possible that
+ /// Model's scale may not match with motion capture animation scale.
+ /// If scale is null, default value will be used: <cref name="Vector3.ONE"/>
+ /// </remarks>
+ /// <param name="motionCaptureBuffer">Contents of motion capture format string.</param>
+ /// <param name="useRootTranslationOnly">True to use only root translation with rotation animation.</param>
+ /// <param name="scale">Scale value of motion capture animation match with model.</param>
+ /// <param name="synchronousLoad">Load synchronously or not. Default is async load.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void LoadMotionCaptureAnimationFromBuffer(string motionCaptureBuffer, bool useRootTranslationOnly, Vector3 scale = null, bool synchronousLoad = false)
+ {
+ Interop.MotionData.LoadMotionCaptureAnimationFromBuffer(SwigCPtr, motionCaptureBuffer, motionCaptureBuffer.Length, useRootTranslationOnly, Vector3.getCPtr(scale), synchronousLoad);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
if (textures != null)
{
- int intptrBytes = checked(sizeof(IntPtr) * textures.Count);
+ int count = textures.Count;
+ int intptrBytes = checked(sizeof(IntPtr) * count);
if (intptrBytes>0)
{
IntPtr unmanagedPointer = Marshal.AllocHGlobal(intptrBytes);
- IntPtr[] texturesArray = new IntPtr[textures.Count];
- for (int i = 0; i < textures.Count; i++)
+ IntPtr[] texturesArray = new IntPtr[count];
+ for (int i = 0; i < count; i++)
{
texturesArray[i] = HandleRef.ToIntPtr(Texture.getCPtr(textures[i]));
}
- System.Runtime.InteropServices.Marshal.Copy(texturesArray, 0, unmanagedPointer, textures.Count);
+ Marshal.Copy(texturesArray, 0, unmanagedPointer, count);
- Interop.GLView.GlViewBindTextureResources(SwigCPtr, unmanagedPointer, textures.Count);
+ Interop.GLView.GlViewBindTextureResources(SwigCPtr, unmanagedPointer, count);
Marshal.FreeHGlobal(unmanagedPointer);
}
}
// If the view had focus, it clears focus.
if (child == FocusManager.Instance.GetCurrentFocusView())
{
+ Tizen.Log.Debug("NUI", $"ClearFocus due to View id:({child.ID}) removed from scene\n");
FocusManager.Instance.ClearFocus();
}
// Do actual child removal
NUILog.Debug($"=============================");
base.Dispose(type);
-
+
aliveCount--;
}
{
if (!profile.Equals(null))
{
- profileList.Add((BluetoothProfileType)profile);
+ profileList.Add(BluetoothUtils.ConvertBtProfileToProfileType(profile));
}
return true;
};
if (BluetoothAdapter.IsBluetoothEnabled)
{
bool isConnected;
- int ret = Interop.Bluetooth.IsProfileConnected(RemoteDeviceAddress, (int)profileType, out isConnected);
+ int ret = Interop.Bluetooth.IsProfileConnected(RemoteDeviceAddress, BluetoothUtils.ConvertProfileTypeToBtProfile(profileType), out isConnected);
if (ret != (int)BluetoothError.None)
{
Log.Error(Globals.LogTag, "Failed to get profile connected state, Error - " + (BluetoothError)ret);
return connectionInfo;
}
+
+ internal static int ConvertProfileTypeToBtProfile(BluetoothProfileType profileType)
+ {
+ return profileType switch
+ {
+ BluetoothProfileType.Rfcomm => 0x01,
+ BluetoothProfileType.AdvancedAudioDistribution => 0x02,
+ BluetoothProfileType.Headset => 0x04,
+ BluetoothProfileType.HumanInterfaceDevice => 0x08,
+ BluetoothProfileType.NetworkAccessPoint => 0x10,
+ BluetoothProfileType.AudioGateway => 0x20,
+ BluetoothProfileType.GenericAttribute => 0x40,
+ BluetoothProfileType.NapServer => 0x80,
+ BluetoothProfileType.AdvancedAudioDistributionSink => 0x100,
+ _ => -1,
+ };
+ }
+
+ internal static BluetoothProfileType ConvertBtProfileToProfileType(int btProfile)
+ {
+ return btProfile switch
+ {
+ 0x01 => BluetoothProfileType.Rfcomm,
+ 0x02 => BluetoothProfileType.AdvancedAudioDistribution,
+ 0x04 => BluetoothProfileType.Headset,
+ 0x08 => BluetoothProfileType.HumanInterfaceDevice,
+ 0x10 => BluetoothProfileType.NetworkAccessPoint,
+ 0x20 => BluetoothProfileType.AudioGateway,
+ 0x40 => BluetoothProfileType.GenericAttribute,
+ 0x80 => BluetoothProfileType.NapServer,
+ 0x100 => BluetoothProfileType.AdvancedAudioDistributionSink,
+ };
+ }
}
}