Skip to content

Commit 2f1424a

Browse files
Removed Default mappings, as they will be provided by the device layer natively
1 parent caac652 commit 2f1424a

File tree

3 files changed

+9
-151
lines changed

3 files changed

+9
-151
lines changed

Assets/MixedRealityToolkit-Tests/UnityInputManagerHelperTests.cs

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,16 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4-
using Microsoft.MixedReality.Toolkit.Internal.Definitions.Devices;
5-
using Microsoft.MixedReality.Toolkit.Internal.Definitions.InputSystem;
6-
using Microsoft.MixedReality.Toolkit.Internal.Definitions.Utilities;
74
using Microsoft.MixedReality.Toolkit.Internal.Utilities;
85
using NUnit.Framework;
9-
using UnityEngine;
106

117
namespace Microsoft.MixedReality.Toolkit.Tests
128
{
139
public class UnityInputManagerHelperTests
1410
{
1511
[Test]
16-
public void Test01_TestAddDefaultMRTKMappings()
12+
public void Test01_TestAddCustomMappings()
1713
{
18-
//First apply settings
19-
InputMappingAxisUtility.ApplyMappings();
20-
foreach (var mapping in InputMappingAxisUtility.MRTKDefaultInputMappingNames)
21-
{
22-
Assert.IsTrue(InputMappingAxisUtility.DoesAxisNameExist(mapping));
23-
}
24-
}
25-
26-
[Test]
27-
public void Test02_TestRemoveDefaultMRTKMappings()
28-
{
29-
//First apply settings
30-
InputMappingAxisUtility.ApplyMappings();
31-
32-
InputMappingAxisUtility.RemoveMappings();
33-
34-
foreach (var mapping in InputMappingAxisUtility.MRTKDefaultInputMappingNames)
35-
{
36-
Assert.IsFalse(InputMappingAxisUtility.DoesAxisNameExist(mapping));
37-
}
38-
}
39-
40-
[Test]
41-
public void Test03_TestAddCustomMappings()
42-
{
43-
//Ensure default mappings are removed
44-
InputMappingAxisUtility.RemoveMappings();
45-
4614
InputMappingAxisUtility.InputManagerAxis[] OpenVRControllerAxisMappings =
4715
{
4816
new InputMappingAxisUtility.InputManagerAxis() { Name = "OPENVR_TOUCHPAD_LEFT_CONTROLLER_HORIZONTAL", Dead = 0.001f, Sensitivity = 1, Invert = false, Type = InputMappingAxisUtility.MappingAxisType.JoystickAxis, Axis = 1 },
@@ -68,11 +36,8 @@ public void Test03_TestAddCustomMappings()
6836
}
6937

7038
[Test]
71-
public void Test04_TestRemoveCustomMappings()
39+
public void Test02_TestRemoveCustomMappings()
7240
{
73-
//Ensure default mappings are removed
74-
InputMappingAxisUtility.RemoveMappings();
75-
7641
InputMappingAxisUtility.InputManagerAxis[] OpenVRControllerAxisMappings =
7742
{
7843
new InputMappingAxisUtility.InputManagerAxis() { Name = "OPENVR_TOUCHPAD_LEFT_CONTROLLER_HORIZONTAL", Dead = 0.001f, Sensitivity = 1, Invert = false, Type = InputMappingAxisUtility.MappingAxisType.JoystickAxis, Axis = 1 },

Assets/MixedRealityToolkit-Tests/UnityInputManagerHelperTests.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/MixedRealityToolkit/_Core/Utilities/InputMappingAxisUtility.cs

Lines changed: 6 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,6 @@ namespace Microsoft.MixedReality.Toolkit.Internal.Utilities
1414
/// </summary>
1515
public static class InputMappingAxisUtility
1616
{
17-
#region Mixed Reality Xbox and Motion Controller constants
18-
19-
public const string CONTROLLER_LEFT_STICK_HORIZONTAL = "CONTROLLER_LEFT_STICK_HORIZONTAL";
20-
public const string CONTROLLER_LEFT_STICK_VERTICAL = "CONTROLLER_LEFT_STICK_VERTICAL";
21-
public const string CONTROLLER_RIGHT_STICK_HORIZONTAL = "CONTROLLER_RIGHT_STICK_HORIZONTAL";
22-
public const string CONTROLLER_RIGHT_STICK_VERTICAL = "CONTROLLER_RIGHT_STICK_VERTICAL";
23-
public const string XBOX_DPAD_HORIZONTAL = "XBOX_DPAD_HORIZONTAL";
24-
public const string XBOX_DPAD_VERTICAL = "XBOX_DPAD_VERTICAL";
25-
public const string CONTROLLER_LEFT_TRIGGER = "CONTROLLER_LEFT_TRIGGER";
26-
public const string CONTROLLER_RIGHT_TRIGGER = "CONTROLLER_RIGHT_TRIGGER";
27-
public const string XBOX_SHARED_TRIGGER = "XBOX_SHARED_TRIGGER";
28-
public const string XBOX_A = "XBOX_A";
29-
public const string XBOX_B = "XBOX_B";
30-
public const string XBOX_X = "XBOX_X";
31-
public const string XBOX_Y = "XBOX_Y";
32-
public const string CONTROLLER_LEFT_MENU = "CONTROLLER_LEFT_MENU";
33-
public const string CONTROLLER_RIGHT_MENU = "CONTROLLER_RIGHT_MENU";
34-
public const string CONTROLLER_LEFT_BUMPER_OR_GRIP = "XBOX_LEFT_BUMPER";
35-
public const string CONTROLLER_RIGHT_BUMPER_OR_GRIP = "XBOX_RIGHT_BUMPER";
36-
public const string CONTROLLER_LEFT_STICK_CLICK = "CONTROLLER_LEFT_STICK_CLICK";
37-
public const string CONTROLLER_RIGHT_STICK_CLICK = "CONTROLLER_RIGHT_STICK_CLICK";
38-
39-
#endregion Mixed Reality Xbox and Motion Controller constants
40-
4117
#region Nested Types
4218

4319
/// <summary>
@@ -74,7 +50,7 @@ public class InputManagerAxis
7450

7551
#endregion Nested Types
7652

77-
#region Mixed Reality Default Mappings configuration
53+
#region Configuration elements
7854

7955
/// <summary>
8056
/// This is used to keep a local list of axis names, so we don't have to keep iterating through each SerializedProperty.
@@ -86,62 +62,7 @@ public class InputManagerAxis
8662
/// </summary>
8763
private static SerializedObject inputManagerAsset;
8864

89-
/// <summary>
90-
/// Define new axes here adding a new InputManagerAxis to the array.
91-
/// </summary>
92-
private static readonly InputManagerAxis[] MRTKDefaultInputAxis =
93-
{
94-
new InputManagerAxis() { Name = CONTROLLER_LEFT_STICK_HORIZONTAL, Dead = 0.19f, Sensitivity = 1, Invert = false, Type = MappingAxisType.JoystickAxis, Axis = 1 },
95-
new InputManagerAxis() { Name = CONTROLLER_LEFT_STICK_VERTICAL, Dead = 0.19f, Sensitivity = 1, Invert = true, Type = MappingAxisType.JoystickAxis, Axis = 2 },
96-
new InputManagerAxis() { Name = XBOX_SHARED_TRIGGER, Dead = 0.19f, Sensitivity = 1, Invert = false, Type = MappingAxisType.JoystickAxis, Axis = 3 },
97-
new InputManagerAxis() { Name = CONTROLLER_RIGHT_STICK_HORIZONTAL, Dead = 0.19f, Sensitivity = 1, Invert = false, Type = MappingAxisType.JoystickAxis, Axis = 4 },
98-
new InputManagerAxis() { Name = CONTROLLER_RIGHT_STICK_VERTICAL, Dead = 0.19f, Sensitivity = 1, Invert = true, Type = MappingAxisType.JoystickAxis, Axis = 5 },
99-
new InputManagerAxis() { Name = XBOX_DPAD_HORIZONTAL, Dead = 0.19f, Sensitivity = 1, Invert = false, Type = MappingAxisType.JoystickAxis, Axis = 6 },
100-
new InputManagerAxis() { Name = XBOX_DPAD_VERTICAL, Dead = 0.19f, Sensitivity = 1, Invert = false, Type = MappingAxisType.JoystickAxis, Axis = 7 },
101-
new InputManagerAxis() { Name = CONTROLLER_LEFT_TRIGGER, Dead = 0.19f, Sensitivity = 1, Invert = false, Type = MappingAxisType.JoystickAxis, Axis = 9 },
102-
new InputManagerAxis() { Name = CONTROLLER_RIGHT_TRIGGER, Dead = 0.19f, Sensitivity = 1, Invert = false, Type = MappingAxisType.JoystickAxis, Axis = 10 },
103-
104-
new InputManagerAxis() { Name = XBOX_A, PositiveButton = "joystick button 0", Gravity = 1000, Dead = 0.001f, Sensitivity = 1000, Type = MappingAxisType.KeyOrMouseButton, Axis = 1 },
105-
new InputManagerAxis() { Name = XBOX_B, PositiveButton = "joystick button 1", Gravity = 1000, Dead = 0.001f, Sensitivity = 1000, Type = MappingAxisType.KeyOrMouseButton, Axis = 1 },
106-
new InputManagerAxis() { Name = XBOX_X, PositiveButton = "joystick button 2", Gravity = 1000, Dead = 0.001f, Sensitivity = 1000, Type = MappingAxisType.KeyOrMouseButton, Axis = 1 },
107-
new InputManagerAxis() { Name = XBOX_Y, PositiveButton = "joystick button 3", Gravity = 1000, Dead = 0.001f, Sensitivity = 1000, Type = MappingAxisType.KeyOrMouseButton, Axis = 1 },
108-
new InputManagerAxis() { Name = CONTROLLER_LEFT_BUMPER_OR_GRIP, PositiveButton = "joystick button 4", Gravity = 1000, Dead = 0.001f, Sensitivity = 1000, Type = MappingAxisType.KeyOrMouseButton, Axis = 1 },
109-
new InputManagerAxis() { Name = CONTROLLER_RIGHT_BUMPER_OR_GRIP, PositiveButton = "joystick button 5", Gravity = 1000, Dead = 0.001f, Sensitivity = 1000, Type = MappingAxisType.KeyOrMouseButton, Axis = 1 },
110-
new InputManagerAxis() { Name = CONTROLLER_LEFT_MENU, PositiveButton = "joystick button 6", Gravity = 1000, Dead = 0.001f, Sensitivity = 1000, Type = MappingAxisType.KeyOrMouseButton, Axis = 1 },
111-
new InputManagerAxis() { Name = CONTROLLER_RIGHT_MENU, PositiveButton = "joystick button 7", Gravity = 1000, Dead = 0.001f, Sensitivity = 1000, Type = MappingAxisType.KeyOrMouseButton, Axis = 1 },
112-
new InputManagerAxis() { Name = CONTROLLER_LEFT_STICK_CLICK, PositiveButton = "joystick button 8", Gravity = 1000, Dead = 0.001f, Sensitivity = 1000, Type = MappingAxisType.KeyOrMouseButton, Axis = 1 },
113-
new InputManagerAxis() { Name = CONTROLLER_RIGHT_STICK_CLICK, PositiveButton = "joystick button 9", Gravity = 1000, Dead = 0.001f, Sensitivity = 1000, Type = MappingAxisType.KeyOrMouseButton, Axis = 1 },
114-
};
115-
116-
public static readonly IEnumerable<string> MRTKDefaultInputMappingNames = new []
117-
{
118-
CONTROLLER_LEFT_STICK_HORIZONTAL,
119-
CONTROLLER_LEFT_STICK_VERTICAL,
120-
XBOX_SHARED_TRIGGER,
121-
CONTROLLER_RIGHT_STICK_HORIZONTAL,
122-
CONTROLLER_RIGHT_STICK_VERTICAL,
123-
XBOX_DPAD_HORIZONTAL,
124-
XBOX_DPAD_VERTICAL,
125-
CONTROLLER_LEFT_TRIGGER,
126-
CONTROLLER_RIGHT_TRIGGER,
127-
XBOX_A,
128-
XBOX_B,
129-
XBOX_X,
130-
XBOX_Y,
131-
CONTROLLER_LEFT_BUMPER_OR_GRIP,
132-
CONTROLLER_RIGHT_BUMPER_OR_GRIP,
133-
CONTROLLER_LEFT_MENU,
134-
CONTROLLER_RIGHT_MENU,
135-
CONTROLLER_LEFT_STICK_CLICK,
136-
CONTROLLER_RIGHT_STICK_CLICK
137-
};
138-
139-
/// <summary>
140-
/// As axes in newInputAxes are removed or renamed, move them here for proper clean-up in user projects.
141-
/// </summary>
142-
private static readonly InputManagerAxis[] ObsoleteMRTKInputAxes = { };
143-
144-
#endregion Mixed Reality Default Mappings configuration
65+
#endregion Configuration elements
14566

14667
#region Mappings Functions
14768

@@ -154,21 +75,11 @@ public class InputManagerAxis
15475
/// <param name="useToolkitAxes">Apply the Mixed Reality Toolkit defaults</param>
15576
/// <param name="removeMappings">If true, removes the selected mappings, either the defaults or the axisMappings array</param>
15677
/// <param name="axisMappings">Optional array of Axis Mappings, to configure your own custom set</param>
157-
public static void ApplyMappings(InputManagerAxis[] axisMappings = null)
78+
public static void ApplyMappings(InputManagerAxis[] axisMappings)
15879
{
15980
AssureInputManagerReference();
16081

161-
if (axisMappings == null)
162-
{
163-
foreach (InputManagerAxis axis in MRTKDefaultInputAxis)
164-
{
165-
if (!DoesAxisNameExist(axis.Name))
166-
{
167-
AddAxis(axis);
168-
}
169-
}
170-
}
171-
else
82+
if (axisMappings != null)
17283
{
17384
foreach (InputManagerAxis axis in axisMappings)
17485
{
@@ -191,29 +102,11 @@ public static void ApplyMappings(InputManagerAxis[] axisMappings = null)
191102
/// <param name="useToolkitAxes">Apply the Mixed Reality Toolkit defaults</param>
192103
/// <param name="removeMappings">If true, removes the selected mappings, either the defaults or the axisMappings array</param>
193104
/// <param name="axisMappings">Optional array of Axis Mappings, to configure your own custom set</param>
194-
public static void RemoveMappings(InputManagerAxis[] axisMappings = null)
105+
public static void RemoveMappings(InputManagerAxis[] axisMappings)
195106
{
196107
AssureInputManagerReference();
197108

198-
if (axisMappings == null)
199-
{
200-
foreach (InputManagerAxis axis in MRTKDefaultInputAxis)
201-
{
202-
if (DoesAxisNameExist(axis.Name))
203-
{
204-
RemoveAxis(axis.Name);
205-
}
206-
}
207-
208-
foreach (InputManagerAxis axis in ObsoleteMRTKInputAxes)
209-
{
210-
if (DoesAxisNameExist(axis.Name))
211-
{
212-
RemoveAxis(axis.Name);
213-
}
214-
}
215-
}
216-
else
109+
if (axisMappings != null)
217110
{
218111
foreach (InputManagerAxis axis in axisMappings)
219112
{

0 commit comments

Comments
 (0)