Skip to content

Commit 7362867

Browse files
author
Rene Damm
authored
FIX: Wrong display names for devices in control schemes (#1028).
1 parent 828102b commit 7362867

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
Due to package verification, the latest version below is the unpublished version and the date is meaningless.
88
however, it has to be formatted properly to pass verification tests.
99

10+
## [1.0.0-preview.5] - 2020-12-12
11+
12+
### Fixed
13+
14+
- The list of device requirements for a control scheme in the action editor no longer displays devices with their internal layout name rather than their external display name.
15+
1016
## [1.0.0-preview.4] - 2020-01-24
1117

1218
This release includes a number of Quality-of-Life improvements for a range of common problems that users have reported.

Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionEditorToolbar.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,15 @@ private static string DeviceRequirementToDisplayString(InputControlScheme.Device
326326
{
327327
////TODO: need something more flexible to produce correct results for more than the simple string we produce here
328328
var deviceLayout = InputControlPath.TryGetDeviceLayout(requirement.controlPath);
329+
var deviceLayoutText = !string.IsNullOrEmpty(deviceLayout)
330+
? EditorInputControlLayoutCache.GetDisplayName(deviceLayout)
331+
: string.Empty;
329332
var usages = InputControlPath.TryGetDeviceUsages(requirement.controlPath);
330333

331334
if (usages != null && usages.Length > 0)
332-
return $"{deviceLayout} {string.Join("}{", usages)}";
335+
return $"{deviceLayoutText} {string.Join("}{", usages)}";
333336

334-
return deviceLayout;
337+
return deviceLayoutText;
335338
}
336339

337340
// Notifications.

Packages/com.unity.inputsystem/InputSystem/Editor/EditorInputControlLayoutCache.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,20 @@ public static IEnumerable<InputDeviceMatcher> GetDeviceMatchers(string layoutNam
112112
return matchers;
113113
}
114114

115+
public static string GetDisplayName(string layoutName)
116+
{
117+
if (string.IsNullOrEmpty(layoutName))
118+
throw new ArgumentException("Layout name cannot be null or empty", nameof(layoutName));
119+
120+
var layout = TryGetLayout(layoutName);
121+
if (layout == null)
122+
return layoutName;
123+
124+
if (!string.IsNullOrEmpty(layout.displayName))
125+
return layout.displayName;
126+
return layout.name;
127+
}
128+
115129
/// <summary>
116130
/// List the controls that may be present on controls or devices of the given layout by virtue
117131
/// of being defined in other layouts based on it.

Packages/com.unity.inputsystem/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.unity.inputsystem",
33
"displayName": "Input System",
4-
"version": "1.0.0-preview.4",
4+
"version": "1.0.0-preview.5",
55
"unity": "2019.1",
66
"repository": {
77
"type": "git",

0 commit comments

Comments
 (0)