-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Project64-input: Detect devices changed
- Loading branch information
Showing
6 changed files
with
96 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "DeviceNotification.h" | ||
#include "CProject64Input.h" | ||
#include <dbt.h> | ||
|
||
DeviceNotification::DeviceNotification() | ||
{ | ||
Create(NULL); | ||
} | ||
|
||
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
#include "wtl.h" | ||
|
||
typedef CWinTraits<WS_OVERLAPPED, WS_EX_APPWINDOW> DeviceNotificationTraits; | ||
|
||
class DeviceNotification : | ||
public CWindowImpl<DeviceNotification, CWindow, DeviceNotificationTraits> | ||
{ | ||
public: | ||
DECLARE_WND_CLASS(_T("My Window Class")) | ||
|
||
BEGIN_MSG_MAP(DeviceNotification) | ||
MSG_WM_CREATE(OnCreate) | ||
MSG_WM_DEVICECHANGE(OnDeviceChange) | ||
END_MSG_MAP() | ||
|
||
DeviceNotification(); | ||
~DeviceNotification(); | ||
|
||
private: | ||
int OnCreate(LPCREATESTRUCT lpCreateStruct); | ||
BOOL OnDeviceChange(UINT nEventType, DWORD dwData); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters