From 0f1bfc5a17180c3045aa92221ef1cf08662ad1a1 Mon Sep 17 00:00:00 2001 From: Clansty Date: Tue, 22 Oct 2024 00:19:12 +0800 Subject: [PATCH] [+] TouchPanelBaudRate --- AquaMai/AquaMai.toml | 4 ++++ AquaMai/AquaMai.zh.toml | 4 ++++ AquaMai/Config.cs | 1 + AquaMai/Main.cs | 1 + AquaMai/Utils/TouchPanelBaudRate.cs | 15 +++++++++++++++ 5 files changed, 25 insertions(+) create mode 100644 AquaMai/Utils/TouchPanelBaudRate.cs diff --git a/AquaMai/AquaMai.toml b/AquaMai/AquaMai.toml index b9bbcff5..dd0529c3 100644 --- a/AquaMai/AquaMai.toml +++ b/AquaMai/AquaMai.toml @@ -105,6 +105,10 @@ FrameRateDisplay=false # Practice mode, activated by pressing Test in the game # Must be used together with TestProof PractiseMode=true +# Adjust the baud rate of the touch screen serial port, default value is 9600 +# Requires hardware support. If you are unsure whether you can use it, you cannot use it +# Set to 0 to disable +TouchPanelBaudRate=0 # =================================== # Save some potentially unnecessary time diff --git a/AquaMai/AquaMai.zh.toml b/AquaMai/AquaMai.zh.toml index 3ed10513..d5a66711 100644 --- a/AquaMai/AquaMai.zh.toml +++ b/AquaMai/AquaMai.zh.toml @@ -125,6 +125,10 @@ FrameRateDisplay=false # 练习模式,在游戏中按 Test 打开 # 必须和 TestProof 一起用 PractiseMode=true +# 调整触摸屏串口波特率,默认值 9600 +# 需要硬件配合。如果你不清楚你是否可以使用,那你不能使用 +# 改为 0 禁用 +TouchPanelBaudRate=0 # =================================== # 节省一些不知道有用没用的时间 diff --git a/AquaMai/Config.cs b/AquaMai/Config.cs index c9d0712e..d052d428 100644 --- a/AquaMai/Config.cs +++ b/AquaMai/Config.cs @@ -75,6 +75,7 @@ public class UtilsConfig public bool SelectionDetail { get; set; } public bool ShowNetErrorDetail { get; set; } public bool FrameRateDisplay { get; set; } + public int TouchPanelBaudRate { get; set; } } public class TimeSavingConfig diff --git a/AquaMai/Main.cs b/AquaMai/Main.cs index 11ea42f7..10918cc1 100644 --- a/AquaMai/Main.cs +++ b/AquaMai/Main.cs @@ -168,6 +168,7 @@ public override void OnInitializeMelon() Patch(typeof(CustomLogo)); // Utils Patch(typeof(JudgeAdjust)); + Patch(typeof(TouchPanelBaudRate)); # if DEBUG Patch(typeof(LogNetworkErrors)); # endif diff --git a/AquaMai/Utils/TouchPanelBaudRate.cs b/AquaMai/Utils/TouchPanelBaudRate.cs new file mode 100644 index 00000000..57cdb091 --- /dev/null +++ b/AquaMai/Utils/TouchPanelBaudRate.cs @@ -0,0 +1,15 @@ +using HarmonyLib; +using IO; + +namespace AquaMai.Utils; + +public class TouchPanelBaudRate +{ + [HarmonyPatch(typeof(NewTouchPanel), "Open")] + [HarmonyPrefix] + private static void OpenPrefix(ref int ___BaudRate) + { + if (AquaMai.AppConfig.Utils.TouchPanelBaudRate <= 0) return; + ___BaudRate = AquaMai.AppConfig.Utils.TouchPanelBaudRate; + } +}