Details
-
Bug
-
Resolution: Won't Do
-
P3: Somewhat important
-
None
-
5.9.0
-
None
-
Qt 5.9.0 on Windows 7, tested both with Xbox 360 controller and an Xbox One controller.
Description
Detecting connected gamepads with QGamepadManager::instance()->connectedGamepads() fails on Windows 7 when no QWindow was shown on screen yet.
This can be verified using the Qt example programs: Qt Gamepad Qt Quick Example works fine, but Qt Gamepad Simple Example does not detect the connected controller.
A workaround is to create, show, and delete a dummy window before detecting gamepads:
QWindow* window = new QWindow();
window->show();
delete window;
QApplication::processEvents();
QGamepadManager::instance()->connectedGamepads()
Note that both show() and processEvents() are necessary. Presumably some initialization stuff happens on Windows platforms when the first window is shown on screen, and QGamepadManager relies on that.
The problem does not exist on Linux. I did not test other systems.