Catch device removal as well as device arrival on Windows
authorSam Lantinga <slouken@libsdl.org>
Wed, 15 Aug 2018 19:53:30 -0700
changeset 121139bede6f89b4c
parent 12112 547ea8a49167
child 12114 34cc14308155
Catch device removal as well as device arrival on Windows
src/joystick/hidapi/SDL_hidapijoystick.c
     1.1 --- a/src/joystick/hidapi/SDL_hidapijoystick.c	Wed Aug 15 19:53:28 2018 -0700
     1.2 +++ b/src/joystick/hidapi/SDL_hidapijoystick.c	Wed Aug 15 19:53:30 2018 -0700
     1.3 @@ -142,6 +142,7 @@
     1.4  
     1.5  typedef struct  _DEV_BROADCAST_HDR      DEV_BROADCAST_HDR;
     1.6  #define DBT_DEVICEARRIVAL               0x8000  /* system detected a new device */
     1.7 +#define DBT_DEVICEREMOVECOMPLETE		0x8004  /* device was removed from the system */
     1.8  #define DBT_DEVTYP_DEVICEINTERFACE      0x00000005  /* device interface class */
     1.9  #define DBT_DEVNODES_CHANGED            0x0007
    1.10  #define DBT_CONFIGCHANGED               0x0018
    1.11 @@ -157,12 +158,13 @@
    1.12      case WM_DEVICECHANGE:
    1.13          switch (wParam) {
    1.14          case DBT_DEVICEARRIVAL:
    1.15 +		case DBT_DEVICEREMOVECOMPLETE:
    1.16              if (((DEV_BROADCAST_HDR*)lParam)->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) {
    1.17                  SDL_HIDAPI_discovery.m_bHaveDevicesChanged = SDL_TRUE;
    1.18              }
    1.19              break;
    1.20          }
    1.21 -        return 0;
    1.22 +        return TRUE;
    1.23      }
    1.24  
    1.25      return DefWindowProc(hwnd, message, wParam, lParam);