Skip to content
Open
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
24 changes: 24 additions & 0 deletions Assets/Tests/InputSystem.Editor/InputActionsEditorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
{
base.OneTimeSetUp();
m_Asset = AssetDatabaseUtils.CreateAsset<InputActionAsset>();
m_Asset.AddControlScheme(new InputControlScheme("test"));
var actionMap = m_Asset.AddActionMap("First Name");
m_Asset.AddActionMap("Second Name");
m_Asset.AddActionMap("Third Name");
Expand Down Expand Up @@ -234,5 +235,28 @@
// Check on the asset side
Assert.That(m_Window.currentAssetInEditor.actionMaps[0].actions[1].name, Is.EqualTo("New Name"));
}

/// <summary>
/// <see href="https://jira.unity3d.com/browse/ISXB-1607">ISXB-1607</see>
/// Fix an out of range exception when pressing undo after creating and editing a new control scheme.
/// </summary>
/// <returns></returns>
[UnityTest]
[Ignore("Currently this is difficult to test, Darren - re-visit once we have converted the advanced dropdown to UIToolkit")]
public IEnumerator CanUndoActionMap_ControlSchemeEdit()
{
var controlSchemeToolbarMenu = m_Window.rootVisualElement.Q("control-schemes-toolbar-menu");

Check warning on line 248 in Assets/Tests/InputSystem.Editor/InputActionsEditorTests.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Assets/Tests/InputSystem.Editor/InputActionsEditorTests.cs#L247-L248

Added lines #L247 - L248 were not covered by tests

// changing the selection triggers a state change, wait for the scheduler to process the frame
yield return WaitForSchedulerLoop();
yield return WaitForNotDirty();

Check warning on line 252 in Assets/Tests/InputSystem.Editor/InputActionsEditorTests.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Assets/Tests/InputSystem.Editor/InputActionsEditorTests.cs#L251-L252

Added lines #L251 - L252 were not covered by tests

SimulateClickOn(controlSchemeToolbarMenu);

Check warning on line 254 in Assets/Tests/InputSystem.Editor/InputActionsEditorTests.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Assets/Tests/InputSystem.Editor/InputActionsEditorTests.cs#L254

Added line #L254 was not covered by tests

yield return WaitForSchedulerLoop();
yield return WaitForNotDirty();

Check warning on line 257 in Assets/Tests/InputSystem.Editor/InputActionsEditorTests.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Assets/Tests/InputSystem.Editor/InputActionsEditorTests.cs#L256-L257

Added lines #L256 - L257 were not covered by tests

yield return WaitForFocus(m_Window.rootVisualElement.Q("control-schemes-toolbar-menu"));
}

Check warning on line 260 in Assets/Tests/InputSystem.Editor/InputActionsEditorTests.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Assets/Tests/InputSystem.Editor/InputActionsEditorTests.cs#L259-L260

