Skip to content

FIX: Add test and fix for multiple touchscreen input bug.#2434

Open
Darren-Kelly-Unity wants to merge 2 commits into
developfrom
bugfix/UUM-112247-multiple-touchscreens-incorrect-input
Open

FIX: Add test and fix for multiple touchscreen input bug.#2434
Darren-Kelly-Unity wants to merge 2 commits into
developfrom
bugfix/UUM-112247-multiple-touchscreens-incorrect-input

Conversation

@Darren-Kelly-Unity

Copy link
Copy Markdown
Collaborator

Purpose of this PR

Fixes a bug (IN-108611) where an ongoing touch on one physical touchscreen could be incorrectly updated by touch events originating from a second physical touchscreen, when both screens reported the same touchId. The root cause was that three touch-matching code paths in Touchscreen.cs identified touches by touchId alone, ignoring displayIndex.

Release Notes

[IN-108611] Input System — Bug Fixes

  • Fixed: Touch events from one physical touchscreen incorrectly updating touch state on another touchscreen when both screens reported the same touchId.

Functional Testing status

  • Automated: New regression test Devices_TouchMoveOnSecondDisplay_DoesNotUpdateTouchOnFirstDisplay added to TouchscreenMultiDisplayTests.cs, covering the exact failure sequence (two Began events with the same touchId on different displayIndex values, followed by a Moved from one screen verifying the other is untouched).
  • Manual: Reproducible via two physical touchscreen monitors per the original bug report steps (hold finger on screen 1, swipe on screen 2).

Performance Testing Status

No performance impact. The three changed comparisons each add a single byte comparison (displayIndex) to an existing conditional — no additional allocations, iterations, or data structure changes.

Overall Product Risks

Technical Risk: 1 — Self-contained fix to three closely related conditions in one file. Behaviour change is additive (stricter matching); single-screen setups are entirely unaffected since displayIndex will always match itself.

Halo Effect: 1 — Could affect any code path relying on Touchscreen with multi-display touch input, but the existing behaviour in those paths was already incorrect.

Class diagram

Changes analysed from origin/develop...HEAD

Class diagram
classDiagram
    class Touchscreen {
        «modified» OnStateEvent()
        «modified» GetCurrentValueAsObject()
        «modified» MergeForward()
    }
Loading

@u-pr u-pr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

May require changes

The PR addresses the touch ID collision bug effectively, but the introduced strict matching causes a regression for cross-display simulated touches.

🤖 Helpful? 👍/👎

@codecov-github-com

codecov-github-com Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

@@             Coverage Diff              @@
##           develop    #2434       +/-   ##
============================================
+ Coverage    58.58%   79.01%   +20.43%     
============================================
  Files          738      766       +28     
  Lines       135831   140369     +4538     
============================================
+ Hits         79570   110917    +31347     
+ Misses       56261    29452    -26809     
Flag Coverage Δ
inputsystem_MacOS_6000.0 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.0_project 77.47% <100.00%> (+0.22%) ⬆️
inputsystem_MacOS_6000.3 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.3_project 77.47% <100.00%> (+0.25%) ⬆️
inputsystem_MacOS_6000.4 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.4_project 77.48% <100.00%> (+0.25%) ⬆️
inputsystem_MacOS_6000.5 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.5_project 77.52% <100.00%> (+0.25%) ⬆️
inputsystem_MacOS_6000.6 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.6_project 77.52% <100.00%> (+0.25%) ⬆️
inputsystem_Ubuntu_6000.0 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.0_project 77.38% <100.00%> (+0.23%) ⬆️
inputsystem_Ubuntu_6000.3 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.3_project 77.38% <100.00%> (+0.25%) ⬆️
inputsystem_Ubuntu_6000.4 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.4_project 77.39% <100.00%> (+0.25%) ⬆️
inputsystem_Ubuntu_6000.5 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.5_project 77.42% <100.00%> (+0.25%) ⬆️
inputsystem_Ubuntu_6000.6 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.6_project 77.43% <100.00%> (+0.26%) ⬆️
inputsystem_Windows_6000.0 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.0_project 77.60% <100.00%> (+0.22%) ⬆️
inputsystem_Windows_6000.3 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.3_project 77.59% <100.00%> (+0.25%) ⬆️
inputsystem_Windows_6000.4 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.4_project 77.60% <100.00%> (+0.25%) ⬆️
inputsystem_Windows_6000.5 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.5_project 77.65% <100.00%> (+0.25%) ⬆️
inputsystem_Windows_6000.6 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.6_project 77.65% <100.00%> (+0.25%) ⬆️

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

Files with missing lines Coverage Δ
.../Tests/InputSystem/TouchscreenMultiDisplayTests.cs 100.00% <100.00%> (ø)
...tsystem/InputSystem/Runtime/Devices/Touchscreen.cs 91.26% <100.00%> (+90.96%) ⬆️
...m/Runtime/Plugins/EnhancedTouch/TouchSimulation.cs 90.64% <100.00%> (+88.63%) ⬆️

... and 277 files with indirect coverage changes

ℹ️ Need help interpreting these results?

@Darren-Kelly-Unity Darren-Kelly-Unity changed the title Add test and fix for multiple touchscreen input bug. FIX: Add test and fix for multiple touchscreen input bug. Jun 12, 2026

@u-pr u-pr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perfect

Solid fix for multi-display touch matching with comprehensive automated test coverage.

🤖 Helpful? 👍/👎

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.

1 participant