Skip to content

Commit 1733a1a

Browse files
committed
Updated contract
1 parent 09c599e commit 1733a1a

File tree

17 files changed

+349
-219
lines changed

17 files changed

+349
-219
lines changed

Amethyst.Contract/Amethyst.Contract.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Nullable>enable</Nullable>
66
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
77
<Title>Amethyst Plugin API Contract</Title>
8-
<Version>2.0.0</Version>
8+
<Version>2.2.0</Version>
99
<Platforms>x64</Platforms>
1010
</PropertyGroup>
1111

Amethyst.Contract/Contract.cs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,22 @@ public interface ITrackingDevice
129129
/// "https://contoso.com/"
130130
/// </example>
131131
[DefaultValue(null)]
132-
public Uri ErrorDocsUri { get; }
132+
Uri ErrorDocsUri { get; }
133133

134134
/// <summary>
135135
/// This is called after the app loads the plugin
136136
/// </summary>
137-
void OnLoad();
137+
Task OnLoad();
138138

139139
/// <summary>
140140
/// This initializes/connects the device
141141
/// </summary>
142-
void Initialize();
142+
Task Initialize();
143143

144144
/// <summary>
145145
/// This is called when the device is closed
146146
/// </summary>
147-
void Shutdown();
147+
Task Shutdown();
148148

149149
/// <summary>
150150
/// This is called to update the device (each loop)
@@ -186,52 +186,52 @@ public interface IServiceEndpoint
186186
/// Additional supported tracker types set
187187
/// The mandatory ones are: waist, left foot, and right foot
188188
/// </summary>
189-
public SortedSet<TrackerType> AdditionalSupportedTrackerTypes { get; }
189+
SortedSet<TrackerType> AdditionalSupportedTrackerTypes { get; }
190190

191191
/// <summary>
192192
/// Mark as true to tell the user that they need to restart/
193193
/// /in case they want to add more trackers after spawning
194194
/// This is the case with OpenVR, where settings need to be reloaded
195195
/// </summary>
196196
[DefaultValue(false)]
197-
public bool IsRestartOnChangesNeeded { get; }
197+
bool IsRestartOnChangesNeeded { get; }
198198

199199
/// <summary>
200200
/// Controller input actions, for calibration and others
201201
/// Also provides support for flip/freeze quick toggling
202202
/// Leaving this null will result in marking the
203203
/// manual calibration and input actions support as [false]
204204
/// </summary>
205-
public InputActions ControllerInputActions { get; set; }
205+
InputActions ControllerInputActions { get; set; }
206206

207207
/// <summary>
208208
/// For AutoStartAmethyst: check if it's even possible
209209
/// Mark as true to state that starting your app/service
210210
/// / can automatically start Amethyst at the same time
211211
/// </summary>
212212
[DefaultValue(false)]
213-
public bool CanAutoStartAmethyst { get; }
213+
bool CanAutoStartAmethyst { get; }
214214

215215
/// <summary>
216216
/// Check or set if starting the service should auto-start Amethyst
217217
/// This is only available for a few actual cases, like OpenVR
218218
/// </summary>
219219
[DefaultValue(false)]
220-
public bool AutoStartAmethyst { get; set; }
220+
bool AutoStartAmethyst { get; set; }
221221

222222
/// <summary>
223223
/// Check or set if closing the service should auto-close Amethyst
224224
/// This is only available for a few actual cases, like OpenVR
225225
/// </summary>
226226
[DefaultValue(true)]
227-
public bool AutoCloseAmethyst { get; set; }
227+
bool AutoCloseAmethyst { get; set; }
228228

229229
/// <summary>
230230
/// Check if Amethyst is shown in the service dashboard or similar
231231
/// This is only available for a few actual cases, like OpenVR
232232
/// </summary>
233233
[DefaultValue(true)]
234-
public bool IsAmethystVisible { get; }
234+
bool IsAmethystVisible { get; }
235235

236236
/// <summary>
237237
/// Check running system name, this is important for input
@@ -240,7 +240,7 @@ public interface IServiceEndpoint
240240
/// "Oculus" | "VIVE" | "Index" | "WMR" | ...
241241
/// </example>
242242
[DefaultValue("Oculus")]
243-
public string TrackingSystemName { get; }
243+
string TrackingSystemName { get; }
244244

