diff --git a/.gitignore b/.gitignore index 3fdbe1f..80eee32 100644 --- a/.gitignore +++ b/.gitignore @@ -1,30 +1,43 @@ ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # User-specific files *.suo *.user +*.userosscache *.sln.docstates +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + # Build results [Dd]ebug/ [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ x64/ -build/ +x86/ bld/ [Bb]in/ [Oo]bj/ +[Ll]og/ -# Roslyn cache directories -*.ide/ +# Visual Studio 2015/2017 cache/options directory +.vs/ +.vscode/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* -#NUNIT +# NUNIT *.VisualState.xml TestResult.xml @@ -33,14 +46,28 @@ TestResult.xml [Rr]eleasePS/ dlldata.c -*_i.c +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio *_p.c *_i.h *.ilk *.meta *.obj +*.iobj *.pch *.pdb +*.ipdb *.pgc *.pgd *.rsp @@ -65,14 +92,21 @@ _Chutzpah* ipch/ *.aps *.ncb +*.opendb *.opensdf *.sdf *.cachefile +*.VC.db +*.VC.VC.opendb # Visual Studio profiler *.psess *.vsp *.vspx +*.sap + +# Visual Studio Trace Files +*.e2e # TFS 2012 Local Workspace $tf/ @@ -85,7 +119,7 @@ _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user -# JustCode is a .NET coding addin-in +# JustCode is a .NET coding add-in .JustCode # TeamCity is a build add-in @@ -94,9 +128,18 @@ _TeamCity* # DotCover is a Code Coverage Tool *.dotCover +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + # NCrunch _NCrunch_* .*crunch*.local.xml +nCrunchTemp_* # MightyMoose *.mm.* @@ -124,42 +167,67 @@ publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml -## TODO: Comment the next line if you want to checkin your -## web deploy settings but do note that will include unencrypted -## passwords +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted *.pubxml +*.publishproj -# NuGet Packages Directory -packages/* -## TODO: If the tool you use requires repositories.config -## uncomment the next line -#!packages/repositories.config +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ -# Enable "build/" folder in the NuGet Packages folder since -# NuGet packages use it for MSBuild targets. -# This line needs to be after the ignore of the build folder -# (and the packages folder if the line above has been uncommented) -!packages/build/ +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets -# Windows Azure Build Output +# Microsoft Azure Build Output csx/ *.build.csdef -# Windows Store app package directory +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ # Others -sql/ -*.Cache ClientBin/ -[Ss]tyle[Cc]op.* ~$* *~ *.dbmdl *.dbproj.schemaview +*.jfm *.pfx *.publishsettings -node_modules/ +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ # RIA/Silverlight projects Generated_Code/ @@ -171,22 +239,109 @@ _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak # SQL Server files *.mdf *.ldf +*.ndf # Business Intelligence projects *.rdl.data *.bim.layout *.bim_*.settings +*.rptproj.rsuser # Microsoft Fakes FakesAssemblies/ -git_stats/* +# GhostDoc plugin setting file +*.GhostDoc.xml -*.ncrunchproject -StyleCop.Cache -bin -obj \ No newline at end of file +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ +/.dotnet +/.packages +/.tools/vswhere/2.5.2 +/.tools/native/iltools + +### OSX ### + +.DS_Store +.AppleDouble +.LSOverride + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk \ No newline at end of file diff --git a/FakeeDeck.sln b/FakeeDeck.sln new file mode 100644 index 0000000..28dc9b3 --- /dev/null +++ b/FakeeDeck.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35219.272 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FakeeDeck", "FakeeDeck\FakeeDeck.csproj", "{D8C79B08-1920-426A-9138-CF0C8BAE0EF7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D8C79B08-1920-426A-9138-CF0C8BAE0EF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D8C79B08-1920-426A-9138-CF0C8BAE0EF7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D8C79B08-1920-426A-9138-CF0C8BAE0EF7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D8C79B08-1920-426A-9138-CF0C8BAE0EF7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5F518D47-24FD-47F9-B761-01EB60C98440} + EndGlobalSection +EndGlobal diff --git a/FakeeDeck/ButtonType/HelldiversTwoMacro.cs b/FakeeDeck/ButtonType/HelldiversTwoMacro.cs new file mode 100644 index 0000000..082b1de --- /dev/null +++ b/FakeeDeck/ButtonType/HelldiversTwoMacro.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FakeeDeck.ButtonType +{ + class HelldiversTwoMacro + { + public static Dictionary stratogems = new Dictionary + { + { "reinforce", new uint[] { 0x65, 0x68, 0x62, 0x66, 0x64, 0x68}}, + { "resupply", new uint[] { 0x65, 0x62, 0x62, 0x68, 0x66 }}, + { "orbital-precision-strike", new uint[] { 0x65, 0x66, 0x66, 0x66}}, + { "anti-material", new uint[] { 0x65, 0x62, 0x66, 0x64, 0x68, 0x62}}, + { "mortar-sentry", new uint[] { 0x65, 0x62, 0x68, 0x66, 0x62}}, + { "gatling-sentry", new uint[] { 0x65, 0x62, 0x68, 0x66, 0x64}}, + }; + + public static Dictionary stratogemsIcons = new Dictionary + { + { "reinforce", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/5/5a/HD2_Reinforce.png"}, + { "resupply", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/7/72/HD2_Resupply.png"}, + { "orbital-precision-strike", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/4/47/Orbital_Precision_Strike_Icon.png"}, + { "anti-material", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/c/c3/APW-1_Anti-Materiel_Rifle_Icon.png"}, + { "mortar-sentry", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/1/1d/A_M-12_Mortar_Sentry_Icon.png"}, + { "gatling-sentry","https://static.wikia.nocookie.net/helldivers_gamepedia/images/4/48/A_G-16_Gatling_Sentry_Icon.png"}, + }; + } +} diff --git a/FakeeDeck/ButtonType/KeyboardMacro.cs b/FakeeDeck/ButtonType/KeyboardMacro.cs new file mode 100644 index 0000000..4c30873 --- /dev/null +++ b/FakeeDeck/ButtonType/KeyboardMacro.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace FakeeDeck.ButtonType +{ + + internal class KeyboardMacro + { + [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + public static extern void keybd_event(uint bVk, uint bScan, uint dwFlags, uint dwExtraInfo); + + public static void SendKey(uint Key) + { + System.Threading.Thread.Sleep(60); + keybd_event(Key, 0, 0, 0); + System.Threading.Thread.Sleep(60); + keybd_event(Key, 0, 2, 0); + + } + } +} diff --git a/FakeeDeck/FakeeDeck.csproj b/FakeeDeck/FakeeDeck.csproj new file mode 100644 index 0000000..2150e37 --- /dev/null +++ b/FakeeDeck/FakeeDeck.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/FakeeDeck/HttpServer.cs b/FakeeDeck/HttpServer.cs new file mode 100644 index 0000000..a20179f --- /dev/null +++ b/FakeeDeck/HttpServer.cs @@ -0,0 +1,167 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; +using System; +using System.IO; +using System.Text; +using System.Net; +using System.Threading.Tasks; +using FakeeDeck.ButtonType; +using System.Web; +using static System.Net.WebRequestMethods; + +namespace FakeeDeck +{ + internal class HttpServer + { + public static HttpListener listener; + public static string url = "http://*:8000/"; + public static int pageViews = 0; + public static int requestCount = 0; + public static string pageHeader = + "" + + "" + + " " + + " HttpListener Example" + + " " + + " " + + " " + + " " + + " "+ + "
" + + "
" + + "

