Firstborn/Library/PackageCache/com.unity.inputsystem@1.5.1/InputSystem/Controls/AnyKeyControl.cs
Schaken-Mods 9092858a58 updated to the latest editor
I updated everything to the latest Unity Editor. Also realized I had the wrong shaders on my hairs, those are fixed and the hairs look MUCH better!
2023-05-07 17:43:11 -05:00

40 lines
1.4 KiB
C#

using UnityEngine.InputSystem.Layouts;
using UnityEngine.InputSystem.LowLevel;
////REVIEW: generalize this to AnyButton and add to more devices?
namespace UnityEngine.InputSystem.Controls
{
/// <summary>
/// A control that simply checks the entire state it's been assigned
/// for whether there's any non-zero bytes. If there are, the control
/// returns 1.0; otherwise it returns 0.0.
/// </summary>
/// <remarks>
/// This control is used by <see cref="Keyboard.anyKey"/> to create a button
/// that is toggled on as long as any of the keys on the keyboard is pressed.
/// </remarks>
/// <seealso cref="Keyboard.anyKey"/>
[InputControlLayout(hideInUI = true)]
public class AnyKeyControl : ButtonControl
{
////TODO: wasPressedThisFrame and wasReleasedThisFrame
/// <summary>
/// Default initialization. Sets state size to 1 bit and format to
/// <see cref="InputStateBlock.FormatBit"/>.
/// </summary>
public AnyKeyControl()
{
m_StateBlock.sizeInBits = 1; // Should be overridden by whoever uses the control.
m_StateBlock.format = InputStateBlock.FormatBit;
}
/// <inheritdoc />
public override unsafe float ReadUnprocessedValueFromState(void* statePtr)
{
return this.CheckStateIsAtDefault(statePtr) ? 0.0f : 1.0f;
}
}
}