# Read-only: list the HID++ 2.0 features of the device in slot $Slot behind receiver $Rcv. param([string]$Rcv = 'c545', [byte]$Slot = 1) Add-Type -Path (Join-Path $PSScriptRoot 'Hidpp.cs') $rx = New-Object HidppReceiver (, [HidppReceiver]::Find("vid_046d&pid_$Rcv")) function Call([byte]$idx, [byte]$fn, [byte[]]$params) { while ($rx.Next(0)) {} $req = New-Object byte[] 7; $req[0] = 0x10; $req[1] = $Slot; $req[2] = $idx; $req[3] = ($fn -shl 4) -bor 0x0A for ($i = 0; $i -lt $params.Length -and $i -lt 3; $i++) { $req[4 + $i] = $params[$i] } $rx.Send($req) $deadline = (Get-Date).AddSeconds(2) while ((Get-Date) -lt $deadline) { $r = $rx.Next(200) if ($r -and $r[1] -eq $Slot -and ($r[2] -eq $idx -and $r[3] -eq $req[3])) { return ,$r } if ($r -and $r[1] -eq $Slot -and $r[2] -eq 0xFF) { return ,$r } # HID++ 2.0 error } return $null } $names = @{ 0x0000='Root'; 0x0001='FeatureSet'; 0x0003='DeviceFwVersion'; 0x0005='DeviceName'; 0x0007='DeviceFriendlyName'; 0x0020='ConfigChange'; 0x1000='BatteryStatus'; 0x1001='BatteryVoltage'; 0x1004='UnifiedBattery'; 0x1814='ChangeHost'; 0x1815='HostsInfo'; 0x1982='Backlight2'; 0x1983='Backlight3'; 0x1B04='ReprogControlsV4'; 0x1D4B='WirelessDeviceStatus'; 0x4100='Encryption'; 0x4522='DisableKeysByUsage'; 0x4530='DualPlatform'; 0x40A3='FnInversion'; 0x8010='GKey'; 0x8020='MKeys'; 0x8030='MR'; 0x8040='BrightnessControl'; 0x8060='ReportRate'; 0x8070='ColorLedEffects'; 0x8071='RgbEffects'; 0x8080='PerKeyLighting'; 0x8081='PerKeyLightingV2'; 0x8100='OnboardProfiles'; 0x8110='MouseButtonSpy'; 0x00C2='DFUControl'; 0x00D0='DFU'; 0x1802='DeviceReset'; 0x1803='GpioAccess'; 0x1806='ConfigurableDeviceProperties'; 0x1890='RfTest'; 0x18A1='LedTest'; 0x1801='Manufacturing'; 0x1805='OOBState' } try { $fs = Call 0 0 ([byte[]](0x00, 0x01)) if (-not $fs -or $fs[2] -eq 0xFF) { "No answer from slot $Slot (keyboard asleep or off?): " + [HidppReceiver]::Hex($fs); return } $fsIdx = $fs[4] $cnt = (Call $fsIdx 0 @())[4] "Slot $Slot on 046D:$Rcv has $cnt features (+root):" for ($i = 1; $i -le $cnt; $i++) { $r = Call $fsIdx 1 ([byte[]]($i)) $id = ([int]$r[4] -shl 8) -bor [int]$r[5] $n = $names[$id]; if (-not $n) { $n = '?' } " idx {0,2} 0x{1:X4} {2}{3}" -f $i, $id, $n, $(if ($r[6] -band 0x40) {' (engineering/hidden)'} else {''}) } } finally { $rx.Dispose() }