Skip to content

Commit 9fb545b

Browse files
authored
Merge pull request lonelyicer#11 from lonelyicer/dev
feat: allow forced disabling of expression or eye tracking
2 parents a77df9f + 1ed6428 commit 9fb545b

6 files changed

Lines changed: 65 additions & 1 deletion

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,13 @@ Done! You have successfully installed the module.
3838
> [!NOTE]
3939
> To manual change protocol version,
4040
> you will need change the value of `faceTrackingTransferProtocol` in the `settings.json` file located in the `%AppData%/PICO Connect/` directory to `2` or `1`.
41+
42+
## Configuration
43+
44+
To selectively disable eye or facial expression tracking, please follow these steps:
45+
46+
### 1.Navigate to the module's configuration directory (path can be found in module logs)
47+
### 2.Create corresponding files:
48+
- Create `.disable_eye` to disable eye tracking
49+
- Create `.disable_expression` to disable facial expression tracking
50+
### 3.Restart the VRCFaceTracking for changes to take effect

README.zh.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,13 @@ VRCFTPicoModule 是一个为 VRCFaceTracking 添加了对 PICO 4 Pro / Enterpris
3838
> [!NOTE]
3939
> 要手动更改协议版本,
4040
> 你需要修改位于 `%AppData%/PICO Connect/` 目录下的 `settings.json` 文件内的 `faceTrackingTransferProtocol` 键对应的值为 `2` 或者 `1`。
41+
42+
## 配置
43+
44+
如需单独禁用眼部或表情追踪功能,请按以下步骤操作:
45+
46+
### 1.打开模块的配置文件目录(路径可在模块日志中查看)
47+
### 2.在目录中创建对应文件:
48+
- 创建 `.disable_eye` 文件关闭眼部追踪
49+
- 创建 `.disable_expression` 文件关闭表情追踪
50+
### 3.重启 VRCFaceTracking 使配置生效

VRCFTPicoModule.sln.DotSettings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=VRCFT/@EntryIndexedValue">VRCFT</s:String></wpf:ResourceDictionary>

VRCFTPicoModule/Assets/Locales/en-US.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"start-init": "Starting Initialization...",
3+
"config-path": "The configuration file will be in {0}",
4+
"force-disable-eye": "Eye tracking is force disabled",
5+
"force-disable-expression": "Expression tracking is force disabled",
36
"initializing-udp-clients": "Initializing UDP Clients on ports: {0}",
47
"using-port": "Using port: {0}",
58
"eye-tracking-disabled": "Eye tracking is disabled",

VRCFTPicoModule/Assets/Locales/zh-CN.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"start-init": "正在开始初始化...",
3+
"config-path": "配置文件将位于 {0}",
4+
"force-disable-eye": "眼部追踪已强制关闭",
5+
"force-disable-expression": "表情追踪已强制关闭",
36
"initializing-udp-clients": "正在端口 {0} 上初始化 UDP 客户端",
47
"using-port": "使用端口:{0}",
58
"eye-tracking-disabled": "眼部追踪已停用",

VRCFTPicoModule/VRCFTPicoModule.cs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Globalization;
22
using Microsoft.Extensions.Logging;
33
using System.Net.Sockets;
4+
using System.Reflection;
45
using VRCFaceTracking;
56
using VRCFTPicoModule.Utils;
67
using static VRCFTPicoModule.Utils.Localization;
@@ -22,7 +23,13 @@ public override (bool eyeSuccess, bool expressionSuccess) Initialize(bool eyeAva
2223
{
2324
Localization.Initialize(CultureInfo.CurrentUICulture.Name);
2425
Logger.LogInformation(T("start-init"));
25-
_trackingAvailable = (eyeAvailable, expressionAvailable);
26+
27+
var config = ReadConfiguration();
28+
_trackingAvailable = (
29+
!config.Item1 && eyeAvailable,
30+
!config.Item2 && expressionAvailable
31+
);
32+
2633
var initializationResult = InitializeAsync().GetAwaiter().GetResult();
2734
UpdateModuleInfo(initializationResult);
2835

@@ -50,6 +57,35 @@ public override (bool eyeSuccess, bool expressionSuccess) Initialize(bool eyeAva
5057
return _trackingAvailable;
5158
}
5259

60+
private (bool, bool) ReadConfiguration()
61+
{
62+
var currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
63+
Logger.LogInformation(T("config-path"), currentDirectory);
64+
65+
if (!Directory.Exists(currentDirectory))
66+
return (false, false);
67+
68+
var disableEye = false;
69+
var disableExpression = false;
70+
71+
var eyeFilePath = Path.Combine(currentDirectory, ".disable_eye");
72+
if (File.Exists(eyeFilePath))
73+
{
74+
disableEye = true;
75+
Logger.LogInformation(T("force-disable-eye"));
76+
}
77+
78+
var expressionFilePath = Path.Combine(currentDirectory, ".disable_expression");
79+
// ReSharper disable once InvertIf
80+
if (File.Exists(expressionFilePath))
81+
{
82+
disableExpression = true;
83+
Logger.LogInformation(T("force-disable-expression"));
84+
}
85+
86+
return (disableEye, disableExpression);
87+
}
88+
5389
private void UpdateModuleInfo((bool, bool) initializationResult)
5490
{
5591
var moduleProtocol = _port == Ports[1] ? $" [{T("legacy-protocol")}]" : "";

0 commit comments

Comments
 (0)