C ++ on Windows: using DirectInput without a window?

Short version:

How to initialize and use DirectInput if I do not have access to HWND / HINSTANCE?

Background Information:

I am currently using SFML for most parts of my program, including creating windows. It works like a charm. But I'm not completely satisfied with the SFML input system (for example, I want XInput for XBox 360 game consoles) and want to write my own.

I already wrote part of XInput, but for other gamepads / joysticks / ... I also need DirectInput. Since SFML hides Windows code from the user (and rightly so), I do not have access to hwnd or hinstance. How can I use DirectInput without it? Maybe catch the entrance all the time, not only when the window is active? (I could then filter it based on the activated Window (de) event.)

Thank,

Wonko

+3
source share
2 answers

Finding back is not too complicated, use EnumThreadWindows () and GetCurrentThreadId ().

Note that DirectInput does not need any window handle. It just needs an instance handle in DirectInput8Create (). GetModuleHandle (NULL) is suitable for an SFML application.

+3

HINSTANCE, : GetModuleHandle (NULL)

+1

Source: https://habr.com/ru/post/1782455/


All Articles