From 9027f80b86e8caddd3245170460450a096afc33f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 7 Jul 2016 11:48:28 +0200 Subject: logic/joystick: initialize dinput handle ASAP --- opentrack-logic/win32-joystick.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'opentrack-logic/win32-joystick.cpp') diff --git a/opentrack-logic/win32-joystick.cpp b/opentrack-logic/win32-joystick.cpp index 41427629..a24224b0 100644 --- a/opentrack-logic/win32-joystick.cpp +++ b/opentrack-logic/win32-joystick.cpp @@ -1,12 +1,13 @@ #ifdef _WIN32 #undef NDEBUG +#include "win32-joystick.hpp" +#include "opentrack-compat/sleep.hpp" #include #include #include #include -#include "win32-joystick.hpp" -#include "opentrack-compat/sleep.hpp" +#include QMutex win32_joy_ctx::enum_state::mtx; win32_joy_ctx::enum_state win32_joy_ctx::enumerator; @@ -115,6 +116,7 @@ win32_joy_ctx::di_t& win32_joy_ctx::make_di() { if (SUCCEEDED(DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&di_, NULL))) { + qDebug() << "made di handle"; return di_; } else @@ -384,4 +386,13 @@ win32_joy_ctx::joy::~joy() release(); } +win32_joy_ctx::di_initializer::di_initializer() +{ + HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + if (FAILED(hr)) + qDebug() << "dinput: failed CoInitializeEx" << hr << GetLastError(); + win32_joy_ctx::make_di(); + qDebug() << "made directinput8 handle"; +} + #endif -- cgit v1.2.3