Skip to content

Please consider restoring the [Import] custom DirectInput backend option removed in Xidi 5.0 #129

Open

Description

@Goblan

Hi Samuel,

I would like to suggest restoring the old [Import] functionality that was available in Xidi 4.x, or providing an equivalent way in Xidi 5.x to select a custom underlying DirectInput implementation.

I have been working on compatibility improvements for the PC version of Sega Rally 2, and we recently ran into a rather unusual but reproducible compatibility issue involving legacy DirectInput.

On one Windows 11 system, Xidi 5.0.0 using the DInput wrapper intermittently crashes the game before startup. After some debugging, I traced the problem to the system legacy dinput.dll while it is enumerating HID devices.

One particular MSI Mystic Light HID device (VID_1462&PID_7C84) reliably triggers the problem on that machine. Using Full Page Heap, the crash could be caught as an out-of-bounds write inside the Windows system dinput.dll during device enumeration.

The behavior is very reproducible on that system:

  • Mystic Light HID enabled: 0/8 successful launches
  • Mystic Light HID disabled: 12/12 successful launches
  • Re-enabled again: 0/8 successful launches

I also tested the new Xidi 5.0.0 HookModule approach. HookModule itself loads and hooks correctly, but the log shows that it still loads and hooks:

C:\Windows\System32\DINPUT.dll

and the same startup failure still occurs. In other words, HookModule changes how Xidi intercepts DirectInput, but in this particular case it does not avoid the problematic legacy DirectInput implementation underneath.

Using Dinputto8 solves the problem because it redirects the legacy DirectInput calls to the system dinput8.dll instead.

I initially used:

Game
→ Dinputto8
→ Xidi
→ DirectInput backend

which works, but then I remembered that Xidi 4.x supported the old [Import] section.

With Xidi 4.3.1 I can instead use:

[Import]
dinput.dll = MUSASHI\dinput_backend.dll

where dinput_backend.dll is Dinputto8.

This gives a much cleaner architecture:

Game
→ Xidi
→ Dinputto8 (custom backend)
→ Windows dinput8.dll

Xidi remains the DirectInput implementation exposed to the game, handling its virtual controllers, mappings and configuration, while Dinputto8 is used only as the underlying DirectInput backend.

Xidi 4.3.1 confirms this in its log:

Attempting to import DirectInput functions from MUSASHI\dinput_backend.dll.
Successfully initialized imported DirectInput functions.
Successfully created a DirectInput interface object.
Finished enumerating DirectInput devices.

This configuration is working correctly in my current tests with the latest Dinputto8 backend.

More importantly, another Sega Rally 2 user who could not launch the game with the normal setup has already tested this Xidi 4.x + [Import] + Dinputto8-backend configuration, and the game started successfully for him.

I have tested this exact configuration on my original problematic PC with the Mystic Light HID enabled, and it solved the issue.

The reason I think restoring [Import] would be valuable is not specifically because of this one Mystic Light device. It provides a useful compatibility escape hatch whenever the system's legacy DirectInput implementation causes problems on a particular machine.

Rather than placing another wrapper in front of Xidi, [Import] allows Xidi itself to remain the front-facing DirectInput layer while selecting a safer or more compatible backend underneath.

Would you consider restoring [Import] in Xidi 5.x, or adding an equivalent backend override mechanism? Or perhaps a new setting under [Workarounds] would be enough.

Thanks for your work on Xidi.

Activity

  1. ProjectXsent commented on Sep 15, 2026

    @ProjectXsent

    Does it also occur when you use SDL2/SDL3 Plugins?

  2. Goblan commented on Sep 15, 2026

    @Goblan
    Author

    Thanks for the suggestion. I have now tested both the SDL2 and SDL3 plugins on the affected machine.

    Unfortunately, the crash still occurs with both.

    Both plugins are loading and registering correctly. For example, with SDL3 the log shows:

    Attempting to import DirectInput legacy functions from C:\WINDOWS\system32\dinput.dll.
    Finished importing DirectInput legacy functions.
    Successfully created a DirectInput interface object.
    Starting to enumerate DirectInput devices.
    Successfully loaded plugin: "...\SDL.XidiPlugin.32.dll"
    [0]: type = PhysicalControllerBackend, name = "SDL3" (successfully registered)
    

    And SDL2 behaves the same way:

    Attempting to import DirectInput legacy functions from C:\WINDOWS\system32\dinput.dll.
    Finished importing DirectInput legacy functions.
    Successfully created a DirectInput interface object.
    Starting to enumerate DirectInput devices.
    Successfully loaded plugin: "...\SDL.XidiPlugin.32.dll"
    [0]: type = PhysicalControllerBackend, name = "SDL2" (successfully registered)
    

    So it appears that the SDL plugins replace Xidi's physical controller backend, but they do not replace the underlying legacy DirectInput implementation used for passthrough/device enumeration.

    On this machine, Xidi still creates the DirectInput interface through the system dinput.dll before the SDL backend is loaded, so the problematic EnumDevices path is still used.

    With SDL2, the log even reaches the problematic device:

    Failed to create the device (result = 0x80004005).
    Enumerate: DirectInput device "MYSTIC LIGHT " ...
    

    and the game still fails to start.

    This is why the old [Import] functionality makes a difference in this particular case.

    So, as far as I can tell, SDL2/SDL3 and [Import] solve two different things: the SDL plugins replace the physical controller backend, while [Import] allows replacing the DirectInput implementation that Xidi delegates to.

  3. ProjectXsent commented on Sep 17, 2026

    @ProjectXsent

    Not sure if this helps but I managed to build v4.3.1 and integrated SDL3.
    https://github.com/ProjectXsent/Xidi-SDL2/releases/tag/Xidi-SDL3-v0.0.9

    Probably with this, you can now use [Import] while be able to connect different brand of controllers.

  4. samuelgr commented on Sep 17, 2026

    @samuelgr
    Owner

    I doubt that swapping out the back-end plugin would help because Xidi imports from system DirectInput libraries pretty deeply within its own code. At the moment, Xidi relies on them for some of its own functionality.

    I removed the [Import] feature as an implementation simplification for the new versions of the wrapper libraries (dinput, dinput8, and winmm) and because I didn't see much evidence of that feature actually being used. I can certainly add it back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions