@@ -21,38 +21,9 @@ public sealed class ViveStreamingFaceTrackingDriver : IInputDriver, IDisposable
2121 private static string ? eyeData ;
2222 private static string ? lipData ;
2323
24- private bool _active ;
25- public bool Active
26- {
27- set
28- {
29- if ( _active == value )
30- {
31- return ;
32- }
24+ private bool _tracking ;
25+ public bool active ;
3326
34- _active = value ;
35- if ( value )
36- {
37- if ( ! VS_PC_SDK . VS_StartFaceTracking ( ) )
38- {
39- ResoniteMod . Error ( "Failed to start face tracking" ) ;
40- throw new InvalidOperationException ( "Failed to start face tracking" ) ;
41- }
42- }
43- else
44- {
45- if ( ! VS_PC_SDK . VS_StopFaceTracking ( ) )
46- {
47- throw new InvalidOperationException ( "Failed to stop face tracking" ) ;
48- }
49- }
50- }
51- get
52- {
53- return _active ;
54- }
55- }
5627 public ViveStreamingFaceTrackingDriver ( )
5728 {
5829 ResoniteMod . Debug ( $ "Initializing Vive Streaming Face Tracking") ;
@@ -169,13 +140,38 @@ private static void OnDebugLog(string message)
169140
170141 public void UpdateInputs ( float deltaTime )
171142 {
143+ if ( connected && ! _tracking && active )
144+ {
145+ if ( ! VS_PC_SDK . VS_StartFaceTracking ( ) )
146+ {
147+ ResoniteMod . Error ( "Failed to start face tracking" ) ;
148+ throw new InvalidOperationException ( "Failed to start face tracking" ) ;
149+ }
150+ _tracking = true ;
151+ }
152+
153+ if ( connected && _tracking && ! active )
154+ {
155+ if ( ! VS_PC_SDK . VS_StopFaceTracking ( ) )
156+ {
157+ ResoniteMod . Error ( "Failed to stop face tracking" ) ;
158+ throw new InvalidOperationException ( "Failed to stop face tracking" ) ;
159+ }
160+ _tracking = false ;
161+ }
162+
163+ if ( ! connected )
164+ {
165+ _tracking = false ;
166+ }
167+
172168 eyes ? . UpdateInputs ( connected , ref eyeData ) ;
173169 mouth ? . UpdateInputs ( connected , ref lipData ) ;
174170 }
175171
176172 public void Dispose ( )
177173 {
178- Active = false ;
174+ active = false ;
179175
180176 var result = VS_PC_SDK . VS_Release ( ) ;
181177 if ( result != 0 )
0 commit comments