diff options
| author | JJ Liebig <jonathan.liebig@gmail.com> | 2026-09-23 14:26:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-23 14:26:17 +0200 |
| commit | 9903007e5c4407ded451cac0b8164e3d69deb891 (patch) | |
| tree | 25d0a79e4fed9237e26076d36e5d36f1b49421fc /scripts/windows_input | |
| parent | 23479dd162caba32379d405b8c8107ff2ae8dbaf (diff) | |
test(windows): capture native console input records (#4520)
refs #4470
Diffstat (limited to 'scripts/windows_input')
| -rw-r--r-- | scripts/windows_input/Native.cs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/windows_input/Native.cs b/scripts/windows_input/Native.cs index 42b387b1..76cb8af7 100644 --- a/scripts/windows_input/Native.cs +++ b/scripts/windows_input/Native.cs @@ -389,7 +389,7 @@ namespace HerdrInputGauntlet { [DllImport("kernel32.dll")] static extern bool SetConsoleCP(uint cp); [DllImport("kernel32.dll")] static extern bool ReadFile(IntPtr handle,byte[] buffer,uint size,out uint count,IntPtr overlap); [DllImport("kernel32.dll")] static extern bool WriteFile(IntPtr handle,byte[] buffer,uint size,out uint count,IntPtr overlap); - [DllImport("kernel32.dll")] static extern bool ReadConsoleInputW(IntPtr handle,Record[] records,uint size,out uint count); + [DllImport("kernel32.dll")] static extern bool ReadConsoleInputW(IntPtr handle,[Out] Record[] records,uint size,out uint count); [DllImport("kernel32.dll")] static extern uint GetCurrentThreadId(); [DllImport("kernel32.dll")] static extern IntPtr OpenThread(uint access,bool inherit,uint id); [DllImport("kernel32.dll")] static extern bool CancelSynchronousIo(IntPtr thread); @@ -459,7 +459,11 @@ namespace HerdrInputGauntlet { public void Clear() { lock(gate) { bytes.Clear(); records.Clear(); } } public bool ClearIfCount(int expected) { lock(gate) { - if(bytes.Count+records.Count!=expected) return false; + if(bytes.Count+records.Count!=expected) { + if(!native || bytes.Count!=0 || records.Count<expected) return false; + for(int i=expected;i<records.Count;i++) + if(records[i][0]!=4 && records[i][0]!=16) return false; // resize/focus between captures + } bytes.Clear(); records.Clear(); return true; } } |
