From ab438856ad450272df1b91fff68a7dd3c9138d4b Mon Sep 17 00:00:00 2001 From: JJ Date: Mon, 24 Nov 2025 00:04:52 -0500 Subject: [PATCH] Update 0.01 D --- Lithium/HotkeyHandler.cs | 80 +++++++++ Lithium/Lithium.csproj | 3 +- Lithium/MainWindow.xaml | 173 +++++++++++++++++- Lithium/MainWindow.xaml.cs | 358 +++++++++++++++++++++++++------------ Lithium/RecoilEngine.cs | 104 +++++++++++ Lithium/Utils.cs | 12 +- 6 files changed, 593 insertions(+), 137 deletions(-) create mode 100644 Lithium/HotkeyHandler.cs create mode 100644 Lithium/RecoilEngine.cs diff --git a/Lithium/HotkeyHandler.cs b/Lithium/HotkeyHandler.cs new file mode 100644 index 0000000..b19be17 --- /dev/null +++ b/Lithium/HotkeyHandler.cs @@ -0,0 +1,80 @@ +using Lua; +using System; +using System.Threading; + +namespace Lithium +{ + internal static class HotkeyHandler + { + private const int CAPSLOCK = 0x14; + + private static bool nextSetHeld, prevSetHeld, refreshHeld, switchSideHeld, capsHeld; + private static MainWindow mainWindow; + + public static void Start(MainWindow window) + { + mainWindow = window; + + while (true) + { + HandleToggleCapsLock(); + HandleNextSet(); + HandlePrevSet(); + HandleRefresh(); + HandleSwitchSide(); + Thread.Sleep(8); + } + } + + private static void HandleToggleCapsLock() + { + bool capsDown = Utils.IsPressed(CAPSLOCK); + if (capsDown && !capsHeld) + { + capsHeld = true; + mainWindow.SetRecoilEnabled(!mainWindow.IsRecoilEnabled); + } + if (!capsDown) capsHeld = false; + } + + private static void HandleNextSet() + { + if (Utils.IsPressed(ConfigLoader.nextSetKey) && !nextSetHeld) + { + nextSetHeld = true; + mainWindow.HandleNextSet(); + } + else if (!Utils.IsPressed(ConfigLoader.nextSetKey)) nextSetHeld = false; + } + + private static void HandlePrevSet() + { + if (Utils.IsPressed(ConfigLoader.prevSetKey) && !prevSetHeld) + { + prevSetHeld = true; + mainWindow.HandlePrevSet(); + } + else if (!Utils.IsPressed(ConfigLoader.prevSetKey)) prevSetHeld = false; + } + + private static void HandleRefresh() + { + if (Utils.IsPressed(ConfigLoader.refreshKey) && !refreshHeld) + { + refreshHeld = true; + mainWindow.HandleRefresh(); + } + else if (!Utils.IsPressed(ConfigLoader.refreshKey)) refreshHeld = false; + } + + private static void HandleSwitchSide() + { + if (Utils.IsPressed(ConfigLoader.switchSideKey) && !switchSideHeld) + { + switchSideHeld = true; + mainWindow.HandleSwitchSide(); + } + else if (!Utils.IsPressed(ConfigLoader.switchSideKey)) switchSideHeld = false; + } + } +} \ No newline at end of file diff --git a/Lithium/Lithium.csproj b/Lithium/Lithium.csproj index 16400eb..37434ce 100644 --- a/Lithium/Lithium.csproj +++ b/Lithium/Lithium.csproj @@ -113,7 +113,9 @@ MSBuild:Compile Designer + + MSBuild:Compile @@ -149,7 +151,6 @@ ResXFileCodeGenerator Resources.Designer.cs - SettingsSingleFileGenerator diff --git a/Lithium/MainWindow.xaml b/Lithium/MainWindow.xaml index 213e22f..a6a334b 100644 --- a/Lithium/MainWindow.xaml +++ b/Lithium/MainWindow.xaml @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wv="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf" - Title="Lithium" Height="570" Width="900" + Title="Lithium" Height="650" Width="1000" Background="#1E1E1E" WindowStyle="None" AllowsTransparency="True"> @@ -110,6 +110,8 @@ + + @@ -130,34 +132,187 @@ - + - + - + - - + + -