245245
/// <summary>
246246
/// The link to launch when 'View Docs' is clicked while
@@ -252,26 +252,26 @@ public interface IServiceEndpoint
252252
/// "https://contoso.com/"
253253
/// </example>
254254
[DefaultValue(null)]
255-
public Uri ErrorDocsUri { get; }
255+
Uri ErrorDocsUri { get; }
256256

257257
/// <summary>
258258
/// Keeps all supported input actions that may be received from ProcessKeyInput
259259
/// You will not be able to receive actions from unsupported TrackerType either
260260
/// </summary>
261261
[DefaultValue(null)]
262-
public Dictionary<TrackerType, SortedSet<IKeyInputAction>> SupportedInputActions { get; }
262+
Dictionary<TrackerType, SortedSet<IKeyInputAction>> SupportedInputActions { get; }
263263

264264
/// <summary>
265265
/// Get the absolute pose of the HMD, calibrated against the play space
266266
/// Return null if unknown to the service or unavailable
267267
/// You'll need to provide this to support automatic calibration
268268
/// </summary>
269-
public (Vector3 Position, Quaternion Orientation)? HeadsetPose { get; }
269+
(Vector3 Position, Quaternion Orientation)? HeadsetPose { get; }
270270

271271
/// <summary>
272272
/// This is called after the app loads the plugin
273273
/// </summary>
274-
void OnLoad();
274+
Task OnLoad();
275275

276276
/// <summary>
277277
/// This is called right before the pose compose
@@ -281,12 +281,12 @@ public interface IServiceEndpoint
281281
/// <summary>
282282
/// This initializes/connects to the service
283283
/// </summary>
284-
int Initialize();
284+
Task Initialize();
285285

286286
/// <summary>
287287
/// This is called when the service is closed
288288
/// </summary>
289-
void Shutdown();
289+
Task Shutdown();
290290

291291
/// <summary>
292292
/// Implement if your service supports custom toasts
@@ -297,39 +297,39 @@ public interface IServiceEndpoint
297297
/// <summary>
298298
/// Request a restart of the tracking endpoint service
299299
/// </summary>
300-
public bool? RequestServiceRestart(string reason, bool wantReply = false);
300+
bool? RequestServiceRestart(string reason, bool wantReply = false);
301301

302302
/// <summary>
303303
/// Find an already-existing tracker and get its pose
304304
/// For no results found return null, also check if it's from amethyst
305305
/// </summary>
306-
public TrackerBase GetTrackerPose(string contains, bool canBeFromAmethyst = true);
306+
TrackerBase GetTrackerPose(string contains, bool canBeFromAmethyst = true);
307307

