@@ -16,6 +16,13 @@ public class VRCFTPicoModule : ExtTrackingModule
1616 private static int _port ;
1717 private Updater ? _updater ;
1818 private ( bool , bool ) _trackingAvailable ;
19+ private static readonly string GainFilePath =
20+ Path . Combine (
21+ Path . GetDirectoryName ( System . Reflection . Assembly . GetExecutingAssembly ( ) . Location ) ! ,
22+ "eye_gain.txt"
23+ ) ;
24+ private static float _eyeGainX = 1.0f ;
25+ private static float _eyeGainY = 1.0f ;
1926
2027 public override ( bool SupportsEye , bool SupportsExpression ) Supported => ( true , true ) ;
2128
@@ -36,6 +43,7 @@ public override (bool eyeSuccess, bool expressionSuccess) Initialize(bool eyeAva
3643 return initializationResult ;
3744 }
3845
46+
3947 private async Task < ( bool eyeSuccess , bool expressionSuccess ) > InitializeAsync ( )
4048 {
4149 Logger . LogDebug ( T ( "initializing-udp-clients" ) , string . Join ( ", " , Ports ) ) ;
@@ -51,12 +59,15 @@ public override (bool eyeSuccess, bool expressionSuccess) Initialize(bool eyeAva
5159 Logger . LogInformation ( T ( "eye-tracking-disabled" ) ) ;
5260 if ( ! _trackingAvailable . Item2 )
5361 Logger . LogInformation ( T ( "expression-tracking-disabled" ) ) ;
54-
62+
63+ LoadEyeGain ( ) ;
5564 _updater = new Updater ( _udpClient , Logger , _port == Ports [ 1 ] , _trackingAvailable ) ;
65+ _updater . EyeGainX = _eyeGainX ;
66+ _updater . EyeGainY = _eyeGainY ;
5667
5768 return _trackingAvailable ;
5869 }
59-
70+
6071 private ( bool , bool ) ReadConfiguration ( )
6172 {
6273 var currentDirectory = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ;
@@ -140,4 +151,36 @@ public override void Teardown()
140151 _udpClient . Dispose ( ) ;
141152 _updater = null ;
142153 }
154+ private void LoadEyeGain ( )
155+ {
156+ try
157+ {
158+ if ( ! File . Exists ( GainFilePath ) )
159+ {
160+ Logger . LogDebug ( "eye_gain.txt not found, using default values" ) ;
161+ return ;
162+ }
163+
164+ var text = File . ReadAllText ( GainFilePath ) . Trim ( ) ;
165+ var parts = text . Split ( ',' ) ;
166+
167+ if ( parts . Length >= 2 &&
168+ float . TryParse ( parts [ 0 ] , NumberStyles . Float , CultureInfo . InvariantCulture , out var x ) &&
169+ float . TryParse ( parts [ 1 ] , NumberStyles . Float , CultureInfo . InvariantCulture , out var y ) )
170+ {
171+ _eyeGainX = x ;
172+ _eyeGainY = y ;
173+
174+ Logger . LogInformation ( $ "Eye gain loaded: X={ _eyeGainX } , Y={ _eyeGainY } ") ;
175+ }
176+ else
177+ {
178+ Logger . LogWarning ( $ "Invalid eye_gain.txt format: \" { text } \" ") ;
179+ }
180+ }
181+ catch ( Exception ex )
182+ {
183+ Logger . LogError ( ex , "Failed to read eye_gain.txt" ) ;
184+ }
185+ }
143186}
0 commit comments