Skip to content

Commit 92dfbde

Browse files
committed
[F] 擦屁股
1 parent 3c4897d commit 92dfbde

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

AquaMai.Mods/Fix/MaimollerFix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace AquaMai.Mods.Fix;
1717
[EnableIf(nameof(shouldEnable))]
1818
public class MaimollerFix
1919
{
20-
private static readonly Assembly shit = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(it => it.GetName().Name == "ADXHIDIOMod");
20+
public static readonly Assembly shit = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(it => it.GetName().Name == "ADXHIDIOMod");
2121
private static bool shouldEnable = shit != null;
2222

2323
public static void OnBeforePatch()

AquaMai.Mods/GameSystem/AdxHidInput.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using AquaMai.Config.Types;
1010
using AquaMai.Core.Attributes;
1111
using AquaMai.Core.Helpers;
12+
using AquaMai.Mods.Fix;
1213
using AquaMai.Mods.Tweaks;
1314
using HarmonyLib;
1415
using HidLibrary;
@@ -102,14 +103,26 @@ private static bool NeedsButtonInput(int p)
102103
}
103104
}
104105

106+
[ConfigEntry("热插拔支持")]
107+
private static readonly bool hotPlugSupport = true;
108+
109+
private static bool RealHotPlugSupport => hotPlugSupport && MaimollerFix.shit == null;
110+
105111
private static void HidInputThread(int p)
106112
{
107113
while (true)
108114
{
109-
while (!IsDeviceAvailable(p))
115+
if (RealHotPlugSupport)
110116
{
111-
Thread.Sleep(500);
112-
TryConnectDevice(p);
117+
while (!IsDeviceAvailable(p))
118+
{
119+
Thread.Sleep(500);
120+
TryConnectDevice(p);
121+
}
122+
}
123+
else
124+
{
125+
if (!IsDeviceAvailable(p)) return;
113126
}
114127

115128
if (!NeedsButtonInput(p))
@@ -128,6 +141,7 @@ private static void HidInputThread(int p)
128141
if (report.Status != HidDeviceData.ReadStatus.Success)
129142
{
130143
DisconnectDevice(p);
144+
if (!RealHotPlugSupport) return;
131145
continue;
132146
}
133147

@@ -146,6 +160,7 @@ private static void HidInputThread(int p)
146160
catch
147161
{
148162
DisconnectDevice(p);
163+
if (!RealHotPlugSupport) return;
149164
}
150165
}
151166
}
@@ -214,6 +229,8 @@ public static void OnBeforeEnableCheck()
214229
for (int i = 0; i < 2; i++)
215230
{
216231
if (hidThreadRunning[i]) continue;
232+
if (!RealHotPlugSupport && adxController[i] == null) continue;
233+
if (!RealHotPlugSupport && !NeedsButtonInput(i)) continue;
217234

218235
keyEnabled = true;
219236
hidThreadRunning[i] = true;

0 commit comments

Comments
 (0)