Skip to content

Commit 5cfed50

Browse files
authored
NEW: Added canRunInBackground flag in device debug view (#2013)
1 parent 026cdcc commit 5cfed50

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ however, it has to be formatted properly to pass verification tests.
1010

1111
## [Unreleased] - yyyy-mm-dd
1212

13+
### Added
14+
- Added the display of the device flag `CanRunInBackground` in device debug view.
15+
1316
## [1.11.1] - 2024-09-26
1417

1518
### Fixed

Packages/com.unity.inputsystem/InputSystem/Devices/InputDevice.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,18 @@ public bool canRunInBackground
255255
return !(this is Pointer || this is Keyboard); // Anything but pointers and keyboards considered as being able to run in background.
256256
#endif
257257

258+
return canDeviceRunInBackground;
259+
}
260+
}
261+
/// <summary>
262+
/// In editor, it may differ from canRunInBackground depending on the gameViewFocus setting.
263+
/// This property is used by Device Debug View
264+
/// </summary>
265+
/// <value>Whether the device should generate input while in the background.</value>
266+
internal bool canDeviceRunInBackground
267+
{
268+
get
269+
{
258270
if ((m_DeviceFlags & DeviceFlags.CanRunInBackgroundHasBeenQueried) != 0)
259271
return (m_DeviceFlags & DeviceFlags.CanRunInBackground) != 0;
260272

Packages/com.unity.inputsystem/InputSystem/Editor/Debugger/InputDeviceDebuggerWindow.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ private void UpdateDeviceFlags()
347347
flags.Add("DisabledInRuntime");
348348
if (m_Device.disabledWhileInBackground)
349349
flags.Add("DisabledWhileInBackground");
350+
if (m_Device.canDeviceRunInBackground)
351+
flags.Add("CanRunInBackground");
350352
m_DeviceFlags = m_Device.m_DeviceFlags;
351353
m_DeviceFlagsString = string.Join(", ", flags.ToArray());
352354
}

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

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2893,22 +2893,8 @@ internal void AddAvailableDevicesThatAreNowRecognized()
28932893

28942894
private bool ShouldRunDeviceInBackground(InputDevice device)
28952895
{
2896-
var runDeviceInBackground =
2897-
m_Settings.backgroundBehavior != InputSettings.BackgroundBehavior.ResetAndDisableAllDevices &&
2896+
return m_Settings.backgroundBehavior != InputSettings.BackgroundBehavior.ResetAndDisableAllDevices &&
28982897
device.canRunInBackground;
2899-
2900-
// In editor, we may override canRunInBackground depending on the gameViewFocus setting.
2901-
#if UNITY_EDITOR
2902-
if (runDeviceInBackground)
2903-
{
2904-
if (m_Settings.editorInputBehaviorInPlayMode == InputSettings.EditorInputBehaviorInPlayMode.AllDevicesRespectGameViewFocus)
2905-
runDeviceInBackground = false;
2906-
else if (m_Settings.editorInputBehaviorInPlayMode == InputSettings.EditorInputBehaviorInPlayMode.PointersAndKeyboardsRespectGameViewFocus)
2907-
runDeviceInBackground = !(device is Pointer || device is Keyboard);
2908-
}
2909-
#endif
2910-
2911-
return runDeviceInBackground;
29122898
}
29132899

29142900
internal void OnFocusChanged(bool focus)

0 commit comments

Comments
 (0)