Skip to content

Commit 744411f

Browse files
authored
Merge branch 'develop' into docf-1179-fixedupdate-vs-update
2 parents b0da146 + 3a96dac commit 744411f

File tree

6 files changed

+69
-24
lines changed

6 files changed

+69
-24
lines changed

Assets/Tests/InputSystem/CoreTests_Devices.cs

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4162,13 +4162,40 @@ public void Devices_RemovingAndReaddingDevice_DoesNotAllocateMemory()
41624162
recorder.CollectFromAllThreads();
41634163
#endif
41644164

4165-
// We expect a single allocation for each call to ReportNewInputDevice when there is one disconnected device
4166-
//
4167-
int numberOfRepeats = 2;
4168-
int numberOfDisconnectedDevices = 1;
4169-
int numberOfCallsToReportNewInputDevicePerRun = 2;
4170-
int expectedAllocations = numberOfRepeats * numberOfDisconnectedDevices * numberOfCallsToReportNewInputDevicePerRun;
4171-
Assert.AreEqual(expectedAllocations, recorder.sampleBlockCount);
4165+
// No allocations are expected.
4166+
Assert.AreEqual(0, recorder.sampleBlockCount);
4167+
}
4168+
4169+
// Regression test to cover having null descriptor fields for a device. Some non-desktop gamepad device types do this.
4170+
[Test]
4171+
[Category("Devices")]
4172+
public void Devices_RemovingAndReaddingDeviceWithNullDescriptorFields_DoesNotThrow()
4173+
{
4174+
// InputDeviceDescription.ToJson writes empty string fields and not null values, whereas reporting a device via an incomplete description string will fully omit the fields.
4175+
string description = @"{
4176+
""type"": ""Gamepad"",
4177+
""product"": ""TestProduct""
4178+
}";
4179+
4180+
var deviceId = runtime.ReportNewInputDevice(description);
4181+
InputSystem.Update();
4182+
4183+
// "Unplug" device.
4184+
var removeEvent1 = DeviceRemoveEvent.Create(deviceId);
4185+
InputSystem.QueueEvent(ref removeEvent1);
4186+
InputSystem.Update();
4187+
4188+
// "Plug" it back in.
4189+
deviceId = runtime.ReportNewInputDevice(description);
4190+
InputSystem.Update();
4191+
4192+
// Repeat that sequence.
4193+
var removeEvent2 = DeviceRemoveEvent.Create(deviceId);
4194+
InputSystem.QueueEvent(ref removeEvent2);
4195+
InputSystem.Update();
4196+
4197+
runtime.ReportNewInputDevice(description);
4198+
InputSystem.Update();
41724199
}
41734200

41744201
[Test]

Packages/com.unity.inputsystem/CHANGELOG.md

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

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

13+
### Fixed
14+
- Fixed `NullReferenceException` from disconnecting and reconnecting a GXDKGamepad.
15+
16+
### Added
17+
- Added the display of the device flag `CanRunInBackground` in device debug view.
18+
- Added analytics for programmatic `InputAction` setup via `InputActionSetupExtensions` when exiting play-mode.
19+
20+
### Fixed
21+
- Fixed wrong mapping of Xbox Series S|X and Xbox One wireless controllers "View" button on macOS.[ISXB-385](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-385)
22+
1323
## [1.11.1] - 2024-09-26
1424

1525
### Fixed
@@ -47,7 +57,6 @@ however, it has to be formatted properly to pass verification tests.
4757
- Added tests for Input Action Editor UI for managing action maps (List, create, rename, delete) (ISX-2087)
4858
- Added automatic loading of custom extensions of InputProcessor, InputInteraction and InputBindingComposite [ISXB-856]](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-856).
4959
- Added an IME Input sample scene.
50-
- Added analytics for programmatic `InputAction` setup via `InputActionSetupExtensions`.
5160

5261
## [1.10.0] - 2024-07-24
5362

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: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,6 +2562,15 @@ private JsonParser.JsonString MakeEscapedJsonString(string theString)
25622562
// To avoid a very costly escape-skipping character-by-character string comparison in JsonParser.Json.Equals() we
25632563
// reconstruct an escaped string and make an escaped JsonParser.JsonString and use that for the comparison instead.
25642564
//
2565+
if (string.IsNullOrEmpty(theString))
2566+
{
2567+
return new JsonParser.JsonString
2568+
{
2569+
text = string.Empty, // text should be an empty string and not null for consistency on property comparisons
2570+
hasEscapes = false
2571+
};
2572+
}
2573+
25652574
var builder = new StringBuilder();
25662575
var length = theString.Length;
25672576
var hasEscapes = false;
@@ -2893,22 +2902,8 @@ internal void AddAvailableDevicesThatAreNowRecognized()
28932902

28942903
private bool ShouldRunDeviceInBackground(InputDevice device)
28952904
{
2896-
var runDeviceInBackground =
2897-
m_Settings.backgroundBehavior != InputSettings.BackgroundBehavior.ResetAndDisableAllDevices &&
2905+
return m_Settings.backgroundBehavior != InputSettings.BackgroundBehavior.ResetAndDisableAllDevices &&
28982906
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;
29122907
}
29132908

29142909
internal void OnFocusChanged(bool focus)

Packages/com.unity.inputsystem/InputSystem/Plugins/XInput/XboxGamepadMacOS.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ internal struct XInputControllerWirelessOSXState : IInputStateTypeInfo
111111
public enum Button
112112
{
113113
Start = 11,
114-
Select = 16,
114+
Select = 10,
115115
LeftThumbstickPress = 13,
116116
RightThumbstickPress = 14,
117117
LeftShoulder = 6,

0 commit comments

Comments
 (0)