Skip to content

NEW: Input consumption - Priorities instead of complexity [ISX-2510]#2402

Open
Darren-Kelly-Unity wants to merge 92 commits into
developfrom
proof-of-concept/input-consumption
Open

NEW: Input consumption - Priorities instead of complexity [ISX-2510]#2402
Darren-Kelly-Unity wants to merge 92 commits into
developfrom
proof-of-concept/input-consumption

Conversation

@Darren-Kelly-Unity
Copy link
Copy Markdown
Collaborator

@Darren-Kelly-Unity Darren-Kelly-Unity commented Mar 31, 2026

Purpose of this PR

Implements priority-based shortcut overlap resolution for ISX-2510. Adds a new InputAction.Priority property and a shortcutKeysUseActionPriority setting so users can explicitly control which actions win when multiple bindings share the same control — replacing the opaque automatic complexity calculation that caused unpredictable results.

Release Notes

  • [ISX-2510] Added InputAction.Priority property (range 0–65535) to let users assign explicit per-action priority for shortcut overlap resolution.
  • [ISX-2510] Added InputSettings.shortcutKeysUseActionPriority setting. When enabled, overlap resolution uses action priority instead of automatic composite complexity. Priority field is shown in the Input Actions editor when this mode is active.
  • [ISX-2510] shortcutKeysConsumeInput (complexity-based resolution) and shortcutKeysUseActionPriority (priority-based resolution) are now independent; priority mode takes precedence when both are enabled.

Functional Testing status

  • New test file CoreTests_ActionsPriority.cs (971 lines) covers priority assignment, clamping, overlap suppression, same-priority co-performance, and interaction with shortcutKeysConsumeInput.
  • Existing CoreTests_Actions.cs updated for renamed internal controlGroupingAndComplexitycontrolGroupingAndPriority field.
  • Manual testing: verified Priority field appears/disappears in the Input Actions editor when toggling shortcutKeysUseActionPriority in Project Settings.

Performance Testing Status

No performance impact. The priority resolution path follows the same O(n²) grouping loop as the existing complexity path; no additional allocations.

Overall Product Risks

Technical Risk: 2 — Replaces internal grouping logic in InputActionState that has many edge cases; complexity path is preserved as a fallback, but the two paths share the same memory layout (controlGroupingAndPriority). Regression risk is mitigated by the new test suite.

Halo Effect: 1 — Change is opt-in via a new setting; existing projects using shortcutKeysConsumeInput are unaffected unless they also enable shortcutKeysUseActionPriority.

Class diagram

Changes across origin/develop...HEAD — new InputActionStateMonitorIndex struct, InputAction.Priority, InputSettings.shortcutKeysUseActionPriority, and the internal ControlGroupingTable.

Class diagram
classDiagram
  direction TB

  class InputAction {
    +int Priority
    +int MinPriority$
    +int MaxPriority$
    +ClampPriority(int) int$
    -int m_Priority
    ~OnActionPriorityChanged()
  }

  class InputSettings {
    +bool shortcutKeysConsumeInput
    +bool shortcutKeysUseActionPriority
    ~bool IsShortcutResolutionUsingActionPriority
    ~bool IsShortcutResolutionUsingComplexity
    ~bool IsShortcutComplexityModifierOrderActive
    -bool m_ShortcutKeysUseActionPriority
  }

  class InputActionState {
    -ushort* controlGroupingAndPriority
    +InitializeControlGrouping()
    ~OnActionPriorityChanged(InputAction)
    -GetControlMonitorGroupIndex(int) uint
    -GetControlBindingPriority(int) int
  }

  class ControlGroupingTable {
    <<static>>
    +int Stride$
    +GroupElementIndex(int) int$
    +PriorityElementIndex(int) int$
  }

  class InputActionStateMonitorIndex {
    <<struct>>
    +long Packed
    +int ControlIndex
    +int BindingIndex
    +int MapIndex
    +int Priority
    +Create(int,int,int,int) InputActionStateMonitorIndex$
    +FromPacked(long) InputActionStateMonitorIndex$
  }

  class InputActionMap {
    ~InputActionState m_State
  }

  InputActionState --> ControlGroupingTable : uses
  InputActionState --> InputSettings : reads
  InputActionState --> InputActionStateMonitorIndex : creates
  InputAction --> InputActionMap : belongs to
  InputActionMap --> InputActionState : owns
  InputAction ..> InputActionState : notifies priority
