diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index 5a555b2373..a63af1b374 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -10,6 +10,9 @@ however, it has to be formatted properly to pass verification tests. ## [Unreleased] - yyyy-mm-dd +### Added +- Added the display of the device flag `CanRunInBackground` in device debug view. + ## [1.11.1] - 2024-09-26 ### Fixed diff --git a/Packages/com.unity.inputsystem/InputSystem/Devices/InputDevice.cs b/Packages/com.unity.inputsystem/InputSystem/Devices/InputDevice.cs index 4996ba8f02..f2b469bc73 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Devices/InputDevice.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Devices/InputDevice.cs @@ -255,6 +255,18 @@ public bool canRunInBackground return !(this is Pointer || this is Keyboard); // Anything but pointers and keyboards considered as being able to run in background. #endif + return canDeviceRunInBackground; + } + } + /// + /// In editor, it may differ from canRunInBackground depending on the gameViewFocus setting. + /// This property is used by Device Debug View + /// + /// Whether the device should generate input while in the background. + internal bool canDeviceRunInBackground + { + get + { if ((m_DeviceFlags & DeviceFlags.CanRunInBackgroundHasBeenQueried) != 0) return (m_DeviceFlags & DeviceFlags.CanRunInBackground) != 0; diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Debugger/InputDeviceDebuggerWindow.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Debugger/InputDeviceDebuggerWindow.cs index d38943abc8..bda67adbf8 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Debugger/InputDeviceDebuggerWindow.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Debugger/InputDeviceDebuggerWindow.cs @@ -347,6 +347,8 @@ private void UpdateDeviceFlags() flags.Add("DisabledInRuntime"); if (m_Device.disabledWhileInBackground) flags.Add("DisabledWhileInBackground"); + if (m_Device.canDeviceRunInBackground) + flags.Add("CanRunInBackground"); m_DeviceFlags = m_Device.m_DeviceFlags; m_DeviceFlagsString = string.Join(", ", flags.ToArray()); } diff --git a/Packages/com.unity.inputsystem/InputSystem/InputManager.cs b/Packages/com.unity.inputsystem/InputSystem/InputManager.cs index eba6c66f9a..989ec623cf 100644 --- a/Packages/com.unity.inputsystem/InputSystem/InputManager.cs +++ b/Packages/com.unity.inputsystem/InputSystem/InputManager.cs @@ -2893,22 +2893,8 @@ internal void AddAvailableDevicesThatAreNowRecognized() private bool ShouldRunDeviceInBackground(InputDevice device) { - var runDeviceInBackground = - m_Settings.backgroundBehavior != InputSettings.BackgroundBehavior.ResetAndDisableAllDevices && + return m_Settings.backgroundBehavior != InputSettings.BackgroundBehavior.ResetAndDisableAllDevices && device.canRunInBackground; - - // In editor, we may override canRunInBackground depending on the gameViewFocus setting. - #if UNITY_EDITOR - if (runDeviceInBackground) - { - if (m_Settings.editorInputBehaviorInPlayMode == InputSettings.EditorInputBehaviorInPlayMode.AllDevicesRespectGameViewFocus) - runDeviceInBackground = false; - else if (m_Settings.editorInputBehaviorInPlayMode == InputSettings.EditorInputBehaviorInPlayMode.PointersAndKeyboardsRespectGameViewFocus) - runDeviceInBackground = !(device is Pointer || device is Keyboard); - } - #endif - - return runDeviceInBackground; } internal void OnFocusChanged(bool focus)