Destroy DirectInput helper window during shutdown

This commit is contained in:
Roland Winklmeier
2018-10-15 12:12:17 +02:00
committed by Klaus Basan
parent 294b854ed8
commit 4b3d3bba48
2 changed files with 17 additions and 0 deletions

View File

@@ -168,6 +168,7 @@ namespace BlackInput
m_joystickDevices.clear(); m_joystickDevices.clear();
m_directInput.reset(); m_directInput.reset();
CoUninitialize(); CoUninitialize();
destroyHelperWindow();
} }
void ReleaseDirectInput(IDirectInput8 *obj) void ReleaseDirectInput(IDirectInput8 *obj)
@@ -252,6 +253,19 @@ namespace BlackInput
return 0; return 0;
} }
void CJoystickWindows::destroyHelperWindow()
{
HINSTANCE hInstance = GetModuleHandle(nullptr);
if (helperWindow == nullptr) { return; }
DestroyWindow(helperWindow);
helperWindow = nullptr;
UnregisterClass(helperWindowClassName, hInstance);
helperWindowClass = 0;
}
void CJoystickWindows::addJoystickDevice(const DIDEVICEINSTANCE *pdidInstance) void CJoystickWindows::addJoystickDevice(const DIDEVICEINSTANCE *pdidInstance)
{ {
CJoystickDevice *device = new CJoystickDevice(m_directInput, pdidInstance, this); CJoystickDevice *device = new CJoystickDevice(m_directInput, pdidInstance, this);

View File

@@ -123,6 +123,9 @@ namespace BlackInput
//! Creates a hidden DI helper window //! Creates a hidden DI helper window
int createHelperWindow(); int createHelperWindow();
//! Destroys a hidden DI helper window
void destroyHelperWindow();
//! Add new joystick device //! Add new joystick device
void addJoystickDevice(const DIDEVICEINSTANCE *pdidInstance); void addJoystickDevice(const DIDEVICEINSTANCE *pdidInstance);