File tree Expand file tree Collapse file tree
Packages/com.unity.inputsystem/InputSystem/Runtime Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1428,7 +1428,7 @@ public void Controls_OptimizedControls_TrivialControlsAreOptimized()
14281428 Assert . That ( mouse . position . x . optimizedControlDataType , Is . EqualTo ( InputStateBlock . FormatFloat ) ) ;
14291429 Assert . That ( mouse . position . y . optimizedControlDataType , Is . EqualTo ( InputStateBlock . FormatFloat ) ) ;
14301430 Assert . That ( mouse . position . optimizedControlDataType , Is . EqualTo ( InputStateBlock . FormatVector2 ) ) ;
1431- Assert . That ( mouse . leftButton . optimizedControlDataType , Is . EqualTo ( InputStateBlock . FormatInvalid ) ) ;
1431+ Assert . That ( mouse . leftButton . optimizedControlDataType , Is . EqualTo ( InputStateBlock . FormatBit ) ) ;
14321432
14331433 InputSystem . settings . SetInternalFeatureFlag ( InputFeatureNames . kUseOptimizedControls , false ) ;
14341434 Assert . That ( mouse . position . x . optimizedControlDataType , Is . EqualTo ( InputStateBlock . FormatInvalid ) ) ;
Original file line number Diff line number Diff line change @@ -378,6 +378,20 @@ internal void UpdateWasPressedEditor()
378378
379379#endif // UNITY_EDITOR
380380
381+ protected override FourCC CalculateOptimizedControlDataType ( )
382+ {
383+ if ( clamp == Clamp . None &&
384+ invert == false &&
385+ normalize == false &&
386+ scale == false &&
387+ m_StateBlock . format == InputStateBlock . FormatBit &&
388+ m_StateBlock . sizeInBits == 1 &&
389+ m_StateBlock . bitOffset == 0 )
390+ return InputStateBlock . FormatBit ;
391+
392+ return base . CalculateOptimizedControlDataType ( ) ;
393+ }
394+
381395 // We make the current global default button press point available as a static so that we don't have to
382396 // constantly make the hop from InputSystem.settings -> InputManager.m_Settings -> defaultButtonPressPoint.
383397 internal static float s_GlobalDefaultButtonPressPoint ;
Original file line number Diff line number Diff line change @@ -252,13 +252,7 @@ protected override FourCC CalculateOptimizedControlDataType()
252252 if (
253253 m_StateBlock . sizeInBits == PoseState . kSizeInBytes * 8 &&
254254 m_StateBlock . bitOffset == 0 &&
255- isTracked . m_StateBlock . format == InputStateBlock . kFormatBit &&
256- isTracked . m_StateBlock . sizeInBits == 1 &&
257- isTracked . m_StateBlock . bitOffset == 0 &&
258- isTracked . clamp == AxisControl . Clamp . None &&
259- isTracked . invert == false &&
260- isTracked . normalize == false &&
261- isTracked . scale == false &&
255+ isTracked . optimizedControlDataType == InputStateBlock . kFormatBit &&
262256 trackingState . optimizedControlDataType == InputStateBlock . kFormatInt &&
263257 position . optimizedControlDataType == InputStateBlock . kFormatVector3 &&
264258 rotation . optimizedControlDataType == InputStateBlock . kFormatQuaternion &&
You can’t perform that action at this time.
0 commit comments