Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Input State Window is now force-closed when the device it is inspecting is disconnected #2093

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
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
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ however, it has to be formatted properly to pass verification tests.
- Fixed an issue with default device selection when adding new Control Scheme.
- Fixed an issue where action map delegates were not updated when the asset already assigned to the PlayerInput component were changed [ISXB-711](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-711).
- Fixed Action properties edition in the UI Toolkit version of the Input Actions Asset editor. [ISXB-1277](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1277)
- Fixed an editor crash caused by input debugger device state window reusing cached state when reconnecting Stadia controller. [ISXB-658](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-658)

### Changed
- Added back the InputManager to InputSystem project-wide asset migration code with performance improvement (ISX-2086).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,26 @@ public unsafe void InitializeWithControl(InputControl control)
PollBuffersFromControl(control, selectBuffer: true);

titleContent = new GUIContent(control.displayName);

InputSystem.onDeviceChange += OnDeviceChange;
}

private void OnDeviceChange(InputDevice device, InputDeviceChange change)
{
if (m_Control is null)
return;

if (device.deviceId != m_Control.device.deviceId)
return;

if (change == InputDeviceChange.Removed)
Close();
}

internal void OnDestroy()
{
if (m_Control != null)
InputSystem.onDeviceChange -= OnDeviceChange;
}

private unsafe void PollBuffersFromControl(InputControl control, bool selectBuffer = false)
Expand Down Expand Up @@ -286,6 +306,12 @@ private string FormatByte(byte value)
////TODO: support dumping multiple state side-by-side when comparing
private void DrawHexDump()
{
if (m_StateBuffers is null)
return;

if (m_StateBuffers[m_SelectedStateBuffer] is null)
return;

m_HexDumpScrollPosition = EditorGUILayout.BeginScrollView(m_HexDumpScrollPosition);

var stateBuffer = m_StateBuffers[m_SelectedStateBuffer];
Expand Down
Loading