2020-07-15 11:10:20 +00:00
|
|
|
#include "DeviceNotification.h"
|
|
|
|
#include "CProject64Input.h"
|
|
|
|
#include <dbt.h>
|
|
|
|
|
|
|
|
DeviceNotification::DeviceNotification()
|
|
|
|
{
|
2021-04-12 11:35:39 +00:00
|
|
|
Create(nullptr);
|
2020-07-15 11:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DeviceNotification::~DeviceNotification()
|
|
|
|
{
|
|
|
|
DestroyWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
int DeviceNotification::OnCreate(LPCREATESTRUCT /*lpCreateStruct*/)
|
|
|
|
{
|
|
|
|
DEV_BROADCAST_DEVICEINTERFACE notificationFilter = { 0 };
|
|
|
|
notificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
|
|
|
|
notificationFilter.dbcc_size = sizeof(notificationFilter);
|
|
|
|
|
|
|
|
HDEVNOTIFY hDevNotify;
|
|
|
|
hDevNotify = RegisterDeviceNotification(m_hWnd, ¬ificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL DeviceNotification::OnDeviceChange(UINT nEventType, DWORD /*dwData*/)
|
|
|
|
{
|
|
|
|
if (g_InputPlugin != nullptr && (nEventType == DBT_DEVICEARRIVAL || nEventType == DBT_DEVICEREMOVECOMPLETE))
|
|
|
|
{
|
|
|
|
g_InputPlugin->DevicesChanged();
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|