308308
/// <summary>
309309
/// Set tracker states, add/spawn if not present yet
310310
/// Default to the serial, update the role if needed
311311
/// Returns the same vector with paired success property (or null)
312312
/// </summary>
313-
public Task<IEnumerable<(TrackerBase Tracker, bool Success)>> SetTrackerStates(
313+
Task<IEnumerable<(TrackerBase Tracker, bool Success)>> SetTrackerStates(
314314
IEnumerable<TrackerBase> trackerBases, bool wantReply = true);
315315

316316
/// <summary>
317317
/// Update tracker positions and physics components
318318
/// Check physics against null, they're passed as optional
319319
/// Returns the same vector with paired success property (or null)
320320
/// </summary>
321-
public Task<IEnumerable<(TrackerBase Tracker, bool Success)>> UpdateTrackerPoses(
321+
Task<IEnumerable<(TrackerBase Tracker, bool Success)>> UpdateTrackerPoses(
322322
IEnumerable<TrackerBase> trackerBases, bool wantReply = true, CancellationToken? token = null);
323323

324324
/// <summary>
325325
/// Check connection: status, serialized status, combined ping time
326326
/// </summary>
327-
public Task<(int Status, string StatusMessage, long PingTime)> TestConnection();
327+
Task<(int Status, string StatusMessage, long PingTime)> TestConnection();
328328

329329
/// <summary>
330330
/// Process a key input event sent by a device, that was assigned and found
331331
/// </summary>
332-
public Task ProcessKeyInput(IKeyInputAction action, object? data,
332+
Task ProcessKeyInput(IKeyInputAction action, object? data,
333333
TrackerType? receiver, CancellationToken? token = null);
334334
}
335335

@@ -380,7 +380,7 @@ public interface IAmethystHost
380380
/// Types you save must either be serializable by ToString()
381381
/// or the Newtonsoft.Json (JSON.NET) serialization library
382382
/// </summary>
383-
public IPluginSettings PluginSettings { get; }
383+
IPluginSettings PluginSettings { get; }
384384

385385
/// <summary>
386386
/// Helper class that provides path-related methods,
@@ -390,7 +390,7 @@ public interface IAmethystHost
390390
/// and in unpackaged mode, AppData will be created near main exe.
391391
/// This is to ensure portability and prevent the need for cleanup
392392
/// </summary>
393-
public IPathHelper PathHelper { get; }
393+
IPathHelper PathHelper { get; }
394394

395395
/// <summary>
396396
/// Get the hook joint pose (typically Head, fallback to .First())
@@ -512,21 +512,21 @@ public interface IDependencyInstaller
512512
/// The list of dependencies that will need to be installed,
513513
/// or tools that can be optionally included, see IDependency
514514
/// </summary>
515-
public List<IDependency> Dependencies { get; }
515+
List<IDependency> Dependencies { get; }
516516

517517
/// <summary>
518518
/// The list of fixes that may need to be applied,
519519
/// or tools that can be included, see the IFix class
520520
/// </summary>
521-
public List<IFix> Fixes { get; }
521+
List<IFix> Fixes { get; }
522522

523523
/// <summary>
524524
/// The localization host, use it to request your strings
525525
/// Note: this property will be overwritten by Amethyst
526526
/// upon the initialization of your implemented class!
527527
/// You may use it ONLY after it's done constructing
528528
/// </summary>
529-
public ILocalizationHost? Host { get; set; }
529+
ILocalizationHost? Host { get; set; }
530530

531531
/// <summary>
532532
/// Use this interface to invoke AME localization methods
@@ -592,15 +592,15 @@ public interface ICoreSetupData
592592
/// Note: MUST BE OF Microsoft.UI.Xaml.Controls.IconElement
593593
/// Note: This icon will be auto-scaled, keep it high-res
594594
/// </summary>
595-
public object PluginIcon { get; }
595+
object PluginIcon { get; }
596596

597597
/// <summary>
598598
/// The name of the group the plugin (device/service)
599599
/// will be put into during the setup. Think of it as
600600
/// about the RadioButton group that links them together
601601
/// Note: case-sensitive, treated the same as serials
602602
/// </summary>
603-
public string GroupName { get; }
603+
string GroupName { get; }
604604

605605
/// <summary>
606606
/// States whether the plugin is an ITrackingDevice or
@@ -609,5 +609,5 @@ public interface ICoreSetupData
609609
/// and is here because MEF will be unavailable at the
610610
/// point of scanning the core setup data from plugins
611611
/// </summary>
612-
public Type PluginType { get; }
612+
Type PluginType { get; }
613613
}

Amethyst/Amethyst.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
</ItemGroup>
3232

3333
<ItemGroup>
34+
<PackageReference Include="AsyncImageLoader.Avalonia" Version="3.4.3" />
3435
<PackageReference Include="Avalonia" Version="11.3.2"/>
3536
<PackageReference Include="Avalonia.Labs.Controls" Version="11.3.1" />
3637
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0"/>

Amethyst/App.axaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ await File.ReadAllTextAsync((await folder.GetFileAsync("en.json"))!.Path.Absolut
11571157
// Send a non-dismissible tip about reloading the app
11581158
private static void OnWatcherOnChanged(object o, FileSystemEventArgs fileSystemEventArgs)
11591159
{
1160-
Dispatcher.UIThread.Post(() =>
1160+
Dispatcher.UIThread.Post(async void () =>
11611161
{
11621162
Logger.Info("String resource files have changed, reloading!");
11631163
Logger.Info($"What happened: {fileSystemEventArgs.ChangeType}");
@@ -1183,8 +1183,8 @@ private static void OnWatcherOnChanged(object o, FileSystemEventArgs fileSystemE
11831183
Shared.Devices.DevicesJointsValid = false;
11841184

11851185
// Reload plugins' interfaces
1186-
AppPlugins.TrackingDevicesList.Values.ToList().ForEach(x => x.OnLoad());
1187-
AppPlugins.ServiceEndpointsList.Values.ToList().ForEach(x => x.OnLoad());
1186+
await AppPlugins.TrackingDevicesList.Values.Reload();
1187+
await AppPlugins.ServiceEndpointsList.Values.Reload();
11881188
}
11891189

11901190
// Request page reloads

0 commit comments

Comments
 (0)