Skip to content

Commit

Permalink
Merge pull request #50 from eviltwo/1.0.2-dev
Browse files Browse the repository at this point in the history
1.0.2
  • Loading branch information
eviltwo committed Jul 16, 2024
2 parents c0cff76 + 22fafaf commit f8e037d
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 30 deletions.
7 changes: 7 additions & 0 deletions InputGlyphs/Assets/InputGlyphs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [1.0.2] - 2024-07-16
### Updated
- Updated SteamInputAdapter package version to 1.0.1
- Supported control components. Example: "XInputController/{Submit}"
### Changed
- Renamed `GetLocalPath()` to `RemoveRoot()`. Internal processing was also changed.

## [1.0.1] - 2024-07-13
### Updated
- Updated SteamInputAdapter package version to 1.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private class RequiredPackageInfo
name = "com.eviltwo.unity-steam-input-adapter",
pageUrl = "https://github.com/eviltwo/UnitySteamInputAdapter",
packageUrl = "https://github.com/eviltwo/UnitySteamInputAdapter.git?path=UnitySteamInputAdapter/Assets/UnitySteamInputAdapter",
requiredVersion = "1.0.0",
requiredVersion = "1.0.1",
#if SUPPORT_ADAPTER
isInstalled = true,
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public bool LoadGlyph(Texture2D texture, IReadOnlyList<InputDevice> activeDevice
return false;
}

var localPath = InputLayoutPathUtility.GetLocalPath(inputLayoutPath);
var localPath = InputLayoutPathUtility.RemoveRoot(inputLayoutPath);
if (activeTextureMap.TryGetTexture(localPath, out var result))
{
texture.Reinitialize(result.width, result.height, TextureFormat.ARGB32, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public bool LoadGlyph(Texture2D texture, IReadOnlyList<InputDevice> activeDevice
return false;
}

var localPath = InputLayoutPathUtility.GetLocalPath(inputLayoutPath);
var localPath = InputLayoutPathUtility.RemoveRoot(inputLayoutPath);
for (var i = 0; i < TextureMaps.Count; i++)
{
if (TextureMaps[i].TryGetTexture(localPath, out var result))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,30 @@ public static class InputLayoutPathUtility
private static List<int> _bindingIndexBuffer = new List<int>();

/// <summary>
/// Returns a local path for the given input layout path.
/// Remove the root (probably the device name) from the path.
/// </summary>
/// <remarks>
/// &lt;gamepad&gt;/dpad/left -> dpad/left
/// Example: &lt;gamepad&gt;/dpad/left -> dpad/left
/// </remarks>
public static string GetLocalPath(string inputLayoutPath)
public static string RemoveRoot(string inputControlPath)
{
if (string.IsNullOrEmpty(inputLayoutPath))
if (string.IsNullOrEmpty(inputControlPath))
{
return null;
return string.Empty;
}
var pathComponents = InputControlPath.Parse(inputLayoutPath);
var enumerator = pathComponents.GetEnumerator();
if (!enumerator.MoveNext())
var startIndex = inputControlPath[0] == InputControlPath.Separator ? 1 : 0;
var separationIndex = inputControlPath.IndexOf(InputControlPath.Separator, startIndex);
if (separationIndex == -1)
{
return null;
return inputControlPath;
}

_stringBuilder.Clear();
while (enumerator.MoveNext())
if (separationIndex == inputControlPath.Length)
{
if (_stringBuilder.Length > 0)
{
_stringBuilder.Append(InputControlPath.Separator);
}
_stringBuilder.Append(enumerator.Current.name);
return string.Empty;
}
return _stringBuilder.ToString();

return inputControlPath.Substring(separationIndex + 1);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion InputGlyphs/Assets/InputGlyphs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.eviltwo.input-glyphs",
"displayName": "Input Glyphs",
"version": "1.0.1",
"version": "1.0.2",
"unity": "2022.3",
"description": "Displays glyphs (icons) of keyboard & mouse or controller buttons recognized by Unity's InputSystem.",
"author": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ namespace InputGlyphs.Tests
{
public class InputLayoutPathUtilityTest
{
[TestCase("/XInputController/buttonSouth", "buttonSouth")]
[TestCase("/XInputController/dpad/right", "dpad/right")]
[TestCase("/XInputController/<Button>", "<Button>")]
[TestCase("/XInputController/{Submit}", "{Submit}")]
[TestCase("/XInputController/#(a)", "#(a)")]
[TestCase("/<Gamepad>/buttonSouth", "buttonSouth")]
[TestCase("/<Gamepad>/buttonSouth", "buttonSouth")]
[TestCase("XInputController/buttonSouth", "buttonSouth")]
[TestCase("XInputController/dpad/left", "dpad/left")]
[TestCase("<gamepad>/dpad/up", "dpad/up")]
[TestCase("<gamepad>", "")]
[TestCase("<gamepad>/", "")]
public void GetLocalPath(string input, string expected)
[TestCase("*/buttonSouth", "buttonSouth")]
public void RemoveRoot(string input, string expected)
{
var result = InputLayoutPathUtility.GetLocalPath(input);
var result = InputLayoutPathUtility.RemoveRoot(input);
Assert.AreEqual(expected, result);
}
}
Expand Down
2 changes: 1 addition & 1 deletion InputGlyphs/Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"com.eviltwo.unity-steam-input-adapter": "https://github.com/eviltwo/UnitySteamInputAdapter.git?path=UnitySteamInputAdapter/Assets/UnitySteamInputAdapter#1.0.0",
"com.eviltwo.unity-steam-input-adapter": "https://github.com/eviltwo/UnitySteamInputAdapter.git?path=UnitySteamInputAdapter/Assets/UnitySteamInputAdapter#1.0.1",
"com.eviltwo.unity-steam-input-glyph-loader": "https://github.com/eviltwo/UnitySteamInputGlyphLoader.git?path=UnitySteamInputGlyphLoader/Assets/UnitySteamInputGlyphLoader#0.10.0",
"com.rlabrecque.steamworks.net": "https://github.com/rlabrecque/Steamworks.NET.git?path=/com.rlabrecque.steamworks.net#20.2.0",
"com.unity.collab-proxy": "2.4.3",
Expand Down
4 changes: 2 additions & 2 deletions InputGlyphs/Packages/packages-lock.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"dependencies": {
"com.eviltwo.unity-steam-input-adapter": {
"version": "https://github.com/eviltwo/UnitySteamInputAdapter.git?path=UnitySteamInputAdapter/Assets/UnitySteamInputAdapter#1.0.0",
"version": "https://github.com/eviltwo/UnitySteamInputAdapter.git?path=UnitySteamInputAdapter/Assets/UnitySteamInputAdapter#1.0.1",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "8856d218033123a932a4c23ed0e6e527f5320933"
"hash": "9d9b8060e51ed78042fc681b22ed35039a54c332"
},
"com.eviltwo.unity-steam-input-glyph-loader": {
"version": "https://github.com/eviltwo/UnitySteamInputGlyphLoader.git?path=UnitySteamInputGlyphLoader/Assets/UnitySteamInputGlyphLoader#0.10.0",
Expand Down

0 comments on commit f8e037d

Please sign in to comment.