microsoft / GDK

Microsoft Public GDK
http://aka.ms/gamedevdocs
Other
1.48k stars 99 forks source link

GameInput Suitability for Win32/Terminal Apps #48

Closed TriceHelix closed 6 months ago

TriceHelix commented 6 months ago

Hi,

I've spent a couple of hours trying to make GameInput work in a plain Windows 10 Win32 (C++) app, configured via CMake. Including the GameInput.h header, compiling, and linking the executable all work as expected. There are no runtime errors. However, the IGameInput singleton does not provide any meaningful readings. Only one device exists, which is completely dead (no key, mouse, gamepad, or other kind of data is accessible). My code is as close to the examples available in the documentation as possible. My hardware is connected properly, drivers up-to-date, and everything else Windows-related is completely functional.

I have also tried building it as a Terminal application (plain int main() entry point, using std::cout to display read data), with limited success. Contrary to the Win32 attempt, my keyboard, mouse, and gamepad (Xbox One S Wireless Controller) are recognized by GameInput and I can detect pressed keys/buttons, mouse movement, etc. However, this behaviour is extremely inconsistent. For example, the mouse interface stops working after a few seconds (appears to be connected, but GetCurrentReading() always fetches the same IGameInputReading instance). What's worse is that after a system reboot, the code broke in a similar manner to the Win32 test. No code changes, no recompiles, simply a reboot.

I've also tried re-installing the entire GDK (I am using the latest version), to no avail. I cannot find any insight that might help me because most example projects are locked behind an NDA. As such, I hope to find some advice here.

TriceHelix commented 6 months ago

Resolved: Launching the built executable directly by double-clicking on it in the explorer instead of starting it from cmd.exe (or PowerShell) fixed all issues I had. No idea how that would influence the inner workings of the GDK, but maybe just a misconfiguration on my system. Sorry!