Capture a chosen keyboard's keys without window focus (Raw Input)

The WinForms focus path only sees keys while vRIO is foreground and can't
tell one keyboard from another, so vRIO went deaf the moment the sim took
focus. The new "Capture keyboard" picker in the Input panel taps one
physical keyboard through the Win32 Raw Input API (RIDEV_INPUTSINK) and
routes its keys to the panel even in the background — the input-side twin
of the lamp mirror writing that keyboard's LEDs under the same condition.

Raw Input observes without intercepting, so keys still reach the focused
app; the picker defaults to "All keyboards (focus only)", preserving the
prior focus-bound behavior, and only registers Raw Input while a specific
device is selected. While capturing, the focus path stands down but still
swallows bound keys so they can't click panel buttons.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Cyd
2026-07-06 21:31:49 -05:00
co-authored by Claude Opus 4.8
parent bec3bb1e4a
commit 391c53f294
3 changed files with 491 additions and 11 deletions
+11
View File
@@ -48,6 +48,17 @@ controls:
F1F6 / F7F12 = the Secondary / Screen columns, numpad = internal
keypad (hex keys on the operators), arrows + Space = hat + main, with
ABXY / dpad / shoulders on the pad's named buttons.
- **Capture one keyboard in the background** (*Capture keyboard* picker in the
Input panel): by default keyboard input follows the focused window, so vRIO
goes deaf the moment the sim takes focus. Selecting a specific keyboard
instead taps it through the Windows **Raw Input** API (`RIDEV_INPUTSINK`), so
its keys drive the panel *while the game has focus* — the input-side twin of
the lamp mirror writing that keyboard's LEDs under the same condition. Raw
Input observes without intercepting: the keystroke still reaches the focused
app, so this is meant for a keyboard *dedicated* to the panel, not the one you
also type on. Leaving the picker on *All keyboards* keeps the plain
focus-only behavior. (No package identity needed — unlike the lamp side, this
is a plain Win32 tap.)
## Wire behavior