Repository navigation
Description
Hi, and thanks for VIIPER — the USB/IP approach is by far the cleanest virtual pad I've tried.
This is a question rather than a bug report: I don't think what I'm seeing is a defect in VIIPER, but I'd like to know whether the behaviour is fundamental or whether there's a knob I've missed.
What I'm trying to do
Feed synthetic input to a game that reads XInputGetState(0), while a physical Xbox 360 controller stays connected to the same machine. So I need the virtual pad to hold XInput user index 0 while the physical pad is plugged in.
What happens
The physical controller always takes slot 0 and the VIIPER pad is pushed to slot 1.
Scenario | VIIPER pad lands on -- | -- No physical controller connected | slot 0 Pad created first (in slot 0), then physical controller plugged in | demoted to slot 1, immediately Physical controller connected first, then pad created | slot 1 Physical connected, pad removed via bus/remove and re-added | slot 1The demotion happens the moment the physical device is enumerated and is completely stable — I watched it for several minutes with no flip back. Notably it is not first-come-first-served: in one earlier run the virtual pad had been online for over a minute before the physical controller was plugged in, and it was still demoted.
How I measured it
Self-reported indices are not trustworthy here (I've had a virtual bus API report index 0 for a pad that was demonstrably on slot 2), so I pulse a button on the virtual pad and watch which XInput slot's button mask follows:
def find_slot(pad):
"""Slot whose buttons follow our A pulse, or None."""
base = slots() # {slot: buttons} for all connected XInput devices
pad.buttons = 0x1000 # A
time.sleep(0.25)
pressed = slots()
pad.buttons = 0
time.sleep(0.15)
hits = [s for s in pressed
if pressed[s] & 0x1000 and not base.get(s, 0) & 0x1000]
return hits[0] if len(hits) == 1 else None
slots() is just XInputGetState(i) over i in range(4) via xinput1_4.dll, collecting the ones that return ERROR_SUCCESS.
The pad is created with bus/create + bus/1/add {"type":"xbox360"}, with a feed thread pushing 20-byte reports every 8 ms to keep it alive.
Why I think this isn't a VIIPER problem
The VIIPER pad really is a genuine USB device as far as Windows is concerned — same VID/PID, same setup class, same function driver as the physical pad. I walked the PnP parent chain of both:
=== VIIPER virtual ===
USB\VID_045E&PID_028E\296013F
USB\ROOT_HUB30\1&2b53a856&0&0
ROOT\USB\0000 <-- USBip emulated host controller
HTREE\ROOT\0
=== Physical ===
USB\VID_045E&PID_028E\5&201B4142&0&10
USB\ROOT_HUB30\4&17da066&0&0
PCI\VEN_8086&DEV_A3AF&... <-- real Intel xHCI
ACPI\PNP0A08\0
ACPI_HAL\PNP0C08\0
ROOT\ACPI_HAL\0000
Both are class XnaComposite, both are bound to service xusb22. They are identical right up to the host controller — the only structural difference is that the emulated controller is root-enumerated (ROOT\USB\0000 → HTREE\ROOT\0) whereas the real xHCI hangs off PCI/ACPI.
My guess is that whatever ordering XInput uses to assign user indices ends up ranking the PCI/ACPI branch ahead of the root-enumerated one, and that this is re-evaluated whenever the set of XInput devices changes. But that's speculation — I haven't found documentation on how dwUserIndex is actually assigned.
I also confirmed this isn't specific to VIIPER: I get the same demotion with ViGEmBus (which lands on slot 2, skipping an empty slot 1) and with HIDMaestro. VIIPER is actually the best-behaved of the three — it takes the lowest free slot predictably.
Questions
- Is there anything in VIIPER that can influence XInput user-index assignment — device ordering, port/bus placement on the emulated controller, timing of attach, anything?
- Has anyone got a VIIPER pad to hold slot 0 alongside a physical XInput controller? If so I'd love to know the setup.
- Do you happen to know whether the root-enumerated host controller is in fact what causes the ranking? If the emulated controller could present itself differently, would that plausibly change the outcome — or is XInput's ordering based on something else entirely?
If the answer is "this can't be influenced from the virtual side", that's a perfectly useful answer — it would tell me to stop looking here and go block the physical device at the USB layer instead. Just want to be sure I'm not missing an option before I go that route.
Environment
- Windows 11 Pro, build 26200, x64
- VIIPER v0.7.0 (
viiper-windows-amd64) - usbip-win2 v0.9.7.7
- Physical pad: wired Xbox 360 controller,
USB\VID_045E&PID_028E - Server started with
viiper.exe server --api.auto-attach-local-client --log.level=debug; auto-attach prerequisites reported satisfied - Tested after a clean reboot (the usbip driver had been installed without a restart in an earlier round, so I re-ran everything from a cold boot to rule out enumeration-order differences — results were identical)
Activity