118 lines
3.4 KiB
C#
118 lines
3.4 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.Speech.Synthesis;
|
|
|
|
namespace Lua
|
|
{
|
|
static class Utils
|
|
{
|
|
// AA0091
|
|
public static readonly SpeechSynthesizer Tts = new SpeechSynthesizer();
|
|
// AA0092
|
|
private static readonly object TtsLock = new object();
|
|
|
|
// AA0093
|
|
[DllImport("user32.dll")]
|
|
public static extern short GetAsyncKeyState(int vKey);
|
|
|
|
// AA0094
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
|
|
public static extern short GetKeyState(int keyCode);
|
|
|
|
// AA0095
|
|
[DllImport("user32.dll")]
|
|
public static extern void mouse_event(uint dwFlags, int dx, int dy, uint dwData, UIntPtr dwExtraInfo);
|
|
|
|
// AA0096
|
|
public const uint MOUSEEVENTF_MOVE = 0x0001;
|
|
|
|
// AA0097
|
|
private const int VK_CAPITAL = 0x14;
|
|
// AA0098
|
|
private static bool _previousCapsState;
|
|
|
|
// AA0099
|
|
public static void InitializeCapsState()
|
|
{
|
|
_previousCapsState = IsCapsLockOn();
|
|
}
|
|
|
|
// AA0100
|
|
public static bool IsPressed(int vKey) => (GetAsyncKeyState(vKey) & 0x8000) != 0;
|
|
// AA0101
|
|
public static bool IsCapsLockOn() => (GetKeyState(VK_CAPITAL) & 0x0001) != 0;
|
|
// AA0102
|
|
public static void MoveMouse(int dx, int dy) => mouse_event(MOUSEEVENTF_MOVE, dx, dy, 0, UIntPtr.Zero);
|
|
|
|
// AA0103
|
|
public static void SafeSpeak(string text)
|
|
{
|
|
if (!ConfigLoader.ttsEnabled) return;
|
|
|
|
lock (TtsLock)
|
|
{
|
|
try
|
|
{
|
|
Tts.SpeakAsyncCancelAll();
|
|
Tts.SpeakAsync(text);
|
|
}
|
|
catch { /* AA0104 */ }
|
|
}
|
|
}
|
|
|
|
// AA0105
|
|
public static void ShowCapsLockStatus()
|
|
{
|
|
Console.WriteLine(IsCapsLockOn()
|
|
? "🚫 Recoil Control: OFF (CapsLock ON)"
|
|
: $"✅ Recoil Control: ON (CapsLock OFF) | Current Set: {OperatorSets.CurrentSet}");
|
|
}
|
|
|
|
// AA0106
|
|
public static void CheckCapsLockChange()
|
|
{
|
|
bool caps = IsCapsLockOn();
|
|
if (caps != _previousCapsState)
|
|
{
|
|
_previousCapsState = caps;
|
|
ShowCapsLockStatus();
|
|
}
|
|
}
|
|
|
|
// AA0107
|
|
public static void DisplayCurrentOperator(string action)
|
|
{
|
|
Console.WriteLine($"🎮 {action} | Current Operator: {OperatorSets.CurrentSet}");
|
|
SafeSpeak(OperatorSets.CurrentSet);
|
|
}
|
|
|
|
// AA0108
|
|
public static string ModeHeader()
|
|
{
|
|
return ConfigLoader.betaTest
|
|
? $"🎯 Dev Mode Enabled | Current Set: {OperatorSets.CurrentSet}"
|
|
: $"🚀 Standard Mode Enabled | Current Set: {OperatorSets.CurrentSet}";
|
|
}
|
|
|
|
// AA0109
|
|
public static void AutoClearIfNearBottom()
|
|
{
|
|
try
|
|
{
|
|
int current = Console.CursorTop;
|
|
int limit = Console.WindowHeight - 2;
|
|
|
|
if (current >= limit)
|
|
{
|
|
Console.Clear();
|
|
Console.WriteLine(ModeHeader());
|
|
ShowCapsLockStatus();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
// AA0110
|
|
}
|
|
}
|
|
}
|
|
} |