Skip to content

Commit 4f50494

Browse files
author
Rene Damm
authored
NEW: Add 'Copy Device Description' to context menu in debugger (#797).
1 parent 9150693 commit 4f50494

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

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

3131
### Added
3232

33+
- Can right-click devices in Input Debugger (also those under "Unsupported") and select "Copy Device Description" to copy the internal `InputDeviceDescription` of the device in JSON format to the system clipboard.
34+
* This information is helpful for us to debug problems related to specific devices.
35+
3336
## [0.9.3-preview] - 2019-8-15
3437

3538
### Fixed

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

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ private static class Contents
330330
public static GUIContent addDevicesNotSupportedByProjectContent = new GUIContent("Add Devices Not Listed in 'Supported Devices'");
331331
public static GUIContent diagnosticsModeContent = new GUIContent("Enable Event Diagnostics");
332332
public static GUIContent openDebugView = new GUIContent("Open Device Debug View");
333+
public static GUIContent copyDeviceDescription = new GUIContent("Copy Device Description");
333334
public static GUIContent removeDevice = new GUIContent("Remove Device");
334335
public static GUIContent enableDevice = new GUIContent("Enable Device");
335336
public static GUIContent disableDevice = new GUIContent("Disable Device");
@@ -369,13 +370,23 @@ protected override void ContextClickedItem(int id)
369370
{
370371
var menu = new GenericMenu();
371372
menu.AddItem(Contents.openDebugView, false, () => InputDeviceDebuggerWindow.CreateOrShowExisting(deviceItem.device));
373+
menu.AddItem(Contents.copyDeviceDescription, false,
374+
() => EditorGUIUtility.systemCopyBuffer = deviceItem.device.description.ToJson());
372375
menu.AddItem(Contents.removeDevice, false, () => InputSystem.RemoveDevice(deviceItem.device));
373376
if (deviceItem.device.enabled)
374377
menu.AddItem(Contents.disableDevice, false, () => InputSystem.DisableDevice(deviceItem.device));
375378
else
376379
menu.AddItem(Contents.enableDevice, false, () => InputSystem.EnableDevice(deviceItem.device));
377380
menu.ShowAsContext();
378381
}
382+
383+
if (item is UnsupportedDeviceItem unsupportedDeviceItem)
384+
{
385+
var menu = new GenericMenu();
386+
menu.AddItem(Contents.copyDeviceDescription, false,
387+
() => EditorGUIUtility.systemCopyBuffer = unsupportedDeviceItem.description.ToJson());
388+
menu.ShowAsContext();
389+
}
379390
}
380391

381392
protected override void DoubleClickedItem(int id)
@@ -464,8 +475,18 @@ protected override TreeViewItem BuildRoot()
464475
var parent = haveRemotes ? localDevicesNode : devicesItem;
465476
var unsupportedDevicesNode = AddChild(parent, $"Unsupported ({m_UnsupportedDevices.Count})", ref id);
466477
foreach (var device in m_UnsupportedDevices)
467-
AddChild(unsupportedDevicesNode, device.ToString(), ref id);
468-
unsupportedDevicesNode.children.Sort((a, b) => string.Compare(a.displayName, b.displayName));
478+
{
479+
var item = new UnsupportedDeviceItem
480+
{
481+
id = id++,
482+
depth = unsupportedDevicesNode.depth + 1,
483+
displayName = device.ToString(),
484+
description = device
485+
};
486+
unsupportedDevicesNode.AddChild(item);
487+
}
488+
unsupportedDevicesNode.children.Sort((a, b) =>
489+
string.Compare(a.displayName, b.displayName, StringComparison.InvariantCulture));
469490
}
470491

471492
var disconnectedDevices = InputSystem.disconnectedDevices;
@@ -475,7 +496,8 @@ protected override TreeViewItem BuildRoot()
475496
var disconnectedDevicesNode = AddChild(parent, $"Disconnected ({disconnectedDevices.Count})", ref id);
476497
foreach (var device in disconnectedDevices)
477498
AddChild(disconnectedDevicesNode, device.ToString(), ref id);
478-
disconnectedDevicesNode.children.Sort((a, b) => string.Compare(a.displayName, b.displayName));
499+
disconnectedDevicesNode.children.Sort((a, b) =>
500+
string.Compare(a.displayName, b.displayName, StringComparison.InvariantCulture));
479501
}
480502

481503
// Layouts.
@@ -853,6 +875,11 @@ private class DeviceItem : TreeViewItem
853875
public InputDevice device;
854876
}
855877

878+
private class UnsupportedDeviceItem : TreeViewItem
879+
{
880+
public InputDeviceDescription description;
881+
}
882+
856883
private class ConfigurationItem : TreeViewItem
857884
{
858885
public string name;

0 commit comments

Comments
 (0)