Skip to content

Commit 1a05093

Browse files
authored
Merge pull request #16 from ExtendRealityLtd/fix/float-deadzone
fix(Transformation): provide deadzone value for float
2 parents 6bcb26f + 6e7c7de commit 1a05093

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Runtime/SharedResources/Scripts/Transformation/Conversion/CallbackContextToFloat.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
namespace Tilia.Input.UnityInputSystem.Transformation.Conversion
22
{
3+
using Malimbe.PropertySerializationAttribute;
4+
using Malimbe.XmlDocumentationAttribute;
35
using System;
46
using UnityEngine.Events;
57
using UnityEngine.InputSystem;
@@ -15,14 +17,22 @@ public class CallbackContextToFloat : CallbackContextTransformer<float, Callback
1517
[Serializable]
1618
public class UnityEvent : UnityEvent<float> { }
1719

20+
/// <summary>
21+
/// The minimum value to consider as a zero float value.
22+
/// </summary>
23+
[Serialized]
24+
[field: DocumentedByXml]
25+
public float DeadZoneValue { get; set; } = 0.00001f;
26+
1827
/// <summary>
1928
/// Transforms the given input <see cref="InputAction.CallbackContext"/> to the equivalent <see cref="float"/> value.
2029
/// </summary>
2130
/// <param name="input">The value to transform.</param>
2231
/// <returns>The transformed value.</returns>
2332
protected override float Process(InputAction.CallbackContext input)
2433
{
25-
return input.ReadValue<float>();
34+
float value = input.ReadValue<float>();
35+
return value >= DeadZoneValue ? value : 0f;
2636
}
2737
}
2838
}

0 commit comments

Comments
 (0)