Skip to content

Commit 64d3aed

Browse files
Add missing InputActionStateMonitorIndex file from last commit.
1 parent 22d5cf7 commit 64d3aed

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
namespace UnityEngine.InputSystem
2+
{
3+
/// <summary>
4+
/// Bit-packed id registered with <see cref="InputManager"/> for <see cref="InputActionState"/> state change monitors.
5+
/// Layout must match <c>TriggerState.kMaxNum*</c> limits on <see cref="InputActionState"/>.
6+
/// </summary>
7+
internal readonly struct InputActionStateMonitorIndex
8+
{
9+
readonly long m_Packed;
10+
11+
public InputActionStateMonitorIndex(long packed)
12+
{
13+
m_Packed = packed;
14+
}
15+
16+
public long Packed => m_Packed;
17+
18+
public static implicit operator long(InputActionStateMonitorIndex index) => index.m_Packed;
19+
20+
public static InputActionStateMonitorIndex FromPacked(long packed) => new InputActionStateMonitorIndex(packed);
21+
22+
public static InputActionStateMonitorIndex Create(int mapIndex, int controlIndex, int bindingIndex, int priority)
23+
{
24+
long result = controlIndex;
25+
result |= (long)bindingIndex << 24;
26+
result |= (long)mapIndex << 40;
27+
result |= (long)priority << 48;
28+
return new InputActionStateMonitorIndex(result);
29+
}
30+
31+
public int ControlIndex => (int)(m_Packed & 0x00ffffff);
32+
33+
public int BindingIndex => (int)((m_Packed >> 24) & 0xffff);
34+
35+
public int MapIndex => (int)((m_Packed >> 40) & 0xff);
36+
37+
/// <summary>
38+
/// Only the low 8 bits are stored; larger <see cref="InputAction.Priority"/> values truncate when packed.
39+
/// </summary>
40+
public int Priority => (int)((m_Packed >> 48) & 0xff);
41+
}
42+
}

Packages/com.unity.inputsystem/InputSystem/Actions/InputActionStateMonitorIndex.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)