-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[+] Prevent accidental touch of the Test button
- Loading branch information
Showing
5 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using HarmonyLib; | ||
using Manager; | ||
using MelonLoader; | ||
|
||
namespace AquaMai.UX; | ||
|
||
public class TestProof | ||
{ | ||
private static int _keyPressFrames; | ||
|
||
[HarmonyPrefix] | ||
[HarmonyPatch(typeof(InputManager), "GetSystemInputDown")] | ||
public static bool GetSystemInputDown(ref bool __result, InputManager.SystemButtonSetting button, bool[] ___SystemButtonDown) | ||
{ | ||
__result = ___SystemButtonDown[(int)button]; | ||
if (button != InputManager.SystemButtonSetting.ButtonTest) | ||
return false; | ||
if (!InputManager.GetSystemInputPush(button)) | ||
{ | ||
_keyPressFrames = 0; | ||
return false; | ||
} | ||
|
||
var stackTrace = new StackTrace(); // get call stack | ||
var stackFrames = stackTrace.GetFrames(); // get method calls (frames) | ||
|
||
if (stackFrames.Any(it => it.GetMethod().Name == "DMD<Main.GameMainObject::Update>")) | ||
{ | ||
__result = false; | ||
if (InputManager.GetSystemInputPush(button)) | ||
{ | ||
_keyPressFrames++; | ||
} | ||
|
||
if (_keyPressFrames == 60) | ||
{ | ||
__result = true; | ||
} | ||
|
||
MelonLogger.Msg(_keyPressFrames); | ||
} | ||
|
||
return false; | ||
} | ||
} |