mirror of
https://github.com/AxioDL/boo.git
synced 2025-12-09 05:27:58 +00:00
WinUSB API implemented!!
This commit is contained in:
@@ -9,6 +9,12 @@
|
||||
#include "SDeviceSignature.hpp"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define _WIN32_LEAN_AND_MEAN 1
|
||||
#include <windows.h>
|
||||
#include <Dbt.h>
|
||||
#endif
|
||||
|
||||
namespace boo
|
||||
{
|
||||
|
||||
@@ -146,6 +152,47 @@ public:
|
||||
|
||||
virtual void deviceConnected(CDeviceToken&) {}
|
||||
virtual void deviceDisconnected(CDeviceToken&, CDeviceBase*) {}
|
||||
|
||||
#if _WIN32
|
||||
/* Windows-specific WM_DEVICECHANGED handler */
|
||||
static LRESULT winDevChangedHandler(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PDEV_BROADCAST_HDR dbh = (PDEV_BROADCAST_HDR)lParam;
|
||||
PDEV_BROADCAST_DEVICEINTERFACE dbhi = (PDEV_BROADCAST_DEVICEINTERFACE)lParam;
|
||||
CDeviceFinder* finder = instance();
|
||||
if (!finder)
|
||||
return 0;
|
||||
|
||||
if (wParam == DBT_DEVICEARRIVAL)
|
||||
{
|
||||
if (dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
||||
{
|
||||
#ifdef UNICODE
|
||||
char devPath[1024];
|
||||
wcstombs(devPath, dbhi->dbcc_name, 1024);
|
||||
finder->m_listener->_extDevConnect(devPath);
|
||||
#else
|
||||
finder->m_listener->_extDevConnect(dbhi->dbcc_name);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (wParam == DBT_DEVICEREMOVECOMPLETE)
|
||||
{
|
||||
if (dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
||||
{
|
||||
#ifdef UNICODE
|
||||
char devPath[1024];
|
||||
wcstombs(devPath, dbhi->dbcc_name, 1024);
|
||||
finder->m_listener->_extDevDisconnect(devPath);
|
||||
#else
|
||||
finder->m_listener->_extDevDisconnect(dbhi->dbcc_name);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -23,6 +23,12 @@ public:
|
||||
|
||||
/* Manual device scanning */
|
||||
virtual bool scanNow()=0;
|
||||
|
||||
#if _WIN32
|
||||
/* External listener implementation (for Windows) */
|
||||
virtual bool _extDevConnect(const char* path)=0;
|
||||
virtual bool _extDevDisconnect(const char* path)=0;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user