Restrict WM_DEVICECHANGE messages to only be sent when HID devices are affected, restrict DirectInput EnumDevices to only enumerate over attached devices. Fixes #1415
This commit is contained in:
parent
b922b04b5e
commit
ee957f3420
@ -449,7 +449,7 @@ void JoystickImpl::updateConnectionsDInput()
|
||||
joystickList[i].plugged = false;
|
||||
|
||||
// Enumerate devices
|
||||
HRESULT result = directInput->EnumDevices(DI8DEVCLASS_GAMECTRL, &JoystickImpl::deviceEnumerationCallback, NULL, DIEDFL_ALLDEVICES);
|
||||
HRESULT result = directInput->EnumDevices(DI8DEVCLASS_GAMECTRL, &JoystickImpl::deviceEnumerationCallback, NULL, DIEDFL_ATTACHEDONLY);
|
||||
|
||||
// Remove devices that were not connected during the enumeration
|
||||
for (std::vector<JoystickRecord>::iterator i = joystickList.begin(); i != joystickList.end();)
|
||||
|
@ -67,6 +67,8 @@ namespace
|
||||
const wchar_t* className = L"SFML_Window";
|
||||
sf::priv::WindowImplWin32* fullscreenWindow = NULL;
|
||||
|
||||
const GUID GUID_DEVINTERFACE_HID = {0x4d1e55b2, 0xf16f, 0x11cf, {0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30}};
|
||||
|
||||
void setProcessDpiAware()
|
||||
{
|
||||
// Try SetProcessDpiAwareness first
|
||||
@ -216,8 +218,8 @@ m_cursorGrabbed (m_fullscreen)
|
||||
m_handle = CreateWindowW(className, title.toWideString().c_str(), win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this);
|
||||
|
||||
// Register to receive device interface change notifications (used for joystick connection handling)
|
||||
DEV_BROADCAST_HDR deviceBroadcastHeader = {sizeof(DEV_BROADCAST_HDR), DBT_DEVTYP_DEVICEINTERFACE, 0};
|
||||
RegisterDeviceNotification(m_handle, &deviceBroadcastHeader, DEVICE_NOTIFY_WINDOW_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES);
|
||||
DEV_BROADCAST_DEVICEINTERFACE deviceInterface = {sizeof(DEV_BROADCAST_DEVICEINTERFACE), DBT_DEVTYP_DEVICEINTERFACE, 0, GUID_DEVINTERFACE_HID, 0};
|
||||
RegisterDeviceNotification(m_handle, &deviceInterface, DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||
|
||||
// If we're the first window handle, we only need to poll for joysticks when WM_DEVICECHANGE message is received
|
||||
if (m_handle)
|
||||
|
Loading…
Reference in New Issue
Block a user