Skip to content

Commit 4184833

Browse files
committed
Add handedness extension
1 parent 53c7d50 commit 4184833

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/Shared/Extensions.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
#if (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP
5+
using Microsoft.MixedReality.Toolkit.Utilities;
6+
using Windows.UI.Input.Spatial;
7+
#endif // (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP
8+
9+
namespace Microsoft.MixedReality.Toolkit.WindowsMixedReality
10+
{
11+
/// <summary>
12+
/// Provides useful extensions for Windows-defined types.
13+
/// </summary>
14+
public static class WindowsExtensions
15+
{
16+
#if (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP
17+
/// <summary>
18+
/// Converts a platform <see cref="SpatialInteractionSourceHandedness"/> into
19+
/// the equivalent value in MRTK's defined <see cref="Handedness"/>.
20+
/// </summary>
21+
/// <param name="handedness">The handedness value to convert.</param>
22+
/// <returns>The converted value in the new type.</returns>
23+
public static Handedness ToMRTKHandedness(this SpatialInteractionSourceHandedness handedness)
24+
{
25+
switch (handedness)
26+
{
27+
case SpatialInteractionSourceHandedness.Left:
28+
return Handedness.Left;
29+
case SpatialInteractionSourceHandedness.Right:
30+
return Handedness.Right;
31+
case SpatialInteractionSourceHandedness.Unspecified:
32+
default:
33+
return Handedness.None;
34+
}
35+
}
36+
#endif // (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP
37+
}
38+
}

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/Shared/Extensions/WindowsExtensions.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)