Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions Packages/com.unity.inputsystem/InputSystem/Devices/InputDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
/// <summary>
/// In editor, it may differ from canRunInBackground depending on the gameViewFocus setting.
/// This property is used by Device Debug View
/// </summary>
/// <value>Whether the device should generate input while in the background.</value>
internal bool canDeviceRunInBackground
{
get
{
if ((m_DeviceFlags & DeviceFlags.CanRunInBackgroundHasBeenQueried) != 0)
return (m_DeviceFlags & DeviceFlags.CanRunInBackground) != 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
16 changes: 1 addition & 15 deletions Packages/com.unity.inputsystem/InputSystem/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this code is already done in canRunInBackground

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)
Expand Down