File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ using System . IO . Ports ;
2+ using AquaMai . Config . Attributes ;
3+ using HarmonyLib ;
4+ using IO ;
5+ using MAI2System ;
6+ using MelonLoader ;
7+
8+ namespace AquaMai . Mods . Fix ;
9+
10+ [ ConfigSection ( exampleHidden : true , defaultOn : true ) ]
11+ public class FixTouchPanelLeak
12+ {
13+ [ HarmonyPostfix ]
14+ [ HarmonyPatch ( typeof ( NewTouchPanel ) , "Open" ) ]
15+ public static void PostOpen ( SerialPort ____serialPort , NewTouchPanel __instance , uint ____monitorIndex )
16+ {
17+ ____serialPort . ErrorReceived += ( _ , e ) =>
18+ {
19+ MelonLogger . Error ( $ "[TouchPanel { ____monitorIndex } ] SerialPort error: { e . EventType } ") ;
20+ var t = Traverse . Create ( __instance ) ;
21+ t . Field < ConstParameter . ErrorID > ( "_psError" ) . Value = ( ____monitorIndex == 0 )
22+ ? ConstParameter . ErrorID . TouchPanel_Left_OpenError
23+ : ConstParameter . ErrorID . TouchPanel_Right_OpenError ;
24+ t . Field < bool > ( "_isRunning" ) . Value = false ;
25+ __instance . Status = NewTouchPanel . StatusEnum . GotoError ;
26+ // t.Method("Close").GetValue();
27+ // __instance.Status = NewTouchPanel.StatusEnum.Error;
28+ } ;
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments