Skip to content

Commit 8b42d5d

Browse files
committed
Updated for managed release
1 parent 6321d9f commit 8b42d5d

File tree

6 files changed

+32
-63
lines changed

6 files changed

+32
-63
lines changed

external/manifest.json

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
{
2-
"version": "1.0.0.2",
3-
"display_name": "SteamVR",
4-
"download_": "plugin_OpenVR.zip",
5-
"changelog": "Better path handling for SteamVR",
6-
"guid": "K2VRTEAM-AME2-APII-SNDP-SENDPTOPENVR"
7-
}
2+
"name": "SteamVR",
3+
"description": "Ame2 plugin for SteamVR, including support for OpenVR-compatible devices.",
4+
"guid": "K2VRTEAM-AME2-APII-SNDP-SENDPTOPENVR",
5+
"type": "service",
6+
"author": "K2VR Team",
7+
"artifacts": [
8+
{
9+
"version": "2.0.0.0",
10+
"contract": "2.0.0.0",
11+
"platform": "any",
12+
"name": "SteamVR",
13+
"download": "plugin_OpenVR.zip",
14+
"changelog": "Initial release of the OpenVR plugin."
15+
}
16+
]
17+
}

plugin_OpenVR/OpenVR.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace plugin_OpenVR;
2929
[ExportMetadata("Name", "SteamVR")]
3030
[ExportMetadata("Guid", "K2VRTEAM-AME2-APII-SNDP-SENDPTOPENVR")]
3131
[ExportMetadata("Publisher", "K2VR Team")]
32-
[ExportMetadata("Version", "1.0.0.2")]
32+
[ExportMetadata("Version", "2.0.0.0")]
3333
[ExportMetadata("Website", "https://github.com/KinectToVR/plugin_OpenVR")]
3434
[ExportMetadata("DependencyInstaller", typeof(DriverInstaller))]
3535
[ExportMetadata("CoreSetupData", typeof(SetupData))]

plugin_OpenVR/Utils/VRHelper.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,8 @@ public class VrHelper
1717
{
1818
private readonly IVrHelperPlatform _impl = s_staticImpl.Value;
1919

20-
private static readonly Lazy<IVrHelperPlatform> s_staticImpl = new(() =>
21-
{
22-
#if WINDOWS
23-
return new VrHelperWindows();
24-
#else
25-
return new VrHelperLinux();
26-
#endif
27-
});
20+
private static readonly Lazy<IVrHelperPlatform> s_staticImpl =
21+
new(() => OperatingSystem.IsWindows() ? new VrHelperWindows() : new VrHelperLinux());
2822

2923
public ((bool SteamExists, bool VrSettingsExist, bool CopiedDriverExists) Exists,
3024
(string SteamVrPath, string VrSettingsPath, string CopiedDriverPath) Path)

plugin_OpenVR/Utils/VRPaths.cs

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,12 @@ namespace plugin_OpenVR.Utils;
1010
[SuppressMessage("ReSharper", "CollectionNeverUpdated.Global")]
1111
internal class OpenVrPaths
1212
{
13-
#if WINDOWS
14-
public static readonly string Path =
13+
public static string Path => OperatingSystem.IsWindows() ?
1514
Environment.ExpandEnvironmentVariables(System.IO.Path.Combine(
16-
"%LocalAppData%", "openvr", "openvrpaths.vrpath"));
17-
#else
18-
public static readonly string Path =
15+
"%LocalAppData%", "openvr", "openvrpaths.vrpath")) :
1916
System.IO.Path.Combine(
2017
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
2118
".config", "openvr", "openvrpaths.vrpath");
22-
#endif
2319

2420
public static OpenVrPaths Read()
2521
{
@@ -60,11 +56,13 @@ public void Write()
6056
#pragma warning restore 0649
6157
}
6258