Loading

Documentation Impact

No new pages required. Both InputAction.Priority and InputSettings.shortcutKeysUseActionPriority are already documented on this branch:

  • Settings.md — shortcut resolution settings table (rows covering both modes)
  • Actions.md — "Overlapping bindings and action priority" section with code example

Copy link
Copy Markdown
Contributor

@u-pr u-pr Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May require changes
The review identified several issues ranging from potential runtime exceptions and logic regressions to documentation mismatches. Most notably, there's a priority clamping issue that causes value wrap-around and a potential logic regression in how composite bindings are handled compared to previous versions.

🤖 Helpful? 👍/👎

Comment thread Assets/Samples/ProjectWideActions/ProjectWideActionsExample.cs Outdated
Comment thread Packages/com.unity.inputsystem/InputSystem/Actions/InputActionState.cs Outdated
Comment thread Packages/com.unity.inputsystem/InputSystem/Actions/InputActionState.cs Outdated
Comment thread Packages/com.unity.inputsystem/InputSystem/Actions/InputActionState.cs Outdated
Comment thread Packages/com.unity.inputsystem/InputSystem/Actions/InputActionState.cs Outdated
@codecov-github-com
Copy link
Copy Markdown

codecov-github-com Bot commented Mar 31, 2026

Codecov Report

Attention: Patch coverage is 91.56080% with 93 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...itor/UITKAssetEditor/Views/ActionPropertiesView.cs 27.77% 26 Missing ⚠️
...ets/Tests/InputSystem/CoreTests_ActionsPriority.cs 96.81% 18 Missing ⚠️
...putSystem/Editor/Settings/InputSettingsProvider.cs 0.00% 16 Missing ⚠️
...em/InputSystem/Runtime/Actions/InputActionState.cs 90.76% 12 Missing ⚠️
...System/Editor/UITKAssetEditor/Commands/Commands.cs 0.00% 10 Missing ⚠️
...m/InputSystem/Runtime/InputManagerStateMonitors.cs 97.07% 5 Missing ⚠️
...tem/InputSystem/Runtime/Utilities/MemoryHelpers.cs 66.66% 5 Missing ⚠️
...em/Editor/UITKAssetEditor/SerializedInputAction.cs 66.66% 1 Missing ⚠️
@@             Coverage Diff             @@
##           develop    #2402      +/-   ##
===========================================
+ Coverage    78.13%   78.55%   +0.42%     
===========================================
  Files          483      759     +276     
  Lines        98770   129903   +31133     
