Skip to content

Commit e35484f

Browse files
fixed issue where not all device flags were set properly
1 parent e12c5ef commit e35484f

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -919,18 +919,24 @@ private void RecreateDevice(InputDevice oldDevice, InternedString newLayout)
919919
var newDevice = InputDevice.Build<InputDevice>(newLayout, oldDevice.m_Variants,
920920
deviceDescription: oldDevice.m_Description);
921921

922-
// Preserve device properties that should not be changed by the re-creation
923-
// of a device.
922+
// Preserve device properties that should not be changed by the re-creation of a device.
923+
var preserveFlags = oldDevice.m_DeviceFlags & (InputDevice.DeviceFlags.HasEventMerger |
924+
InputDevice.DeviceFlags.HasStateCallbacks | InputDevice.DeviceFlags.HasEventPreProcessor);
924925
newDevice.m_DeviceId = oldDevice.m_DeviceId;
925926
newDevice.m_Description = oldDevice.m_Description;
927+
newDevice.m_DeviceFlags |= preserveFlags;
926928
if (oldDevice.native)
927929
newDevice.m_DeviceFlags |= InputDevice.DeviceFlags.Native;
928930
if (oldDevice.remote)
929931
newDevice.m_DeviceFlags |= InputDevice.DeviceFlags.Remote;
930932
if (!oldDevice.enabled)
931933
{
932-
newDevice.m_DeviceFlags |= InputDevice.DeviceFlags.DisabledStateHasBeenQueriedFromRuntime;
933-
newDevice.m_DeviceFlags |= InputDevice.DeviceFlags.DisabledInFrontend;
934+
var disableFlags = InputDevice.DeviceFlags.DisabledStateHasBeenQueriedFromRuntime;
935+
disableFlags |= oldDevice.m_DeviceFlags & InputDevice.DeviceFlags.DisabledInFrontend;
936+
disableFlags |= oldDevice.m_DeviceFlags & InputDevice.DeviceFlags.DisabledWhileInBackground;
937+
disableFlags |= oldDevice.m_DeviceFlags & InputDevice.DeviceFlags.DisabledInRuntime;
938+
939+
newDevice.m_DeviceFlags |= disableFlags;
934940
}
935941

936942
// Re-add.

0 commit comments

Comments
 (0)