-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOpenVRManager.cs
557 lines (479 loc) · 25.4 KB
/
OpenVRManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
using MathNet.Numerics.LinearAlgebra;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using Valve.VR;
namespace VRC_OSC_ExternallyTrackedObject
{
public enum CalibrationField
{
POSX, POSY, POSZ,
ROTX, ROTY, ROTZ,
SCALE,
CALIBRATION_LAST
}
internal class OVRException : Exception {
public OVRException(string message) : base(message) { }
}
internal class DeviceListEntry
{
public ETrackedDeviceClass Type { get; set; }
public uint Handle { get; set; }
}
internal class TrackedObjectListEntry
{
public uint Index { get; set; }
public string Name { get; set; } = "";
}
public class CalibrationUpdateArgs : EventArgs
{
public enum CalibrationUpdateType
{
CALIBRATION_VALUE,
ACTIVE_FIELD,
};
public CalibrationUpdateType Type { get; set; }
public AvatarCalibration? CalibrationValues { get; set; }
public CalibrationField Field { get; set; }
}
public class TrackingDataArgs : EventArgs
{
public Matrix<float>? Controller { get; set; }
public Matrix<float>? Tracker { get; set; }
}
internal class OpenVRManager
{
private CVRSystem? cVR;
private BlockingCollection<Key> InputKeyQueue = new BlockingCollection<Key>();
private CancellationTokenSource CancelTokenSource = new CancellationTokenSource();
private Thread? currentThread = null;
private AvatarCalibration? currentCalibration;
private bool calibrationThreadRunning = false;
private bool trackingThreadRunning = false;
private bool trackingEnabled = false;
private Dictionary<string, DeviceListEntry> Devices = new Dictionary<string, DeviceListEntry>();
public event EventHandler? CalibrationUpdate;
public event EventHandler? TrackingData;
public OpenVRManager()
{
}
public bool IsCalibrationThreadRunning()
{
return calibrationThreadRunning;
}
public void InjectKeyPress(Key key)
{
InputKeyQueue.Add(key);
}
public void UpdateControllers()
{
if (cVR == null) return;
Devices.Clear();
// this is not optimal, ideally we could put everything in the same array but I don't think c# slices actually support that?
uint[] controllerIds = new uint[OpenVR.k_unMaxTrackedDeviceCount];
uint[] trackerIds = new uint[OpenVR.k_unMaxTrackedDeviceCount];
uint noOfControllers = OpenVR.System.GetSortedTrackedDeviceIndicesOfClass(ETrackedDeviceClass.Controller, controllerIds, OpenVR.k_unTrackedDeviceIndex_Hmd);
uint noOfTrackers = OpenVR.System.GetSortedTrackedDeviceIndicesOfClass(ETrackedDeviceClass.GenericTracker, trackerIds, OpenVR.k_unTrackedDeviceIndex_Hmd);
try
{
for (uint i = 0; i < noOfControllers; i++)
{
uint id = controllerIds[i];
Devices.Add(
GetStringTrackedDeviceProperty(id, ETrackedDeviceProperty.Prop_SerialNumber_String),
new DeviceListEntry { Handle = id, Type = ETrackedDeviceClass.Controller }
);
}
for (uint i = 0; i < noOfTrackers; i++)
{
uint id = trackerIds[i];
Devices.Add(
GetStringTrackedDeviceProperty(id, ETrackedDeviceProperty.Prop_SerialNumber_String),
new DeviceListEntry { Handle = id, Type = ETrackedDeviceClass.GenericTracker }
);
}
}
catch (OVRException e)
{
MessageBox.Show("Updating controllers and trackers encountered an unexpected OpenVR error: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
public List<string> GetControllers()
{
return Devices.Keys.Where(id => Devices[id].Type == ETrackedDeviceClass.Controller).ToList();
}
public List<string> GetTrackers()
{
return Devices.Keys.Where(id => Devices[id].Type == ETrackedDeviceClass.GenericTracker).ToList();
}
public List<string> GetAllDevices()
{
return Devices.Keys.ToList();
}
private string GetStringTrackedDeviceProperty(uint deviceIndex, ETrackedDeviceProperty prop)
{
ETrackedPropertyError err = ETrackedPropertyError.TrackedProp_Success;
StringBuilder sb = new StringBuilder(128);
uint propLen = OpenVR.System.GetStringTrackedDeviceProperty(deviceIndex, prop, sb, (uint)sb.Capacity, ref err);
if (err == ETrackedPropertyError.TrackedProp_Success)
{
return sb.ToString();
}
else if (err == ETrackedPropertyError.TrackedProp_BufferTooSmall)
{
// try again with larger buffer
sb.Capacity = (int)propLen;
propLen = OpenVR.System.GetStringTrackedDeviceProperty(deviceIndex, prop, sb, (uint)sb.Capacity, ref err);
}
if (err != ETrackedPropertyError.TrackedProp_Success)
{
throw new OVRException(err.ToString());
}
return sb.ToString();
}
public bool InitBackground()
{
if (cVR != null)
{
Shutdown();
}
EVRInitError error = EVRInitError.None;
cVR = OpenVR.Init(ref error, EVRApplicationType.VRApplication_Background);
if (error != EVRInitError.None)
{
MessageBox.Show("Error while connecting to SteamVR: " + error.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return false;
}
else
{
return true;
}
}
public bool InitOverlay()
{
if (cVR != null)
{
Shutdown();
}
EVRInitError error = EVRInitError.None;
cVR = OpenVR.Init(ref error, EVRApplicationType.VRApplication_Overlay);
if (error != EVRInitError.None)
{
MessageBox.Show("Error while connecting to SteamVR: " + error.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return false;
}
else
{
return true;
}
}
public void Shutdown()
{
if (cVR != null)
{
OpenVR.Shutdown();
cVR = null;
}
}
public void SetTrackingEnabled(bool enabled)
{
this.trackingEnabled = enabled;
}
public bool StartTrackingThread(string controllerSn, string trackerSn)
{
if (currentThread != null) return false;
if (!Devices.ContainsKey(controllerSn))
{
MessageBox.Show("The controller " + controllerSn + " does not exist", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return false;
}
if (!Devices.ContainsKey(trackerSn))
{
MessageBox.Show("The tracker " + trackerSn + " does not exist", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return false;
}
uint controllerHandle = Devices[controllerSn].Handle;
uint trackerHandle = Devices[trackerSn].Handle;
this.CancelTokenSource = new CancellationTokenSource();
this.currentThread = new Thread(() => TrackingThreadMain(controllerHandle, trackerHandle));
this.currentThread.Name = "TrackingThread";
this.currentThread.IsBackground = true;
this.currentThread.Start();
this.trackingThreadRunning = true;
this.trackingEnabled = false;
return true;
}
public void TrackingThreadMain(uint controllerHandle, uint trackerHandle)
{
TrackedDevicePose_t[] poses = new TrackedDevicePose_t[Math.Max(controllerHandle, trackerHandle) + 1];
TrackedDevicePose_t[] empty = new TrackedDevicePose_t[0];
var eventArgs = new TrackingDataArgs();
while (true)
{
if (CancelTokenSource.Token.WaitHandle.WaitOne(10))
{
return; // cancellation was requested
}
//OpenVR.System.GetDeviceToAbsoluteTrackingPose(ETrackingUniverseOrigin.TrackingUniverseStanding, 0, poses);
ThrowOVRError(OpenVR.Compositor.GetLastPoses(poses, empty));
var controllerPose = poses[controllerHandle];
var trackerPose = poses[trackerHandle];
eventArgs.Controller = MathUtils.OVR34ToMat44(ref controllerPose.mDeviceToAbsoluteTracking);
eventArgs.Tracker = MathUtils.OVR34ToMat44(ref trackerPose.mDeviceToAbsoluteTracking);
var handler = TrackingData;
handler?.Invoke(this, eventArgs);
}
}
public void StartCalibrationThread(string controllerSn, AvatarCalibration avatarCalibration)
{
if (currentThread != null) return;
if (!Devices.ContainsKey(controllerSn))
{
MessageBox.Show("The controller " + controllerSn + " does not exist", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
uint controllerHandle = Devices[controllerSn].Handle;
this.currentCalibration = avatarCalibration;
this.CancelTokenSource = new CancellationTokenSource();
this.currentThread = new Thread(() => CalibrationThreadMain(controllerHandle));
this.currentThread.Name = "CalibrationThread";
this.currentThread.IsBackground = true;
this.currentThread.Start();
this.calibrationThreadRunning = true;
}
public void CalibrationThreadMain(uint controllerHandle)
{
if (this.currentCalibration == null) return;
ulong OverlayXHandle = OpenVR.k_ulOverlayHandleInvalid;
ulong OverlayYHandle = OpenVR.k_ulOverlayHandleInvalid;
ulong OverlayZHandle = OpenVR.k_ulOverlayHandleInvalid;
Key nextKey;
var currentCalibrationField = CalibrationField.POSX;
Matrix<float> OverlayXMat = MathUtils.createTransformMatrix44((float)Math.PI, (float)(-Math.PI / 2), (float)(Math.PI / 2), 0, 0.05f, 0, 1, 1, 1);
HmdMatrix34_t OverlayXMatOVR = new HmdMatrix34_t();
MathUtils.CopyMat34ToOVR(ref OverlayXMat, ref OverlayXMatOVR);
Matrix<float> OverlayYMat = MathUtils.createTransformMatrix44(0, 0, 0, 0, 0, 0.05f, 1, 1, 1);
HmdMatrix34_t OverlayYMatOVR = new HmdMatrix34_t();
MathUtils.CopyMat34ToOVR(ref OverlayYMat, ref OverlayYMatOVR);
Matrix<float> OverlayZMat = MathUtils.createTransformMatrix44((float)(-Math.PI / 2), (float)Math.PI, (float)(Math.PI / 2), -0.05f, 0, 0, 1, 1, 1);
HmdMatrix34_t OverlayZMatOVR = new HmdMatrix34_t();
MathUtils.CopyMat34ToOVR(ref OverlayZMat, ref OverlayZMatOVR);
Matrix<float> currentTransformMatrix = Matrix<float>.Build.Dense(4, 4);
Matrix<float> m = Matrix<float>.Build.Dense(4, 4); // <-- matrix for temporary data storage in calculations
try
{
ThrowOVRError(OpenVR.Overlay.CreateOverlay("com.jangxx.vrc_osc_calibrate_x", "OSC Debug X Plane", ref OverlayXHandle));
ThrowOVRError(OpenVR.Overlay.SetOverlayWidthInMeters(OverlayXHandle, 0.1f));
ThrowOVRError(OpenVR.Overlay.SetOverlayTransformTrackedDeviceRelative(OverlayXHandle, controllerHandle, ref OverlayXMatOVR));
ThrowOVRError(OpenVR.Overlay.ShowOverlay(OverlayXHandle));
ThrowOVRError(OpenVR.Overlay.SetOverlayFromFile(OverlayXHandle, Path.GetFullPath("img\\debug overlay X.png")));
ThrowOVRError(OpenVR.Overlay.CreateOverlay("com.jangxx.vrc_osc_calibrate_y", "OSC Debug Y Plane", ref OverlayYHandle));
ThrowOVRError(OpenVR.Overlay.SetOverlayWidthInMeters(OverlayYHandle, 0.1f));
ThrowOVRError(OpenVR.Overlay.SetOverlayTransformTrackedDeviceRelative(OverlayYHandle, controllerHandle, ref OverlayYMatOVR));
ThrowOVRError(OpenVR.Overlay.ShowOverlay(OverlayYHandle));
ThrowOVRError(OpenVR.Overlay.SetOverlayFromFile(OverlayYHandle, Path.GetFullPath("img\\debug overlay Y.png")));
ThrowOVRError(OpenVR.Overlay.CreateOverlay("com.jangxx.vrc_osc_calibrate_z", "OSC Debug Z Plane", ref OverlayZHandle));
ThrowOVRError(OpenVR.Overlay.SetOverlayWidthInMeters(OverlayZHandle, 0.1f));
ThrowOVRError(OpenVR.Overlay.SetOverlayTransformTrackedDeviceRelative(OverlayZHandle, controllerHandle, ref OverlayZMatOVR));
ThrowOVRError(OpenVR.Overlay.ShowOverlay(OverlayZHandle));
ThrowOVRError(OpenVR.Overlay.SetOverlayFromFile(OverlayZHandle, Path.GetFullPath("img\\debug overlay Z.png")));
{ // emit an initial event to highlight the first field
var args = new CalibrationUpdateArgs() { Type = CalibrationUpdateArgs.CalibrationUpdateType.ACTIVE_FIELD, Field = currentCalibrationField };
var handler = CalibrationUpdate;
handler?.Invoke(this, args);
}
// do one initial update to show the current calibration
MathUtils.fillTransformMatrix44(ref currentTransformMatrix,
(float)currentCalibration.RotationX,
(float)currentCalibration.RotationY,
(float)currentCalibration.RotationZ,
(float)currentCalibration.TranslationX,
(float)currentCalibration.TranslationY,
(float)currentCalibration.TranslationZ,
(float)currentCalibration.Scale,
(float)currentCalibration.Scale,
(float)currentCalibration.Scale
);
currentTransformMatrix.Multiply(OverlayXMat, m);
MathUtils.CopyMat34ToOVR(ref m, ref OverlayXMatOVR);
currentTransformMatrix.Multiply(OverlayYMat, m);
MathUtils.CopyMat34ToOVR(ref m, ref OverlayYMatOVR);
currentTransformMatrix.Multiply(OverlayZMat, m);
MathUtils.CopyMat34ToOVR(ref m, ref OverlayZMatOVR);
OpenVR.Overlay.SetOverlayTransformTrackedDeviceRelative(OverlayXHandle, controllerHandle, ref OverlayXMatOVR);
OpenVR.Overlay.SetOverlayTransformTrackedDeviceRelative(OverlayYHandle, controllerHandle, ref OverlayYMatOVR);
OpenVR.Overlay.SetOverlayTransformTrackedDeviceRelative(OverlayZHandle, controllerHandle, ref OverlayZMatOVR);
while (InputKeyQueue.TryTake(out nextKey, -1, CancelTokenSource.Token))
{
switch(nextKey)
{
// switch to previous param
case Key.Left:
{
int field_len = (int)CalibrationField.CALIBRATION_LAST;
currentCalibrationField = (CalibrationField)((((int)currentCalibrationField - 1) + field_len) % field_len);
var args = new CalibrationUpdateArgs() { Type = CalibrationUpdateArgs.CalibrationUpdateType.ACTIVE_FIELD, Field = currentCalibrationField };
var handler = CalibrationUpdate;
handler?.Invoke(this, args);
continue;
}
// switch to next param
case Key.Right:
{
int field_len = (int)CalibrationField.CALIBRATION_LAST;
currentCalibrationField = (CalibrationField)(((int)currentCalibrationField + 1) % field_len);
var args = new CalibrationUpdateArgs() { Type = CalibrationUpdateArgs.CalibrationUpdateType.ACTIVE_FIELD, Field = currentCalibrationField };
var handler = CalibrationUpdate;
handler?.Invoke(this, args);
continue;
}
// increase current parameter value
case Key.Up:
{
transformMatrixInDirection(ref currentTransformMatrix, currentCalibrationField, 1);
currentCalibration.CopyFrom(AvatarCalibration.FromMatrix(currentTransformMatrix));
var args = new CalibrationUpdateArgs() { Type = CalibrationUpdateArgs.CalibrationUpdateType.CALIBRATION_VALUE, Field = currentCalibrationField, CalibrationValues = currentCalibration };
var handler = CalibrationUpdate;
handler?.Invoke(this, args);
break;
}
// decrease current parameter value
case Key.Down:
{
transformMatrixInDirection(ref currentTransformMatrix, currentCalibrationField, -1);
currentCalibration.CopyFrom(AvatarCalibration.FromMatrix(currentTransformMatrix));
var args = new CalibrationUpdateArgs() { Type = CalibrationUpdateArgs.CalibrationUpdateType.CALIBRATION_VALUE, Field = currentCalibrationField, CalibrationValues = currentCalibration };
var handler = CalibrationUpdate;
handler?.Invoke(this, args);
break;
}
}
currentTransformMatrix.Multiply(OverlayXMat, m);
MathUtils.CopyMat34ToOVR(ref m, ref OverlayXMatOVR);
currentTransformMatrix.Multiply(OverlayYMat, m);
MathUtils.CopyMat34ToOVR(ref m, ref OverlayYMatOVR);
currentTransformMatrix.Multiply(OverlayZMat, m);
MathUtils.CopyMat34ToOVR(ref m, ref OverlayZMatOVR);
OpenVR.Overlay.SetOverlayTransformTrackedDeviceRelative(OverlayXHandle, controllerHandle, ref OverlayXMatOVR);
OpenVR.Overlay.SetOverlayTransformTrackedDeviceRelative(OverlayYHandle, controllerHandle, ref OverlayYMatOVR);
OpenVR.Overlay.SetOverlayTransformTrackedDeviceRelative(OverlayZHandle, controllerHandle, ref OverlayZMatOVR);
}
}
catch(OperationCanceledException)
{
Debug.WriteLine("Calibration thread exited");
}
catch (OVRException e)
{
MessageBox.Show("Calibration encountered an unexpected OpenVR error: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
catch(Exception e)
{
MessageBox.Show("Calibration thread encountered an unexpected error: " + e.ToString() + " (" + e.Message + ")", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
finally
{
//Shutdown();
OpenVR.Overlay.DestroyOverlay(OverlayXHandle);
OpenVR.Overlay.DestroyOverlay(OverlayYHandle);
OpenVR.Overlay.DestroyOverlay(OverlayZHandle);
}
}
private void transformMatrixInDirection(ref Matrix<float> calibrationMatrix, CalibrationField field, float direction)
{
switch (field)
{
case CalibrationField.POSX:
{
var transform = MathUtils.createTransformMatrix44(0, 0, 0, 0.005f * direction, 0, 0, 1, 1, 1);
transform.Multiply(calibrationMatrix, calibrationMatrix);
return;
}
case CalibrationField.POSY:
{
var transform = MathUtils.createTransformMatrix44(0, 0, 0, 0, 0.005f * direction, 0, 1, 1, 1);
transform.Multiply(calibrationMatrix, calibrationMatrix);
return;
}
case CalibrationField.POSZ:
{
var transform = MathUtils.createTransformMatrix44(0, 0, 0, 0, 0, 0.005f * direction, 1, 1, 1);
transform.Multiply(calibrationMatrix, calibrationMatrix);
return;
}
case CalibrationField.ROTX:
{
var translate = MathUtils.extractTranslationFromMatrix44(calibrationMatrix).Clone();
MathUtils.createTransformMatrix44(0, 0, 0, -translate[0], -translate[1], -translate[2], 1, 1, 1).Multiply(calibrationMatrix, calibrationMatrix);
MathUtils.createTransformMatrix44(0.01f * direction, 0, 0, 0, 0, 0, 1, 1, 1).Multiply(calibrationMatrix, calibrationMatrix);
MathUtils.createTransformMatrix44(0, 0, 0, translate[0], translate[1], translate[2], 1, 1, 1).Multiply(calibrationMatrix, calibrationMatrix);
return;
}
case CalibrationField.ROTY:
{
var translate = MathUtils.extractTranslationFromMatrix44(calibrationMatrix).Clone();
MathUtils.createTransformMatrix44(0, 0, 0, -translate[0], -translate[1], -translate[2], 1, 1, 1).Multiply(calibrationMatrix, calibrationMatrix);
MathUtils.createTransformMatrix44(0, 0.01f * direction, 0, 0, 0, 0, 1, 1, 1).Multiply(calibrationMatrix, calibrationMatrix);
MathUtils.createTransformMatrix44(0, 0, 0, translate[0], translate[1], translate[2], 1, 1, 1).Multiply(calibrationMatrix, calibrationMatrix);
return;
}
case CalibrationField.ROTZ:
{
var translate = MathUtils.extractTranslationFromMatrix44(calibrationMatrix).Clone();
MathUtils.createTransformMatrix44(0, 0, 0, -translate[0], -translate[1], -translate[2], 1, 1, 1).Multiply(calibrationMatrix, calibrationMatrix);
MathUtils.createTransformMatrix44(0, 0, 0.01f * direction, 0, 0, 0, 1, 1, 1).Multiply(calibrationMatrix, calibrationMatrix);
MathUtils.createTransformMatrix44(0, 0, 0, translate[0], translate[1], translate[2], 1, 1, 1).Multiply(calibrationMatrix, calibrationMatrix);
return;
}
case CalibrationField.SCALE:
{
var translate = MathUtils.extractTranslationFromMatrix44(calibrationMatrix).Clone();
MathUtils.createTransformMatrix44(0, 0, 0, -translate[0], -translate[1], -translate[2], 1, 1, 1).Multiply(calibrationMatrix, calibrationMatrix);
MathUtils.createTransformMatrix44(
0, 0, 0,
0, 0, 0,
1 + 0.005f * direction,
1 + 0.005f * direction,
1 + 0.005f * direction
).Multiply(calibrationMatrix, calibrationMatrix);
MathUtils.createTransformMatrix44(0, 0, 0, translate[0], translate[1], translate[2], 1, 1, 1).Multiply(calibrationMatrix, calibrationMatrix);
return;
}
}
}
private void ThrowOVRError(EVROverlayError err)
{
if (err != EVROverlayError.None)
{
throw new OVRException(err.ToString());
}
}
private void ThrowOVRError(EVRCompositorError err)
{
if (err != EVRCompositorError.None)
{
throw new OVRException(err.ToString());
}
}
public bool IsAnyThreadRunning()
{
return this.currentThread != null;
}
public void StopThread()
{
if (currentThread == null) return;
CancelTokenSource.Cancel();
currentThread.Join();
currentThread = null;
this.calibrationThreadRunning = false;
}
}
}