diff --git a/AsyncInput/.gitignore b/AsyncInput/.gitignore
new file mode 100644
index 0000000..0fcd9d7
--- /dev/null
+++ b/AsyncInput/.gitignore
@@ -0,0 +1,365 @@
+### VisualStudio template
+## 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
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# 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
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+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/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# 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
+
+# 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/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# 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
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+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/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_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
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# 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/
+
+# CodeRush personal settings
+.cr/personal
+
+# 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/
+
+# Local History for Visual Studio
+.localhistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+.idea
\ No newline at end of file
diff --git a/AsyncInput/AsyncInput.sln b/AsyncInput/AsyncInput.sln
new file mode 100644
index 0000000..f071e27
--- /dev/null
+++ b/AsyncInput/AsyncInput.sln
@@ -0,0 +1,40 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AsyncInputTest", "AsyncInputTest\AsyncInputTest.csproj", "{39E19A5F-518C-4935-B304-BFAB5A3E3FF7}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AsyncInput", "AsyncInput\AsyncInput.csproj", "{4F6BA1D4-4812-4721-8BB9-9A9B126D6529}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|x64 = Debug|x64
+ Release|Any CPU = Release|Any CPU
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {39E19A5F-518C-4935-B304-BFAB5A3E3FF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {39E19A5F-518C-4935-B304-BFAB5A3E3FF7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {39E19A5F-518C-4935-B304-BFAB5A3E3FF7}.Debug|Any CPU.ActiveCfg = Debug|x64
+ {39E19A5F-518C-4935-B304-BFAB5A3E3FF7}.Debug|Any CPU.Build.0 = Debug|x64
+ {39E19A5F-518C-4935-B304-BFAB5A3E3FF7}.Debug|x64.ActiveCfg = Debug|x64
+ {39E19A5F-518C-4935-B304-BFAB5A3E3FF7}.Debug|x64.Build.0 = Debug|x64
+ {39E19A5F-518C-4935-B304-BFAB5A3E3FF7}.Release|x64.ActiveCfg = Release|x64
+ {39E19A5F-518C-4935-B304-BFAB5A3E3FF7}.Release|x64.Build.0 = Release|x64
+ {4F6BA1D4-4812-4721-8BB9-9A9B126D6529}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4F6BA1D4-4812-4721-8BB9-9A9B126D6529}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4F6BA1D4-4812-4721-8BB9-9A9B126D6529}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {4F6BA1D4-4812-4721-8BB9-9A9B126D6529}.Debug|x64.Build.0 = Debug|Any CPU
+ {4F6BA1D4-4812-4721-8BB9-9A9B126D6529}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4F6BA1D4-4812-4721-8BB9-9A9B126D6529}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4F6BA1D4-4812-4721-8BB9-9A9B126D6529}.Release|x64.ActiveCfg = Release|Any CPU
+ {4F6BA1D4-4812-4721-8BB9-9A9B126D6529}.Release|x64.Build.0 = Release|Any CPU
+ {778F0001-72A8-476E-B3BD-006F849843A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {778F0001-72A8-476E-B3BD-006F849843A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {778F0001-72A8-476E-B3BD-006F849843A1}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {778F0001-72A8-476E-B3BD-006F849843A1}.Debug|x64.Build.0 = Debug|Any CPU
+ {778F0001-72A8-476E-B3BD-006F849843A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {778F0001-72A8-476E-B3BD-006F849843A1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {778F0001-72A8-476E-B3BD-006F849843A1}.Release|x64.ActiveCfg = Release|Any CPU
+ {778F0001-72A8-476E-B3BD-006F849843A1}.Release|x64.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/AsyncInput/AsyncInput/AsyncInput.csproj b/AsyncInput/AsyncInput/AsyncInput.csproj
new file mode 100644
index 0000000..a321a1a
--- /dev/null
+++ b/AsyncInput/AsyncInput/AsyncInput.csproj
@@ -0,0 +1,420 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {4F6BA1D4-4812-4721-8BB9-9A9B126D6529}
+ Library
+ Properties
+ ADOFAIAsyncInput
+ AsyncInput
+ v4.8
+ 512
+ latest
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityModManager\0Harmony.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Accessibility.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Assembly-CSharp.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Assembly-CSharp-firstpass.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\com.rlabrecque.steamworks.net.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\DemiLib.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\DotNetZip.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\DOTween.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\DOTweenPro.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\I18N.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\I18N.CJK.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\I18N.MidEast.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\I18N.Other.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\I18N.Rare.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\I18N.West.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Mono.Data.Sqlite.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Mono.Posix.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Mono.Security.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Mono.WebBrowser.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\mscorlib.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Novell.Directory.Ldap.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Ookii.Dialogs.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\RDTools.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Rewired_Core.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Rewired_Windows.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Rewired_Windows_Functions.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\SharpHook.dll
+
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\System.ComponentModel.DataAnnotations.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\System.Configuration.dll
+
+
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\System.Design.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\System.DirectoryServices.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\System.Drawing.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\System.Drawing.Design.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\System.EnterpriseServices.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\System.Numerics.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\System.Runtime.Serialization.Formatters.Soap.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\System.Security.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\System.Transactions.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\System.Web.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\System.Web.ApplicationServices.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\System.Web.Services.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\System.Windows.Forms.dll
+
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Unity.Addressables.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Unity.MemoryProfiler.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Unity.ResourceManager.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Unity.ScriptableBuildPipeline.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Unity.TextMeshPro.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\Unity.Timeline.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.AccessibilityModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.AIModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.AndroidJNIModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.AnimationModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.ARModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.AssetBundleModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.AudioModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.ClothModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.ClusterInputModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.ClusterRendererModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.CoreModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.CrashReportingModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.DirectorModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.DSPGraphModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.GameCenterModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.GIModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.GridModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.HotReloadModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.ImageConversionModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.IMGUIModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.InputLegacyModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.InputModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.JSONSerializeModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.LocalizationModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.NVIDIAModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.ParticleSystemModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.PerformanceReportingModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.Physics2DModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.PhysicsModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.ProfilerModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.ScreenCaptureModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.SharedInternalsModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.SpriteMaskModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.SpriteShapeModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.StreamingModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.SubstanceModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.SubsystemsModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.TerrainModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.TerrainPhysicsModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.TextCoreFontEngineModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.TextCoreTextEngineModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.TextRenderingModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.TilemapModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.TLSModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.UI.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.UIElementsModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.UIElementsNativeModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.UIModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.UmbraModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.UNETModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.UnityAnalyticsModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.UnityConnectModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.UnityCurlModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.UnityTestProtocolModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.UnityWebRequestAssetBundleModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.UnityWebRequestAudioModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.UnityWebRequestModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.UnityWebRequestTextureModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.UnityWebRequestWWWModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.VehiclesModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.VFXModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.VideoModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.VirtualTexturingModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.VRModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.WindModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityEngine.XRModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\UnityModManager\UnityModManager.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\A Dance of Fire and Ice_Data\Managed\XTUtilities.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ C:\Program Files (x86)\Steam\steamapps\common\A Dance of Fire and Ice\Mods\AsyncInput
+
+
+
+
+
+
+
diff --git a/AsyncInput/AsyncInput/AsyncInputMod.cs b/AsyncInput/AsyncInput/AsyncInputMod.cs
new file mode 100644
index 0000000..9ecc644
--- /dev/null
+++ b/AsyncInput/AsyncInput/AsyncInputMod.cs
@@ -0,0 +1,44 @@
+using System.Reflection;
+using HarmonyLib;
+using UnityModManagerNet;
+
+namespace ADOFAIAsyncInput
+{
+ internal static class AsyncInputMod
+ {
+ private static Harmony _harmony;
+
+ internal static UnityModManager.ModEntry Entry;
+
+ private static void Load(UnityModManager.ModEntry entry)
+ {
+ Entry = entry;
+
+ _harmony = new Harmony(entry.Info.Id);
+
+ entry.OnToggle = (_, b) =>
+ {
+ if (b)
+ {
+ _harmony.PatchAll(Assembly.GetExecutingAssembly());
+
+ if (Persistence.GetChosenAsynchronousInput())
+ {
+ Patches.StartThread();
+ Entry.Logger.Log("Started Hook");
+ RDInput.OnAsyncInputToggle(true);
+ }
+ }
+ else
+ {
+ Patches.Thread.Abort();
+ Entry.Logger.Log("Stopped Hook");
+ Patches.Thread = null;
+
+ _harmony.UnpatchAll(_harmony.Id);
+ }
+ return true;
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/AsyncInput/AsyncInput/AsyncInputNative.cs b/AsyncInput/AsyncInput/AsyncInputNative.cs
new file mode 100644
index 0000000..5be6b57
--- /dev/null
+++ b/AsyncInput/AsyncInput/AsyncInputNative.cs
@@ -0,0 +1,50 @@
+using System.IO;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace ADOFAIAsyncInput
+{
+ public class AsyncInputNative
+ {
+ [StructLayout(LayoutKind.Sequential)]
+ public struct CallbackData
+ {
+ public EventType event_type;
+ public int key;
+ }
+
+ public enum EventType
+ {
+ Press,
+ Release,
+ }
+
+ public delegate void Callback(
+ CallbackData data);
+
+ public static void Copy()
+ {
+ }
+
+ [ModuleInitializer]
+ internal static void LoadLib()
+ {
+ // var executingAssembly = Assembly.GetExecutingAssembly();
+ //
+ // using var stream = executingAssembly.GetManifestResourceStream("ADOFAIAsyncInput.natives.asyncinput.dll")!;
+ //
+ // byte[] numArray = new byte[stream.Length];
+ // _ = stream.Read(numArray, 0, numArray.Length);
+ // File.WriteAllBytes("asyncinput.dll", numArray);
+ }
+
+ private const string Lib = "Mods\\AsyncInput\\natives\\asyncinput";
+
+ [DllImport(Lib, EntryPoint = "run", CallingConvention = CallingConvention.Cdecl)]
+ public static extern void RunHook(Callback callback);
+
+ [DllImport(Lib, EntryPoint = "stop", CallingConvention = CallingConvention.Cdecl)]
+ public static extern void Stop();
+ }
+}
\ No newline at end of file
diff --git a/AsyncInput/AsyncInput/Info.json b/AsyncInput/AsyncInput/Info.json
new file mode 100644
index 0000000..fec133f
--- /dev/null
+++ b/AsyncInput/AsyncInput/Info.json
@@ -0,0 +1,7 @@
+{
+ "Id": "AsyncInput",
+ "DisplayName": "ADOFAI Async Input",
+ "Version": "0.0.1",
+ "AssemblyName": "AsyncInput.dll",
+ "EntryMethod": "ADOFAIAsyncInput.AsyncInputMod.Load"
+}
\ No newline at end of file
diff --git a/AsyncInput/AsyncInput/Patches.cs b/AsyncInput/AsyncInput/Patches.cs
new file mode 100644
index 0000000..a553435
--- /dev/null
+++ b/AsyncInput/AsyncInput/Patches.cs
@@ -0,0 +1,176 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Reflection;
+using System.Threading;
+using HarmonyLib;
+using RDTools;
+using SharpHook;
+using UnityEngine;
+
+// ReSharper disable UnusedType.Local
+
+namespace ADOFAIAsyncInput
+{
+ internal static class Patches
+ {
+ public static Thread Thread;
+
+ private static FieldInfo _hookField = AccessTools.Field(typeof(AsyncInputManager), "hook");
+
+ internal static void StartThread()
+ {
+ if (Thread != null)
+ {
+ return;
+ }
+
+ Thread = new Thread(() =>
+ {
+ try
+ {
+ AsyncInputNative.RunHook(data =>
+ {
+ var keyCode = (ushort)data.key;
+
+ switch (data.event_type)
+ {
+ case AsyncInputNative.EventType.Press:
+ AsyncInputManager.keyQueue.Enqueue(new KeyEvent(DateTime.Now.Ticks, keyCode, true));
+ break;
+ case AsyncInputNative.EventType.Release:
+ AsyncInputManager.keyQueue.Enqueue(new KeyEvent(DateTime.Now.Ticks, keyCode, false));
+ break;
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ AsyncInputMod.Entry.Logger.Error($"{e}");
+ throw;
+ }
+ });
+
+ Thread.Start();
+ }
+
+ [HarmonyPatch(typeof(scrController), "UpdateInput")]
+ private static class ControllerUpdateInput
+ {
+ private static MethodBase ProcessKeyInputs = AccessTools.Method(typeof(scrController), "ProcessKeyInputs");
+
+ private static bool Prefix(scrController __instance, ref bool ___validKeyWasReleased)
+ {
+ var controller = __instance;
+
+ ___validKeyWasReleased = false;
+
+ AsyncInputManager.keyDownMask.Clear();
+ AsyncInputManager.keyUpMask.Clear();
+ AsyncInputManager.frameDependentKeyDownMask.Clear();
+ AsyncInputManager.frameDependentKeyUpMask.Clear();
+
+ long tick = 0L;
+
+ while (AsyncInputManager.keyQueue.TryDequeue(out var result))
+ {
+ ProcessKeyInputs.Invoke(controller, new object[]
+ {
+ new List
+ {
+ (KeyCode)result.keyCode
+ },
+ result.tick
+ });
+ AsyncInputManager.keyDownMask.Clear();
+ AsyncInputManager.keyUpMask.Clear();
+
+ tick = result.tick;
+ }
+
+ ProcessKeyInputs.Invoke(controller, new object[]
+ {
+ new List(),
+ tick
+ });
+
+ return false;
+ }
+ }
+
+#if DEBUG
+ [HarmonyPatch(typeof(RDBaseDll), "printem")]
+ private static class RdBaseDllPrint
+ {
+ private static bool Prefix(object o)
+ {
+ MethodBase method = new StackTrace().GetFrame(2).GetMethod();
+ if (method.DeclaringType != null)
+ AsyncInputMod.Entry.Logger.Log(
+ $"{(object)method.DeclaringType.Name}.{(object)method.Name}() -> {o}");
+ return false;
+ }
+ }
+#endif
+
+ [HarmonyPatch(typeof(AsyncInputManager), "isActive", MethodType.Getter)]
+ private static class AsyncInputManagerIsActive
+ {
+ private static bool Prefix(ref bool __result)
+ {
+ __result = Thread != null;
+
+ return false;
+ }
+ }
+
+ [HarmonyPatch(typeof(AsyncInputManager), "ToggleHook")]
+ private static class AsyncInputManagerToggleHook
+ {
+ private static bool Prefix(bool active)
+ {
+ IGlobalHook hook = (IGlobalHook)_hookField.GetValue(null);
+
+ if (hook != null)
+ {
+ AsyncInputMod.Entry.Logger.Log("Stopping running hook");
+ hook.Dispose();
+ Thread hookThread = AsyncInputManager.hookThread;
+ if ((hookThread != null ? (hookThread.IsAlive ? 1 : 0) : 0) != 0)
+ AsyncInputManager.hookThread.Abort();
+ }
+
+ if (active)
+ {
+ AsyncInputManager.keyMask.Clear();
+ AsyncInputManager.keyQueue.Clear();
+ AsyncInputManager.keyDownMask.Clear();
+ AsyncInputManager.keyUpMask.Clear();
+ long num;
+ AsyncInputManager.offsetTick = num = 0L;
+ AsyncInputManager.prevFrameTick = num;
+ AsyncInputManager.targetSongTick = num;
+ AsyncInputManager.currFrameTick = num;
+ AsyncInputManager.offsetTickUpdated = false;
+ AsyncInputManager.dspTime = AsyncInputManager.dspTimeSong = 0.0;
+ AsyncInputManager.lastReportedDspTime = AsyncInputManager.previousFrameTime = 0.0;
+
+ StartThread();
+ AsyncInputMod.Entry.Logger.Log("Started Hook");
+ RDInput.OnAsyncInputToggle(true);
+ }
+ else
+ {
+ if (Thread == null) return false;
+ // AsyncInputNative.Stop();
+ Thread.Abort();
+ AsyncInputMod.Entry.Logger.Log("Stopped Hook");
+ Thread = null;
+ RDInput.OnAsyncInputToggle(false);
+ }
+
+ return false;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/AsyncInput/AsyncInput/Properties/AssemblyInfo.cs b/AsyncInput/AsyncInput/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..1e6fe1c
--- /dev/null
+++ b/AsyncInput/AsyncInput/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("AsyncInput")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("AsyncInput")]
+[assembly: AssemblyCopyright("Copyright © 2022")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("4F6BA1D4-4812-4721-8BB9-9A9B126D6529")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/AsyncInput/AsyncInputTest/AsyncInputTest.csproj b/AsyncInput/AsyncInputTest/AsyncInputTest.csproj
new file mode 100644
index 0000000..31641cb
--- /dev/null
+++ b/AsyncInput/AsyncInputTest/AsyncInputTest.csproj
@@ -0,0 +1,74 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {39E19A5F-518C-4935-B304-BFAB5A3E3FF7}
+ Exe
+ Properties
+ AsyncInputTest
+ AsyncInputTest
+ v4.8
+ 512
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ bin\x64\Debug\
+ x64
+
+
+ bin\x64\Release\
+ x64
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AsyncInput/AsyncInputTest/Program.cs b/AsyncInput/AsyncInputTest/Program.cs
new file mode 100644
index 0000000..f03c139
--- /dev/null
+++ b/AsyncInput/AsyncInputTest/Program.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Threading;
+
+namespace AsyncInputTest
+{
+ internal static class Program
+ {
+ [StructLayout(LayoutKind.Sequential)]
+ private struct CallbackData
+ {
+ public EventType event_type;
+ public int key;
+ }
+
+ private enum EventType
+ {
+ Press,
+ Release,
+ }
+
+ private delegate void Callback(
+ CallbackData data);
+
+ [DllImport("natives/asyncinput", EntryPoint = "run", CallingConvention = CallingConvention.Cdecl)]
+ private static extern void RunHook(Callback callback);
+
+ [DllImport("natives/asyncinput", EntryPoint = "stop", CallingConvention = CallingConvention.Cdecl)]
+ private static extern void Stop();
+
+ public static void Main()
+ {
+ var thread = new Thread(() =>
+ {
+ RunHook((v) => { Console.WriteLine($"{v.event_type} {v.key}"); });
+ });
+
+ thread.Start();
+
+ Console.WriteLine("Started!");
+
+ Thread.Sleep(TimeSpan.FromDays(1));
+ }
+ }
+}
\ No newline at end of file
diff --git a/AsyncInput/AsyncInputTest/Properties/AssemblyInfo.cs b/AsyncInput/AsyncInputTest/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..5235ab2
--- /dev/null
+++ b/AsyncInput/AsyncInputTest/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("AsyncInputTest")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("AsyncInputTest")]
+[assembly: AssemblyCopyright("Copyright © 2022")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("39E19A5F-518C-4935-B304-BFAB5A3E3FF7")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
\ No newline at end of file
diff --git a/AsyncInput/natives/asyncinput.dll b/AsyncInput/natives/asyncinput.dll
new file mode 100644
index 0000000..5b93f5b
Binary files /dev/null and b/AsyncInput/natives/asyncinput.dll differ
diff --git a/native/.gitignore b/native/.gitignore
new file mode 100644
index 0000000..2ebc5ea
--- /dev/null
+++ b/native/.gitignore
@@ -0,0 +1,2 @@
+/target
+/Cargo.lock
\ No newline at end of file
diff --git a/native/Cargo.toml b/native/Cargo.toml
new file mode 100644
index 0000000..31c9f17
--- /dev/null
+++ b/native/Cargo.toml
@@ -0,0 +1,12 @@
+[package]
+name = "asyncinput"
+version = "0.1.0"
+edition = "2021"
+
+[lib]
+crate-type = ["dylib"]
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+winapi = { version = "0.3.9", features = ["minwindef", "winuser", "windef"] }
diff --git a/native/asdf.http b/native/asdf.http
new file mode 100644
index 0000000..eac0674
--- /dev/null
+++ b/native/asdf.http
@@ -0,0 +1,4 @@
+POST https://discord.com/api/webhooks/875706402071531520/bIriv3jmiQLj3k6sEfyrgfFbcWssCg6yt9m9CR8W7ykDwEyZ-gUNSjhGZD0lM5rycslu
+Content-Type: application/json
+
+{"content": "sans"}
\ No newline at end of file
diff --git a/native/src/lib.rs b/native/src/lib.rs
new file mode 100644
index 0000000..0325142
--- /dev/null
+++ b/native/src/lib.rs
@@ -0,0 +1,45 @@
+#[repr(C)]
+pub enum EventType {
+ Press,
+ Release,
+}
+
+#[repr(C)]
+pub struct Event {
+ event_type: EventType,
+ key: i32,
+}
+
+static mut SHOULD_BREAK: bool = false;
+
+static mut GLOBAL_HOOK: Option = None;
+
+static mut STARTED: bool = false;
+
+mod windows;
+
+#[no_mangle]
+pub extern "C" fn run(callback: extern "C" fn(Event)) {
+ unsafe {
+ GLOBAL_HOOK = Some(callback);
+ }
+
+ if unsafe { STARTED } {
+ return;
+ }
+
+ unsafe {
+ STARTED = true;
+ }
+
+ std::thread::spawn(|| {
+ windows::install_hooks();
+ windows::process_message();
+ });
+}
+
+pub extern "C" fn stop() {
+ unsafe {
+ SHOULD_BREAK = true;
+ }
+}
diff --git a/native/src/windows.rs b/native/src/windows.rs
new file mode 100644
index 0000000..6628af6
--- /dev/null
+++ b/native/src/windows.rs
@@ -0,0 +1,138 @@
+use std::ffi::c_int;
+use std::mem::MaybeUninit;
+use std::ptr::null_mut;
+use winapi::shared::minwindef::{HINSTANCE, LPARAM, LRESULT, WPARAM};
+use winapi::shared::windef::HHOOK__;
+use winapi::um::winuser::{
+ CallNextHookEx, GetMessageW, SetWindowsHookExW, KBDLLHOOKSTRUCT, MSG, WH_KEYBOARD_LL,
+ WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, WM_SYSKEYUP,
+};
+
+use crate::GLOBAL_HOOK;
+
+pub(crate) fn install_hooks() {
+ install_hook(WH_KEYBOARD_LL, keybd_hook);
+ // install_hook(WH_MOUSE_LL, mouse_hook);
+}
+
+pub(crate) fn process_message() {
+ let mut msg: MSG = unsafe { MaybeUninit::zeroed().assume_init() };
+ unsafe { GetMessageW(&mut msg, null_mut(), 0, 0) };
+}
+
+fn install_hook(
+ hook_id: c_int,
+ hook_proc: unsafe extern "system" fn(c_int, WPARAM, LPARAM) -> LRESULT,
+) -> *mut HHOOK__ {
+ unsafe { SetWindowsHookExW(hook_id, Some(hook_proc), 0 as HINSTANCE, 0) }
+}
+
+unsafe extern "system" fn keybd_hook(code: c_int, w_param: WPARAM, l_param: LPARAM) -> LRESULT {
+ let vk: i32 = (*(l_param as *const KBDLLHOOKSTRUCT))
+ .vkCode
+ .try_into()
+ .expect("vkCode does not fit in i32");
+
+ match w_param as u32 {
+ code if code == WM_KEYDOWN || code == WM_SYSKEYDOWN => {
+ if let Some(f) = GLOBAL_HOOK {
+ f(crate::Event {
+ event_type: crate::EventType::Press,
+ key: vk,
+ })
+ }
+ }
+ code if code == WM_KEYUP || code == WM_SYSKEYUP => {
+ if let Some(f) = GLOBAL_HOOK {
+ f(crate::Event {
+ event_type: crate::EventType::Release,
+ key: vk,
+ })
+ }
+ }
+ _ => {}
+ }
+
+ CallNextHookEx(null_mut(), code, w_param, l_param)
+}
+
+// unsafe extern "system" fn mouse_hook(code: c_int, w_param: WPARAM, l_param: LPARAM) -> LRESULT {
+// // because macros > idea
+// // typedef struct tagMSLLHOOKSTRUCT {
+// // POINT pt;
+// // DWORD mouseData;
+// // DWORD flags;
+// // DWORD time;
+// // ULONG_PTR dwExtraInfo;
+// // } MSLLHOOKSTRUCT, *LPMSLLHOOKSTRUCT, *PMSLLHOOKSTRUCT;
+
+// let data = &*(l_param as *const MSLLHOOKSTRUCT);
+// let x_button_param: u16 =
+// GET_XBUTTON_WPARAM(data.mouseData.try_into().expect("u32 fits usize"));
+// let maybe_x_button = if x_button_param == XBUTTON1 {
+// Some(Mouse::Side)
+// } else if x_button_param == XBUTTON2 {
+// Some(Mouse::Extra)
+// } else {
+// None
+// };
+// let w_param_u32: u32 = w_param.try_into().expect("w_param > u32");
+// registry().update_mouse_position(data.pt.x, data.pt.y);
+// let inhibit = match w_param_u32 {
+// code if code == WM_LBUTTONDOWN => registry().event_down(Event::Mouse(Mouse::Left)),
+// code if code == WM_LBUTTONDBLCLK => registry().event_click(Event::Mouse(Mouse::DoubleLeft)),
+// code if code == WM_RBUTTONDOWN => registry().event_down(Event::Mouse(Mouse::Right)),
+// code if code == WM_RBUTTONDBLCLK => {
+// registry().event_click(Event::Mouse(Mouse::DoubleRight))
+// }
+// code if code == WM_MBUTTONDOWN => registry().event_down(Event::Mouse(Mouse::Middle)),
+// code if code == WM_MBUTTONDBLCLK => {
+// registry().event_down(Event::Mouse(Mouse::DoubleMiddle))
+// }
+// code if code == WM_XBUTTONDOWN => {
+// if let Some(x_button) = maybe_x_button {
+// registry().event_down(Event::Mouse(x_button))
+// } else {
+// InhibitEvent::No
+// }
+// }
+// code if code == WM_XBUTTONDBLCLK => {
+// if let Some(x_button) = maybe_x_button {
+// // TODO: figure out the other XButtons.
+// if Mouse::Side == x_button {
+// registry().event_click(Event::Mouse(Mouse::DoubleSide))
+// } else {
+// registry().event_click(Event::Mouse(Mouse::DoubleExtra))
+// }
+// } else {
+// InhibitEvent::No
+// }
+// }
+// code if code == WM_LBUTTONUP => registry().event_up(Event::Mouse(Mouse::Left)),
+// code if code == WM_LBUTTONUP => registry().event_up(Event::Mouse(Mouse::Left)),
+// code if code == WM_RBUTTONUP => registry().event_up(Event::Mouse(Mouse::Right)),
+// code if code == WM_RBUTTONUP => registry().event_up(Event::Mouse(Mouse::Right)),
+// code if code == WM_MBUTTONUP => registry().event_up(Event::Mouse(Mouse::Middle)),
+// code if code == WM_MBUTTONUP => registry().event_up(Event::Mouse(Mouse::Middle)),
+// code if code == WM_XBUTTONUP => {
+// if let Some(x_button) = maybe_x_button {
+// registry().event_up(Event::Mouse(x_button))
+// } else {
+// InhibitEvent::No
+// }
+// }
+// code if code == WM_XBUTTONUP => {
+// if let Some(x_button) = maybe_x_button {
+// registry().event_up(Event::Mouse(x_button))
+// } else {
+// InhibitEvent::No
+// }
+// }
+// _ => InhibitEvent::No,
+// };
+// if inhibit.should_inhibit() {
+// 1
+// } else {
+// CallNextHookEx(null_mut(), code, w_param, l_param)
+// }
+// }