Skip to content

Commit ef8c111

Browse files
committed
Updated contract
1 parent 3dcf914 commit ef8c111

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

plugin_OpenVR/OpenVR.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public string TrackingSystemName
397397
}
398398
}
399399

400-
public void OnLoad()
400+
public Task OnLoad()
401401
{
402402
VrInput ??= new SteamEvrInput(Host, this);
403403
VrInputStatic = VrInput;
@@ -411,21 +411,23 @@ public void OnLoad()
411411

412412
IsStandableSupportEnabled = Host?.PluginSettings
413413
.GetSetting("StandableSupport", false) ?? false;
414+
415+
return Task.CompletedTask;
414416
}
415417

416-
public int Initialize()
418+
public async Task Initialize()
417419
{
418420
// Reset the status
419421
ServiceStatus = 0;
420422

421423
// Check if Amethyst is running as admin
422424
// Check if OpenVR is running as admin
423425
// Initialize OpenVR if we're ready to go
424-
if (VrHelper.IsCurrentProcessElevated() !=
425-
VrHelper.IsOpenVrElevated() || !OpenVrStartup())
426+
if (VrHelper.IsCurrentProcessElevated() != VrHelper.IsOpenVrElevated() ||
427+
!await Task.Run(OpenVrStartup)) // Wait for the system to initialize
426428
{
427429
ServiceStatus = 1;
428-
return 1;
430+
return;
429431
}
430432

431433
// Install the manifest
@@ -435,14 +437,10 @@ public int Initialize()
435437
UpdateBindingTexts();
436438

437439
// Startup input actions
438-
var serviceStatus = 0;
439-
if (!EvrActionsStartup()) serviceStatus = 2;
440+
EvrActionsStartup();
440441

441442
// Connect to the server driver
442-
K2ServerDriverRefresh();
443-
444-
// Return the binding error if the driver is fine
445-
return ServiceStatus == 0 ? serviceStatus : ServiceStatus;
443+
await K2ServerDriverRefresh();
446444
}
447445

448446
public void Heartbeat()
@@ -487,7 +485,7 @@ public void Heartbeat()
487485
}
488486
}
489487

490-
public void Shutdown()
488+
public Task Shutdown()
491489
{
492490
lock (InitLock)
493491
lock (Host.UpdateThreadLock)
@@ -500,6 +498,8 @@ public void Shutdown()
500498
// K2ServerDriverRefresh(); // TODO
501499
Host?.RefreshStatusInterface();
502500
}
501+
502+
return Task.CompletedTask;
503503
}
504504

505505
public void DisplayToast((string Title, string Text) message)
@@ -764,7 +764,7 @@ public Task ProcessKeyInput(IKeyInputAction action, object data, TrackerType? re
764764
UpdateBindingTexts();
765765

766766
// Refresh the driver, just in case
767-
K2ServerDriverRefresh();
767+
await K2ServerDriverRefresh();
768768

769769
// Driver client sanity check: return empty or null if not valid
770770
if (!Initialized || OpenVR.System is null || DriverService is null ||
@@ -936,9 +936,9 @@ private async Task<int> CheckK2ServerStatusAsync()
936936
*/
937937
}
938938

939-
private void K2ServerDriverRefresh()
939+
private async Task K2ServerDriverRefresh()
940940
{
941-
ServiceStatus = CheckK2ServerStatusAsync().Result;
941+
ServiceStatus = await CheckK2ServerStatusAsync();
942942

943943
// Request a quick status refresh
944944
Host?.RefreshStatusInterface();

plugin_OpenVR/plugin_OpenVR.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.3.0"/>
2424
<PackageReference Include="Capnp.Net.Runtime" Version="1.3.118"/>
2525
<!-- <PackageReference Include="CapnpC.CSharp.MsBuild.Generation" Version="1.3.118" />-->
26-
<PackageReference Include="Amethyst.Contract" Version="2.0.0"/>
26+
<PackageReference Include="Amethyst.Contract" Version="2.2.0" />
2727
<PackageReference Include="FluentAvaloniaUI" Version="2.4.0"/>
2828
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.14.0"/>
2929
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>

0 commit comments

Comments
 (0)