Wait for packet echoes and send only changed packets
The keyboard echoes each colour packet back; wait for that echo before sending the next one, like OpenRGB's EVision driver, instead of firing all packets back to back. Skip packets whose colours did not change and resend the whole frame every 500 ms so the keyboard stays under plugin control. Add a passive listener tool for the echoes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
822787ae0f
commit
0b2a90ba94
3 files changed
+68
No files matched your search
@@ -0,0 +1,35 @@
|
||||
# Passively reads input reports from the EVision RGB endpoint for a few seconds
|
||||
param([double]$Seconds = 2, [string]$Match = 'VID_320F&PID_502A&MI_01&COL04')
|
||||
Add-Type @"
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
public static class EVL {
|
||||
[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)]
|
||||
public static extern SafeFileHandle CreateFile(string n, uint a, uint s, IntPtr sa, uint c, uint f, IntPtr t);
|
||||
public static string Listen(string path, int ms) {
|
||||
var h = CreateFile(path, 0x80000000, 3, IntPtr.Zero, 3, 0x40000000, IntPtr.Zero);
|
||||
if (h.IsInvalid) return "open failed " + Marshal.GetLastWin32Error();
|
||||
var sb = new System.Text.StringBuilder();
|
||||
var counts = new System.Collections.Generic.Dictionary<string,int>();
|
||||
using (var fs = new FileStream(h, FileAccess.Read, 64, true)) {
|
||||
var end = DateTime.Now.AddMilliseconds(ms); int n = 0;
|
||||
while (DateTime.Now < end) {
|
||||
var buf = new byte[64];
|
||||
var t = fs.ReadAsync(buf, 0, 64);
|
||||
if (!t.Wait(end - DateTime.Now > TimeSpan.Zero ? end - DateTime.Now : TimeSpan.Zero)) break;
|
||||
n++;
|
||||
var key = BitConverter.ToString(buf, 0, 8);
|
||||
counts[key] = counts.ContainsKey(key) ? counts[key] + 1 : 1;
|
||||
}
|
||||
sb.AppendLine("reports: " + n);
|
||||
foreach (var kv in counts) sb.AppendLine(kv.Value + "x " + kv.Key);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
"@
|
||||
$dev = Get-PnpDevice -PresentOnly -Class HIDClass | Where-Object { $_.InstanceId -match [regex]::Escape($Match) } | Select-Object -First 1
|
||||
$path = '\\?\' + ($dev.InstanceId -replace '\\','#') + '#{4d1e55b2-f16f-11cf-88cb-001111000030}'
|
||||
[EVL]::Listen($path, [int]($Seconds * 1000))
|
||||
Reference in new issue
Block a user