Skip to content

Commit f5d6714

Browse files
suearkinunityMorganHoaraujosepmariapujol-unity
authored
DOCS: Add information about IgnoreFocus to InputSettings.cs (#2359)
Co-authored-by: Morgan Hoarau <122548697+MorganHoarau@users.noreply.github.com> Co-authored-by: JosepMariaPujol <josep.pujol@unity3d.com>
1 parent 68d9a53 commit f5d6714

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Packages/com.unity.inputsystem/InputSystem/InputSettings.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,23 @@ public enum ScrollDeltaBehavior
855855
/// <summary>
856856
/// Determines how the applications behaves when running in the background. See <see cref="backgroundBehavior"/>.
857857
/// </summary>
858+
/// <remarks>
859+
/// Limitations:
860+
///
861+
/// Receiving input while the application is not in the foreground is platform and device-dependent, and should not be relied upon.
862+
/// IgnoreFocus does not grant the ability to receive input in the background; it only prevents the Input System from resetting/disabling devices on focus changes.
863+
///
864+
/// Specifically:
865+
///
866+
/// Keyboard: InputSystem doesn't receive events while unfocused.
867+
/// Even on platforms where OS-level hooks could technically capture background keyboard input, Unity doesn't forward it to the managed Input System.
868+
///
869+
/// Mouse: Only receives events when the cursor is hovering over the application window.
870+
///
871+
/// XR HMDs: May continue receiving tracking data while unfocused, depending on the XR runtime.
872+
/// These devices report canRunInBackground == true and are the primary use case for ResetAndDisableNonBackgroundDevices,
873+
/// which leaves them untouched while resetting everything else.
874+
/// </remarks>
858875
/// <seealso href="https://docs.unity3d.com/ScriptReference/Application-isFocused.html"/>
859876
/// <seealso href="https://docs.unity3d.com/ScriptReference/Application-runInBackground.html"/>
860877
/// <seealso cref="backgroundBehavior"/>
@@ -889,6 +906,11 @@ public enum BackgroundBehavior
889906

890907
/// <summary>
891908
/// Ignore all changes in focus and leave devices untouched. This also disables focus checks in <see cref="UI.InputSystemUIInputModule"/>.
909+
/// This mode doesn't disable devices when the application loses focus. It also doesn't reset or sync device state on focus changes.
910+
/// As a result, input controls may retain a stale state after focus transitions.
911+
/// For example, if a key is held when the application loses focus and released while unfocused, the Input System still reports that key as pressed
912+
/// when the focus returns. This is the expected behavior, not a bug.
913+
/// If you need a reliable state after focus changes, use ResetAndDisableNonBackgroundDevices (default) or ResetAndDisableAllDevices.
892914
/// </summary>
893915
IgnoreFocus = 2,
894916
}

0 commit comments

Comments
 (0)