On 12/17/21 16:31, Nikolay Sivov wrote:
On 12/17/21 17:24, Rémi Bernon wrote:
-void joystick_load( HINSTANCE instance ) +static BOOL WINAPI joystick_load( INIT_ONCE *once, void *param, void **context ) { - HRESULT hr = DirectInput8Create( instance, DIRECTINPUT_VERSION, &IID_IDirectInput8W, - (void **)&dinput, NULL ); - if (FAILED(hr)) WARN( "could not create dinput instance, hr %#x\n", hr ); + HRESULT hr;
+ CoInitialize( NULL );
+ hr = CoCreateInstance( &CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInput8W, + (void **)&dinput ); + if (FAILED(hr)) goto failed;
+ hr = IDirectInput8_Initialize( dinput, hWinMM32Instance, DIRECTINPUT_VERSION ); + if (FAILED(hr)) goto failed;
+ return TRUE;
+failed: + if (dinput) IDirectInput8_Release( dinput ); + dinput = NULL;
+ WARN( "Could not create dinput instance, hr %#x\n", hr ); + CoUninitialize(); + return FALSE; }
I don't think it's safe to initialize/uninitialize like that. For example if application already initialized with multithreaded mode.
Yes, thanks, Paul said something like that too on the previous version. I'll resend with delayload instead.