A game about forced loneliness, made by TACStudios
1using UnityEngine.InputSystem.Layouts;
2using UnityEngine.InputSystem.LowLevel;
3
4////REVIEW: generalize this to AnyButton and add to more devices?
5
6namespace UnityEngine.InputSystem.Controls
7{
8 /// <summary>
9 /// A control that simply checks the entire state it's been assigned
10 /// for whether there's any non-zero bytes. If there are, the control
11 /// returns 1.0; otherwise it returns 0.0.
12 /// </summary>
13 /// <remarks>
14 /// This control is used by <see cref="Keyboard.anyKey"/> to create a button
15 /// that is toggled on as long as any of the keys on the keyboard is pressed.
16 /// </remarks>
17 /// <seealso cref="Keyboard.anyKey"/>
18 [InputControlLayout(hideInUI = true)]
19 public class AnyKeyControl : ButtonControl
20 {
21 ////TODO: wasPressedThisFrame and wasReleasedThisFrame
22
23 /// <summary>
24 /// Default initialization. Sets state size to 1 bit and format to
25 /// <see cref="InputStateBlock.FormatBit"/>.
26 /// </summary>
27 public AnyKeyControl()
28 {
29 m_StateBlock.sizeInBits = 1; // Should be overridden by whoever uses the control.
30 m_StateBlock.format = InputStateBlock.FormatBit;
31 }
32
33 /// <inheritdoc />
34 public override unsafe float ReadUnprocessedValueFromState(void* statePtr)
35 {
36 return this.CheckStateIsAtDefault(statePtr) ? 0.0f : 1.0f;
37 }
38 }
39}