diff --git a/Lithium/MainWindow.xaml.cs b/Lithium/MainWindow.xaml.cs index db00b3c..b70cbdb 100644 --- a/Lithium/MainWindow.xaml.cs +++ b/Lithium/MainWindow.xaml.cs @@ -20,6 +20,14 @@ namespace Lithium private bool refreshHeld = false; private bool switchSideHeld = false; + // CapsLock recoil toggle + private bool recoilEnabled = true; + private bool capsHeld = false; + + // NEW: cooldown timestamps + private DateTime nextSetAllowed = DateTime.MinValue; + private DateTime prevSetAllowed = DateTime.MinValue; + public MainWindow() { InitializeComponent(); @@ -48,18 +56,23 @@ namespace Lithium } // ============================================================ - // RECOIL SYSTEM (THIS IS WHAT WAS MISSING) + // RECOIL ENGINE (CapsLock toggle + both mouse buttons required) // ============================================================ private void RecoilLoop() { - const int RIGHT_MOUSE = 0x02; // Right mouse button + const int RIGHT_MOUSE = 0x02; while (true) { - bool leftPressed = Utils.IsPressed(ConfigLoader.shootKey); // 0x01 - bool rightPressed = Utils.IsPressed(RIGHT_MOUSE); // 0x02 + if (!recoilEnabled) + { + Thread.Sleep(1); + continue; + } + + bool leftPressed = Utils.IsPressed(ConfigLoader.shootKey); + bool rightPressed = Utils.IsPressed(RIGHT_MOUSE); - // Only trigger recoil when BOTH are held bool shouldFire = leftPressed && rightPressed; if (shouldFire) @@ -79,40 +92,69 @@ namespace Lithium } } - - - // ============================================================ - // HOTKEY THREAD (debounced) + // HOTKEY THREAD (debounced + cooldowns + CapsLock toggle) // ============================================================ private void HotkeyLoop() { + const int CAPSLOCK = 0x14; + while (true) { - // Next Set + // ------------------------------- + // CAPSLOCK → Toggle recoil + // ------------------------------- + bool capsDown = Utils.IsPressed(CAPSLOCK); + + if (capsDown && !capsHeld) + { + capsHeld = true; + + recoilEnabled = !recoilEnabled; + + AppendConsole(recoilEnabled ? "Recoil Enabled" : "Recoil Disabled"); + } + if (!capsDown) capsHeld = false; + + // ------------------------------- + // NEXT SET (cooldown) + // ------------------------------- bool nextDown = Utils.IsPressed(ConfigLoader.nextSetKey); - if (nextDown && !nextSetHeld) + + if (nextDown && !nextSetHeld && DateTime.Now >= nextSetAllowed) { nextSetHeld = true; + + nextSetAllowed = DateTime.Now.AddMilliseconds(200); + OperatorSets.NextSet(); AppendConsole("Next Set → " + OperatorSets.CurrentSet); Utils.SafeSpeak(OperatorSets.CurrentSet); } if (!nextDown) nextSetHeld = false; - // Previous Set + // ------------------------------- + // PREVIOUS SET (cooldown) + // ------------------------------- bool prevDown = Utils.IsPressed(ConfigLoader.prevSetKey); - if (prevDown && !prevSetHeld) + + if (prevDown && !prevSetHeld && DateTime.Now >= prevSetAllowed) { prevSetHeld = true; + + prevSetAllowed = DateTime.Now.AddMilliseconds(200); + OperatorSets.PreviousSet(); AppendConsole("Previous Set → " + OperatorSets.CurrentSet); Utils.SafeSpeak(OperatorSets.CurrentSet); } if (!prevDown) prevSetHeld = false; - // Reload config + // ------------------------------- + // RELOAD CONFIG + // ------------------------------- bool refreshDown = Utils.IsPressed(ConfigLoader.refreshKey); + if (refreshDown && !refreshHeld) { refreshHeld = true; @@ -121,8 +163,11 @@ namespace Lithium } if (!refreshDown) refreshHeld = false; - // Switch Side + // ------------------------------- + // SWITCH SIDE + // ------------------------------- bool switchDown = Utils.IsPressed(ConfigLoader.switchSideKey); + if (switchDown && !switchSideHeld) { switchSideHeld = true; @@ -136,7 +181,7 @@ namespace Lithium } // ============================================================ - // SAFE UI CONSOLE APPEND + // UI CONSOLE // ============================================================ public void AppendConsole(string msg) {