===========================================
+ Hits         77169   102049   +24880     
- Misses       21601    27854    +6253     
Flag Coverage Δ
inputsystem_MacOS_2021.3 ?
inputsystem_MacOS_2021.3_project ?
inputsystem_MacOS_6000.0 5.31% <5.11%> (+<0.01%) ⬆️
inputsystem_MacOS_6000.0_project 77.40% <91.46%> (+0.10%) ⬆️
inputsystem_MacOS_6000.2 ?
inputsystem_MacOS_6000.2_project ?
inputsystem_MacOS_6000.3 5.31% <5.11%> (+<0.01%) ⬆️
inputsystem_MacOS_6000.3_project 77.40% <91.46%> (+0.12%) ⬆️
inputsystem_MacOS_6000.4 5.32% <5.11%> (+<0.01%) ⬆️
inputsystem_MacOS_6000.4_project 77.41% <91.46%> (+0.13%) ⬆️
inputsystem_MacOS_6000.5 5.31% <5.11%> (+<0.01%) ⬆️
inputsystem_MacOS_6000.5_project 77.45% <91.46%> (+0.13%) ⬆️
inputsystem_MacOS_6000.6 5.31% <5.11%> (+<0.01%) ⬆️
inputsystem_MacOS_6000.6_project 77.45% <91.46%> (+0.13%) ⬆️
inputsystem_Ubuntu_2021.3 ?
inputsystem_Ubuntu_2021.3_project ?
inputsystem_Ubuntu_2022.3 ?
inputsystem_Ubuntu_6000.0 5.32% <5.11%> (+<0.01%) ⬆️
inputsystem_Ubuntu_6000.0_project 77.31% <91.55%> (+0.10%) ⬆️
inputsystem_Ubuntu_6000.2 ?
inputsystem_Ubuntu_6000.2_project ?
inputsystem_Ubuntu_6000.3 5.32% <5.11%> (+<0.01%) ⬆️
inputsystem_Ubuntu_6000.3_project 77.31% <91.55%> (+0.13%) ⬆️
inputsystem_Ubuntu_6000.4 5.32% <5.11%> (+<0.01%) ⬆️
inputsystem_Ubuntu_6000.4_project 77.32% <91.55%> (+0.13%) ⬆️
inputsystem_Ubuntu_6000.5 5.31% <5.11%> (+<0.01%) ⬆️
inputsystem_Ubuntu_6000.5_project 77.35% <91.55%> (+0.13%) ⬆️
inputsystem_Ubuntu_6000.6 5.31% <5.11%> (+<0.01%) ⬆️
inputsystem_Ubuntu_6000.6_project 77.35% <91.55%> (+0.13%) ⬆️
inputsystem_Windows_2021.3 ?
inputsystem_Windows_2021.3_project ?
inputsystem_Windows_6000.0 5.31% <5.11%> (+<0.01%) ⬆️
inputsystem_Windows_6000.0_project 77.53% <91.55%> (+0.10%) ⬆️
inputsystem_Windows_6000.2 ?
inputsystem_Windows_6000.2_project ?
inputsystem_Windows_6000.3 5.31% <5.11%> (+<0.01%) ⬆️
inputsystem_Windows_6000.3_project 77.52% <91.55%> (+0.12%) ⬆️
inputsystem_Windows_6000.4 5.32% <5.11%> (+<0.01%) ⬆️
inputsystem_Windows_6000.4_project 77.53% <91.55%> (+0.12%) ⬆️
inputsystem_Windows_6000.5 5.31% <5.11%> (+<0.01%) ⬆️
inputsystem_Windows_6000.5_project 77.58% <91.55%> (+0.13%) ⬆️
inputsystem_Windows_6000.6 5.31% <5.11%> (+<0.01%) ⬆️
linux_2021.3_pkg ?
linux_2021.3_project ?
linux_2022.3_pkg ?
linux_2022.3_project ?
linux_6000.0_pkg ?
linux_6000.0_project ?
linux_6000.1_pkg ?
linux_6000.1_project ?
linux_6000.2_pkg ?
linux_6000.2_project ?
linux_trunk_pkg ?
linux_trunk_project ?
mac_2021.3_pkg ?
mac_2021.3_project ?
mac_2022.3_pkg ?
mac_2022.3_project ?
mac_6000.0_pkg ?
mac_6000.0_project ?
mac_6000.1_pkg ?
mac_6000.1_project ?
mac_6000.2_pkg ?
mac_6000.2_project ?
mac_trunk_pkg ?
mac_trunk_project ?
win_2021.3_pkg ?
win_2021.3_project ?
win_2022.3_pkg ?
win_2022.3_project ?
win_6000.0_pkg ?
win_6000.0_project ?
win_6000.1_pkg ?
win_6000.1_project ?
win_6000.2_pkg ?
win_6000.2_project ?
win_trunk_pkg ?
win_trunk_project ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Assets/Samples/InGameHints/InGameHintsActions.cs 15.04% <ø> (-2.66%) ⬇️
Assets/Tests/InputSystem/CoreTests_Actions.cs 98.09% <100.00%> (-0.32%) ⬇️
Assets/Tests/InputSystem/CoreTests_Analytics.cs 99.27% <100.00%> (-0.10%) ⬇️
Assets/Tests/InputSystem/CoreTests_Editor.cs 97.70% <100.00%> (-0.26%) ⬇️
Assets/Tests/InputSystem/CoreTests_State.cs 96.47% <100.00%> (+0.04%) ⬆️
...sts/InputSystem/InputActionCodeGeneratorActions.cs 55.69% <ø> (-3.80%) ⬇️
...nputSystem/Actions/InputActionStateMonitorIndex.cs 100.00% <100.00%> (ø)
...InputSystem/Editor/Analytics/InputBuildAnalytic.cs 78.02% <100.00%> (-1.59%) ⬇️
...tor/UITKAssetEditor/InputActionsEditorConstants.cs 100.00% <100.00%> (ø)
...untime/Actions/Composites/ButtonWithOneModifier.cs 100.00% <100.00%> (ø)
... and 26 more

