diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-07-07 11:48:28 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-07-07 11:48:28 +0200 |
commit | 9027f80b86e8caddd3245170460450a096afc33f (patch) | |
tree | 92bb4476e9906a222b5c91fc2341eb6c5c7368a2 /opentrack-logic/win32-joystick.cpp | |
parent | fa9dcb9da8ad8a0b164a4008d5b493a268d682cf (diff) |
logic/joystick: initialize dinput handle ASAP
Diffstat (limited to 'opentrack-logic/win32-joystick.cpp')
-rw-r--r-- | opentrack-logic/win32-joystick.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
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 <cassert> #include <cstring> #include <algorithm> #include <cmath> -#include "win32-joystick.hpp" -#include "opentrack-compat/sleep.hpp" +#include <objbase.h> 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 |