Added lines #L259 - L260 were not covered by tests
}
#endif
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ however, it has to be formatted properly to pass verification tests.
- Fixed the compilation warnings when used with Unity 6.4 (ISX-2349).
- Fixed an issue where `InputSystemUIInputModule.localMultiPlayerRoot` could not be set to `null` when using `MultiplayerEventSystem`. [ISXB-1610](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1610)
- Fixed an issue in `Keyboard` where the sub-script operator would return a `null` key control for the deprecated key `Key.IMESelected`. Now, an aliased `KeyControl`mapping to the IMESelected bit is returned for compability reasons. It is still strongly advised to not rely on this key since `IMESelected` bit isn't strictly a key and will be removed from the `Key` enumeration type in a future major revision. [ISXB-1541](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1541).
- Fixed an ArgumentOutOfRangeException that was thrown when pressing the undo shortcut while changing a control scheme name. [ISXB-1607](https://issuetracker.unity3d.com/issues/argumentoutofrangeexception-error-is-thrown-when-pressing-the-undo-shortcut-while-changing-the-control-scheme-name)
- Fixed an issue where the onAnyButtonPress callback would be triggered multiple times during unrelated events when a button is held down. See [ISXB-1005](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1005).
- Fixed InputControl picker not updating correctly when the Input Actions Window was dirty. [ISXB-1221](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1221)
- Fixed formatting issues on processor documentation page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,16 @@
{
return (in InputActionsEditorState state) =>
{
var controlSchemeSerializedProperty = state.selectedControlSchemeIndex == -1 ? null :
state.serializedObject
.FindProperty(nameof(InputActionAsset.m_ControlSchemes))
.GetArrayElementAtIndex(state.selectedControlSchemeIndex);
SerializedProperty controlSchemeSerializedProperty = null;
var serializedProperty = state.serializedObject

Check warning on line 149 in Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/ControlSchemeCommands.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/ControlSchemeCommands.cs#L148-L149

Added lines #L148 - L149 were not covered by tests
.FindProperty(nameof(InputActionAsset.m_ControlSchemes));

if (state.selectedControlSchemeIndex < serializedProperty.arraySize)
{
controlSchemeSerializedProperty = state.selectedControlSchemeIndex == -1 ? null :

Check warning on line 154 in Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/ControlSchemeCommands.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/ControlSchemeCommands.cs#L152-L154

Added lines #L152 - L154 were not covered by tests
serializedProperty
.GetArrayElementAtIndex(state.selectedControlSchemeIndex);
}

Check warning on line 157 in Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/ControlSchemeCommands.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/ControlSchemeCommands.cs#L157

Added line #L157 was not covered by tests

if (controlSchemeSerializedProperty == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ private void RemoveDeviceRequirement()
public override void RedrawUI(InputControlScheme viewState)
{
rootElement.Q<TextField>(kControlSchemeNameTextField).value = string.IsNullOrEmpty(m_NewName) ? viewState.name : m_NewName;

m_ListView.itemsSource?.Clear();
m_ListView.itemsSource = viewState.deviceRequirements.Count > 0 ?
viewState.deviceRequirements.Select(r => (r.controlPath, r.isOptional)).ToList() :
Expand All @@ -128,7 +127,7 @@ private void SaveAndClose()
CloseView();
}

private void Cancel()
internal void Cancel()
{
// Reload the selected ControlScheme values from the SerilaizedProperty and throw away any changes
Dispatch(ControlSchemeCommands.ResetSelectedControlScheme());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

private readonly Action m_SaveAction;

private ControlSchemesView m_ControlSchemesView;

public InputActionsEditorView(VisualElement root, StateContainer stateContainer, bool isProjectSettings,
Action saveAction)
: base(root, stateContainer)
Expand Down Expand Up @@ -104,6 +106,13 @@
});

s_OnPasteCutElements.Add(this);

Undo.undoRedoPerformed += CloseControlSchemeView;
}

private void CloseControlSchemeView()
{
m_ControlSchemesView?.Cancel();

Check warning on line 115 in Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/InputActionsEditorView.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/InputActionsEditorView.cs#L114-L115

Added lines #L114 - L115 were not covered by tests
}

private void OnReset()
Expand Down Expand Up @@ -156,9 +165,8 @@

if (viewState.controlSchemes.Any())
{
m_ControlSchemesToolbar.text = viewState.selectedControlSchemeIndex == -1
? "All Control Schemes"
: viewState.controlSchemes.ElementAt(viewState.selectedControlSchemeIndex).name;
var elementAtOrDefault = viewState.controlSchemes.ElementAtOrDefault(viewState.selectedControlSchemeIndex);
m_ControlSchemesToolbar.text = elementAtOrDefault == default ? "All Control Schemes" : elementAtOrDefault.name;

m_ControlSchemesToolbar.menu.AppendAction("All Control Schemes", _ => SelectControlScheme(-1),
viewState.selectedControlSchemeIndex == -1 ? DropdownMenuAction.Status.Checked : DropdownMenuAction.Status.Normal);
Expand Down Expand Up @@ -186,7 +194,7 @@
return;
}
m_DevicesToolbar.SetEnabled(true);
var currentControlScheme = viewState.controlSchemes.ElementAt(viewState.selectedControlSchemeIndex);
var currentControlScheme = viewState.controlSchemes.ElementAtOrDefault(viewState.selectedControlSchemeIndex);

Check warning on line 197 in Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/InputActionsEditorView.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/InputActionsEditorView.cs#L197

Added line #L197 was not covered by tests
if (viewState.selectedDeviceIndex == -1)
m_DevicesToolbar.text = "All Devices";

Expand Down Expand Up @@ -228,10 +236,13 @@

private void ShowControlSchemeEditor(VisualElement parent, bool updateExisting = false)
{
var controlSchemesView = CreateChildView(new ControlSchemesView(parent, stateContainer, updateExisting));
controlSchemesView.UpdateView(stateContainer.GetState());

controlSchemesView.OnClosing += _ => DestroyChildView(controlSchemesView);
m_ControlSchemesView = CreateChildView(new ControlSchemesView(parent, stateContainer, updateExisting));
m_ControlSchemesView.UpdateView(stateContainer.GetState());
m_ControlSchemesView.OnClosing += _ =>
{
DestroyChildView(m_ControlSchemesView);
m_ControlSchemesView = null;
};

Check warning on line 245 in Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/InputActionsEditorView.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/InputActionsEditorView.cs#L239-L245

Added lines #L239 - L245 were not covered by tests
}

private void SelectControlScheme(int controlSchemeIndex)
Expand All @@ -258,6 +269,7 @@
{
base.DestroyView();
s_OnPasteCutElements.Remove(this);
Undo.undoRedoPerformed -= CloseControlSchemeView;
}

public void OnPaste(InputActionsEditorState state)
Expand Down