mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-18 15:07:49 +08:00
fix: add copy paste fallback detection
This commit is contained in:
parent
8080129d58
commit
65a4f4540c
@ -201,12 +201,17 @@ The following helper methods are available:
|
||||
|
||||
internal static bool IsUserCopyPasting()
|
||||
{
|
||||
return inputsWithinThreshold > inputThreshold;
|
||||
return (InputManager.GetKey(KeyCode.LeftControl) || InputManager.GetKey(KeyCode.RightControl))
|
||||
&& InputManager.GetKeyDown(KeyCode.V);
|
||||
}
|
||||
|
||||
public void UpdateConsole()
|
||||
{
|
||||
if (inputsWithinThreshold > 0 && DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond - lastInputChange >= inputSpamThresholdMs * 2)
|
||||
{
|
||||
inputsWithinThreshold = 0;
|
||||
}
|
||||
if (s_copyPasteBuffer != null)
|
||||
{
|
||||
if (!IsUserCopyPasting())
|
||||
@ -290,8 +295,26 @@ The following helper methods are available:
|
||||
|
||||
internal static string s_copyPasteBuffer;
|
||||
|
||||
internal static long lastInputChange;
|
||||
internal static int inputsWithinThreshold;
|
||||
|
||||
internal static readonly long inputSpamThresholdMs = 5;
|
||||
internal static readonly long inputThreshold = 1;
|
||||
|
||||
public void OnInputChanged(string newText, bool forceUpdate = false)
|
||||
{
|
||||
var timeSinceLastInput = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond - lastInputChange;
|
||||
lastInputChange = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
|
||||
|
||||
if (timeSinceLastInput < lastInputChange)
|
||||
{
|
||||
inputsWithinThreshold++;
|
||||
}
|
||||
else
|
||||
{
|
||||
inputsWithinThreshold = 0;
|
||||
}
|
||||
|
||||
if (IsUserCopyPasting())
|
||||
{
|
||||
//Console.WriteLine("Copy+Paste detected!");
|
||||
|
Loading…
x
Reference in New Issue
Block a user