63-
#if WINDOWS
6459
public static class PathUtils
6560
{
66-
public static string GetShortName(string sLongFileName)
61+
private static string GetShortName(string sLongFileName)
6762
{
63+
if (!OperatingSystem.IsWindows())
64+
return sLongFileName;
65+
6866
var buffer = new StringBuilder(259);
6967
if (GetShortPathName(sLongFileName, buffer, buffer.Capacity) == 0)
7068
throw new System.ComponentModel.Win32Exception();
@@ -79,6 +77,9 @@ public static string ShortPath(this string path)
7977
{
8078
try
8179
{
80+
if (!OperatingSystem.IsWindows())
81+
return path;
82+
8283
var result = GetShortName(path);
8384
return string.IsNullOrEmpty(result) ? path : result;
8485
}
@@ -88,17 +89,3 @@ public static string ShortPath(this string path)
8889
}
8990
}
9091
}
91-
#else
92-
public static class PathUtils
93-
{
94-
public static string GetShortName(string sLongFileName)
95-
{
96-
return sLongFileName;
97-
}
98-
99-
public static string ShortPath(this string path)
100-
{
101-
return path;
102-
}
103-
}
104-
#endif

plugin_OpenVR/Utils/VrHelper.Windows.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
using System.IO;
44
using System.Linq;
55
using System.Runtime.InteropServices;
6+
using System.Runtime.Versioning;
67
using System.Security.Principal;
78
using System.Threading;
89
using Microsoft.Win32;
910

1011
namespace plugin_OpenVR.Utils;
1112

12-
#if WINDOWS
13+
[SupportedOSPlatform("windows")]
1314
internal class VrHelperWindows : IVrHelperPlatform
1415
{
1516
public ((bool SteamExists, bool VrSettingsExist, bool CopiedDriverExists) Exists,
@@ -175,4 +176,3 @@ private enum ProcessAccessFlags : uint
175176
QueryLimitedInformation = 0x00001000
176177
}
177178
}
178-
#endif

plugin_OpenVR/plugin_OpenVR.csproj

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<PropertyGroup>
33
<TargetFrameworks>net8.0</TargetFrameworks>
44
<RootNamespace>plugin_OpenVR</RootNamespace>
5-
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
65
<PublishTrimmed>false</PublishTrimmed>
76
<Platforms>x64</Platforms>
87
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
@@ -12,13 +11,6 @@
1211
<WarningsAsErrors>CA1416</WarningsAsErrors>
1312
</PropertyGroup>
1413

15-
<PropertyGroup Condition="'$(RuntimeIdentifier)'=='win-x64' or '$(RuntimeIdentifier)'=='win-x86'">
16-
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
17-
<TargetPlatformVersion>10.0.22621.0</TargetPlatformVersion>
18-
<TargetPlatformIdentifier>Windows</TargetPlatformIdentifier>
19-
<DefineConstants>$(DefineConstants);WINDOWS</DefineConstants>
20-
</PropertyGroup>
21-
2214
<ItemGroup>
2315
<TrimmerRootAssembly Include="MessagePack"/>
2416
<TrimmerRootAssembly Include="Microsoft.VisualStudio.Threading"/>
@@ -86,26 +78,12 @@
8678

8779
<ItemGroup>
8880
<!-- Windows x64 -->
89-
<Content Include="..\vendor\openvr\bin\win64\openvr_api.dll" Link="openvr_api.dll"
90-
Condition="'$(RuntimeIdentifier)'=='win-x64'">
91-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
92-
</Content>
93-
94-
<!-- Windows x86 -->
95-
<Content Include="..\vendor\openvr\bin\win32\openvr_api.dll" Link="openvr_api.dll"
96-
Condition="'$(RuntimeIdentifier)'=='win-x86'">
81+
<Content Include="..\vendor\openvr\bin\win64\openvr_api.dll" Link="openvr_api.dll" Visible="False">
9782
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
9883
</Content>
9984

10085
<!-- Linux x64 -->
101-
<Content Include="..\vendor\openvr\bin\linux64\libopenvr_api.so" Link="libopenvr_api.so"
102-
Condition="'$(RuntimeIdentifier)'=='linux-x64'">
103-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
104-
</Content>
105-
106-
<!-- Linux x86 -->
107-
<Content Include="..\vendor\openvr\bin\linux32\libopenvr_api.so" Link="libopenvr_api.so"
108-
Condition="'$(RuntimeIdentifier)'=='linux-x86'">
86+
<Content Include="..\vendor\openvr\bin\linux64\libopenvr_api.so" Link="libopenvr_api.so" Visible="False">
10987
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
11088
</Content>
11189
</ItemGroup>

0 commit comments

Comments
 (0)