@@ -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