99using AquaMai . Config . Types ;
1010using AquaMai . Core . Attributes ;
1111using AquaMai . Core . Helpers ;
12+ using AquaMai . Mods . Fix ;
1213using AquaMai . Mods . Tweaks ;
1314using HarmonyLib ;
1415using 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