... and 272 files with indirect coverage changes

ℹ️ Need help interpreting these results?

Copy link
Copy Markdown
Collaborator

@ekcoh ekcoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting up this draft PR. I looked through the tests only so far and I think we should have a discussion around it which would be more helpful than doing asynchronous feedback on the comments. Test cases generally make sense but I fail to decipher some differences and rules in them I fail to understand. Also I am missing tests using priorities when interaction is not a shortcut modifier, I would assume the same rules apply regardless of binding? I think there is opportunity to reduce code diff here by doing some code reuse in the tests without having tests full of if statements.

I also think it would be good to have tests with repeated input which I mentioned before. I didn't spot any such tests unless I missed something. This would look like e.g. with a binding 'X', here value of X button provided as binary

X:                 0 1 1
Action 1 (Prio 1): 0 - 0
Action 2 (Prio 2): 0 1 0
                   a b c

   a: button up, nothing happens
   b: button down, triggers both, but only action 2 fires notification since higher prio
   c: button down again (repeat), triggers none since action 1 saw and reacted to state transition but did not fire

Comment thread Assets/Tests/InputSystem/CoreTests_Actions.cs Outdated
Comment thread Assets/Tests/InputSystem/CoreTests_Actions.cs Outdated
Comment thread Assets/Tests/InputSystem/CoreTests_Actions.cs Outdated
Comment thread Assets/Tests/InputSystem/CoreTests_Actions.cs Outdated
Comment thread Assets/Tests/InputSystem/CoreTests_Actions.cs Outdated
Comment thread Assets/Tests/InputSystem/CoreTests_Actions.cs Outdated
Comment thread Assets/Tests/InputSystem/CoreTests_Actions.cs Outdated
Comment thread Assets/Tests/InputSystem/CoreTests_Actions.cs Outdated
Comment thread Assets/Tests/InputSystem/CoreTests_Actions.cs Outdated
Comment thread Assets/Tests/InputSystem/CoreTests_Actions.cs Outdated
@suearkinunity suearkinunity self-requested a review June 2, 2026 09:36
Copy link
Copy Markdown
Collaborator

@suearkinunity suearkinunity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of repetition between Actions.md and Settings.md; please condense the information to one page and link to it from the other.

Comment thread Packages/com.unity.inputsystem/Documentation~/Actions.md Outdated
Comment thread Packages/com.unity.inputsystem/Documentation~/Actions.md Outdated
Comment thread Packages/com.unity.inputsystem/Documentation~/Actions.md Outdated
Comment thread Packages/com.unity.inputsystem/Documentation~/Actions.md Outdated
Comment thread Packages/com.unity.inputsystem/Documentation~/Actions.md Outdated
Comment thread Packages/com.unity.inputsystem/Documentation~/Actions.md Outdated
Comment thread Packages/com.unity.inputsystem/Documentation~/Actions.md Outdated
Comment thread Packages/com.unity.inputsystem/Documentation~/Settings.md Outdated
Comment thread Packages/com.unity.inputsystem/Documentation~/Settings.md
Comment thread Packages/com.unity.inputsystem/Documentation~/ActionBindings.md Outdated
Darren-Kelly-Unity and others added 24 commits June 2, 2026 12:02
Co-authored-by: Sue Arkin <85237015+suearkinunity@users.noreply.github.com>
Co-authored-by: Sue Arkin <85237015+suearkinunity@users.noreply.github.com>
Co-authored-by: Sue Arkin <85237015+suearkinunity@users.noreply.github.com>
Co-authored-by: Sue Arkin <85237015+suearkinunity@users.noreply.github.com>
Co-authored-by: Sue Arkin <85237015+suearkinunity@users.noreply.github.com>
Co-authored-by: Sue Arkin <85237015+suearkinunity@users.noreply.github.com>
Co-authored-by: Sue Arkin <85237015+suearkinunity@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
EditorPlatformType is more granular than SystemType — both MacOs13 and
MacOs13Arm resolve to SystemType.MacOS, which caused duplicate job key
errors after the Wrench 2.12.0 bump added MacOs13Arm to the default
platform set. Switching to EditorPlatformType makes each job name unique.

Also removes the temporary ExcludeUnsupportedPlatforms workaround for
Unity 6.6 Mac jobs, which should no longer be needed with Wrench 2.12.0.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants