Skip to content

Commit

Permalink
Catch device removal as well as device arrival on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Aug 16, 2018
1 parent 641c674 commit c886665
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/joystick/hidapi/SDL_hidapijoystick.c
Expand Up @@ -142,6 +142,7 @@ typedef struct _DEV_BROADCAST_DEVICEINTERFACE_A

typedef struct _DEV_BROADCAST_HDR DEV_BROADCAST_HDR;
#define DBT_DEVICEARRIVAL 0x8000 /* system detected a new device */
#define DBT_DEVICEREMOVECOMPLETE 0x8004 /* device was removed from the system */
#define DBT_DEVTYP_DEVICEINTERFACE 0x00000005 /* device interface class */
#define DBT_DEVNODES_CHANGED 0x0007
#define DBT_CONFIGCHANGED 0x0018
Expand All @@ -157,12 +158,13 @@ static LRESULT CALLBACK ControllerWndProc(HWND hwnd, UINT message, WPARAM wParam
case WM_DEVICECHANGE:
switch (wParam) {
case DBT_DEVICEARRIVAL:
case DBT_DEVICEREMOVECOMPLETE:
if (((DEV_BROADCAST_HDR*)lParam)->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) {
SDL_HIDAPI_discovery.m_bHaveDevicesChanged = SDL_TRUE;
}
break;
}
return 0;
return TRUE;
}

return DefWindowProc(hwnd, message, wParam, lParam);
Expand Down

0 comments on commit c886665

Please sign in to comment.