imgui: Implementation examples link to xinput 1.4 which doesn't work on Windows 7

Version/Branch of Dear ImGui:

Version: 1.72b Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_win32.cpp + imgui_impl_dx11.cpp Compiler: Visual Studio 2017 Operating System: Windows 10

My Issue/Question:

This issue is in response to #787. As of recently with the added gamepad inputs, Dear ImGui added a pragma link to the source to automatically link to xinput:

#ifdef _MSC_VER
#pragma comment(lib, "xinput")
#endif

This will cause MSVC to link against xinput1_4.dll, which is not available on Windows 7. (It probably will link against 1.3 or the strangely named “9.1.0” if you’re building on a Windows 7 machine though.)

Since there are 3 possible versions of xinput, I propose a possible fix where we link with xinput 9.1.0 instead, which is shipped both within the 8.1 SDK and up, and on Windows 7 and up.

#ifdef _MSC_VER
#pragma comment(lib, "Xinput9_1_0")
#endif

It’s a bit weird that this is even required, but this will cause MSVC to link against Xinput9_1_0.dll, which seems to be available everywhere.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 16 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Pushed IMGUI_IMPL_WIN32_DISABLE_GAMEPAD IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT

This has been reworked and better solved by #3646 Now loading the XInput DLL dynamically, remove need to link to any of it. Removed IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT.

I’d be very happy to take a PR doing that (with minimum amount of cruft and code overhead so it doesn’t overwhelm casual readers).

I’ll have to research this for my own purposes already so I might as well PR it back upstream, sure!

I’d be very happy to take a PR doing that (with minimum amount of cruft and code overhead so it doesn’t overwhelm casual readers).

That’s a good solution I suppose! I’m definitely not using any of the gamepad features myself.