Page Views: {0}

" + + "
"; + public static string pageFooter = + "
" + + " " + + "
"+ + "
" + + " " + + ""; + public static string pageData = ""; + + + + public static async Task HandleIncomingConnections() + { + bool runServer = true; + + // While a user hasn't visited the `shutdown` url, keep on handling requests + while (runServer) + { + // Will wait here until we hear from a connection + HttpListenerContext ctx = await listener.GetContextAsync(); + + // Peel out the requests and response objects + HttpListenerRequest req = ctx.Request; + HttpListenerResponse resp = ctx.Response; + + // Print out some info about the request + Console.WriteLine("Request #: {0}", ++requestCount); + Console.WriteLine(req.Url.ToString()); + Console.WriteLine(req.HttpMethod); + Console.WriteLine(req.UserHostName); + Console.WriteLine(req.UserAgent); + Console.WriteLine(); + + Dictionary postParams = new Dictionary(); + if(req.HttpMethod == "POST"){ + using (var reader = new StreamReader(req.InputStream, req.ContentEncoding)) + { + string postData = reader.ReadToEnd(); + var parsedData = HttpUtility.ParseQueryString(postData); + foreach (string key in parsedData) + { + postParams[key] = parsedData[key]; + } + } + } + + // If `shutdown` url requested w/ POST, then shutdown the server after serving the page + if ((req.HttpMethod == "POST") && (req.Url.AbsolutePath == "/shutdown")) + { + Console.WriteLine("Shutdown requested"); + runServer = false; + } + + // If `shutdown` url requested w/ POST, then shutdown the server after serving the page + if ((req.HttpMethod == "POST") && (req.Url.AbsolutePath == "/keyboard/stratogem")) + { + + + //new uint[] { 0x65, 0x68, 0x62, 0x66, 0x64, 0x68, 0x0D, 0x0D, } + foreach (var key in HelldiversTwoMacro.stratogems[postParams["stratogem"]]) + { + KeyboardMacro.SendKey(key); + Console.WriteLine(key); + } + resp.Redirect("/"); + } + + // Make sure we don't increment the page views counter if `favicon.ico` is requested + if (req.Url.AbsolutePath != "/favicon.ico") + { + pageViews += 1; + } + + // Write the response info + string disableSubmit = !runServer ? "disabled" : ""; + byte[] data = Encoding.UTF8.GetBytes(String.Format((pageHeader + pageData + pageFooter), pageViews, disableSubmit)); + resp.ContentType = "text/html"; + resp.ContentEncoding = Encoding.UTF8; + resp.ContentLength64 = data.LongLength; + + // Write out to the response stream (asynchronously), then close it + await resp.OutputStream.WriteAsync(data, 0, data.Length); + resp.Close(); + } + } + + + public static void serv() + { + foreach (var stratogem in HelldiversTwoMacro.stratogems) + { + Console.WriteLine(HelldiversTwoMacro.stratogemsIcons[stratogem.Key]); + pageData += + "
" + + "
" + + " " + + " " + + "
" + + "
"; + } + + + // Create a Http server and start listening for incoming connections + listener = new HttpListener(); + listener.Prefixes.Add(url); + listener.Start(); + Console.WriteLine("Listening for connections on {0}", url); + + // Handle requests + Task listenTask = HandleIncomingConnections(); + listenTask.GetAwaiter().GetResult(); + + // Close the listener + listener.Close(); + } + + public static string FirstLetterToUpper(string str) + { + if (str == null) + return null; + + if (str.Length > 1) + return char.ToUpper(str[0]) + str.Substring(1); + + return str.ToUpper(); + } + } +} diff --git a/FakeeDeck/Program.cs b/FakeeDeck/Program.cs new file mode 100644 index 0000000..edb43d6 --- /dev/null +++ b/FakeeDeck/Program.cs @@ -0,0 +1,3 @@ +using FakeeDeck; + +HttpServer.serv(); \ No newline at end of file