Direct Input FPS Fix

What Is this?

The DirectInputFpsFix fixes a bug that causes the FPS to severely drop after a few minutes of play. This problem is probably most widely known in regards to the game FEAR and often occurs in conjunction with the usage of Logitech devices.

However, the problem also pops up in other games using the same engine, such as the FEAR expansions or Condemned: Criminal Origins and with non-Logitech hardware configurations. A similar problem has also been reported to occur in other games, such as Prototype.

Although this problem can often be fixed by disabling most/all HID-Devices in the device manager, it is bothersome to do so and lately some people reported that that solution doesn’t even work at all anymore, especially on machines running Windows 10.

Instructions

  1. Download this zip-file
  2. Extract the file dinput8.dll to the folder containing the executable of the game. For Steam in most cases this is "Steam\steamapps\common'. For example: 'D:\Games\Steam\steamapps\common\FEAR Ultimate Shooter Edition"
  3. Start the game like you would normally, e.g. through Steam or GOG-Galaxy.

Note: This fix makes no permanent changes to the system or the installation of the game. To uninstall the fix just remove or rename the dinput8.dll file.

Supported Games

This is a list of games for which the DLL has either been confirmed to fix the problem or might fix the problem. Feel free to provide feedback if the DLL works on other games as well.

The fix is agnostic towards the game that uses it and should therefore work with all versions of a supported game, including teh Steam, GOG and retail versions.

  • Confirmed:
    • FEAR and its expansions
    • Condemned: Criminal Origins
  • Supposedly:
    • Prototype

What You Should Know

Since this fix consists of an executable DLL-File, I could have put any harmful shenanigans in there. You just have to trust me that the file is clean.

If you don’t — and why should you — feel free to use a meta online virus scanner like VirusTotal to verify the file. Be aware however, that the file could trigger anti-virus software without being harmful.

How This Works

The fix is implemented using a common technique known as DLL hooking.

User input in games like FEAR can be realized via DirectInput, an API by Microsoft for interacting with HID-Devices. The library is ancient and should no longer be used today, because there are other ways to get mouse and keyboard input, especially for games.

The FPS drops happen because the thread that runs DirectInput massively slows down after a while (as can be seen in tools like ProcessExplorer).

If an application uses a library like DirectInput, it needs a so-called DLL (dynamic-link library) where the functionality of the library is stored. In many cases, especially for libraries provided by Microsoft, these DLLs usually reside in the Windows folder.

However, there is an order of how an application searches for the DLLs it needs. Since the DLL of the fix gets copied into the main folder of the application and has the same name of a DLL needed by the game (the one of DirectInput), it gets loaded instead of the one in the Windows folder.

This means that all calls to DirectInput go through the Hook-DLL and can either be directed to the original DLL in the Windows folder or changed as necessary. This also allows some insight in how exactly the library is used by the game.

It turned out that some games not only unnecessarily register all HID-devices, they also call several functions every frame that usually only should be called once during initialization. The latter seems to apply only to devices that are not keyboards or mice. This eventually leads to circumstances where a lot of time is spent opening and closing device connections.

The fix changes the DirectInput initialization in such a way that only keyboard and pointer devices get registered.

Reported Problems

Up to this point I have no reports that the fix doesn’t work for anyone. But since PCs offer a wide variety of hard- and software configurations, I cannot say for sure that there will not be some unexpected problems.

However, in theory the problem should be fixable with the approach I used, regardless of whether the current implementation works flawlessly or not.

If you have any problems don’t hesitate to provide feedback.

I really love these games and I think they deserve to be preserved.

Version History

Beta 0.2:

  • Statically linked the Microsoft Visual C++ Runtime so that users no longer have to install the corresponding Visual C++ Redistributable package.

Beta 0.1:

  • Initial release
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s