mirror of
https://github.com/AxioDL/boo.git
synced 2025-07-17 18:45:51 +00:00
Windows fixes and include refinements
This commit is contained in:
parent
c77fe94313
commit
dbf7b9bcf8
@ -209,6 +209,7 @@ add_library(boo
|
|||||||
lib/inputdev/DualshockPad.cpp include/boo/inputdev/DualshockPad.hpp
|
lib/inputdev/DualshockPad.cpp include/boo/inputdev/DualshockPad.hpp
|
||||||
lib/inputdev/GenericPad.cpp include/boo/inputdev/GenericPad.hpp
|
lib/inputdev/GenericPad.cpp include/boo/inputdev/GenericPad.hpp
|
||||||
lib/inputdev/DeviceSignature.cpp include/boo/inputdev/DeviceSignature.hpp
|
lib/inputdev/DeviceSignature.cpp include/boo/inputdev/DeviceSignature.hpp
|
||||||
|
lib/inputdev/DeviceFinder.cpp include/boo/inputdev/DeviceFinder.hpp
|
||||||
lib/inputdev/IHIDDevice.hpp
|
lib/inputdev/IHIDDevice.hpp
|
||||||
lib/audiodev/WAVOut.cpp
|
lib/audiodev/WAVOut.cpp
|
||||||
lib/audiodev/AudioMatrix.hpp
|
lib/audiodev/AudioMatrix.hpp
|
||||||
|
@ -54,6 +54,8 @@ namespace boo
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#include <D3Dcommon.h>
|
||||||
#include <wrl/client.h>
|
#include <wrl/client.h>
|
||||||
template <class T>
|
template <class T>
|
||||||
using ComPtr = Microsoft::WRL::ComPtr<T>;
|
using ComPtr = Microsoft::WRL::ComPtr<T>;
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include "IGraphicsCommandQueue.hpp"
|
#include "IGraphicsCommandQueue.hpp"
|
||||||
#include "boo/IGraphicsContext.hpp"
|
#include "boo/IGraphicsContext.hpp"
|
||||||
#include "boo/System.hpp"
|
#include "boo/System.hpp"
|
||||||
#include <D3Dcommon.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#define WIN32_LEAN_AND_MEAN 1
|
#define WIN32_LEAN_AND_MEAN 1
|
||||||
#endif
|
#endif
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <Dbt.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace boo
|
namespace boo
|
||||||
@ -30,20 +29,20 @@ public:
|
|||||||
friend class HIDListenerUdev;
|
friend class HIDListenerUdev;
|
||||||
friend class HIDListenerWinUSB;
|
friend class HIDListenerWinUSB;
|
||||||
static inline DeviceFinder* instance() {return skDevFinder;}
|
static inline DeviceFinder* instance() {return skDevFinder;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/* Types this finder is interested in (immutable) */
|
/* Types this finder is interested in (immutable) */
|
||||||
DeviceSignature::TDeviceSignatureSet m_types;
|
DeviceSignature::TDeviceSignatureSet m_types;
|
||||||
|
|
||||||
/* Platform-specific USB event registration
|
/* Platform-specific USB event registration
|
||||||
* (for auto-scanning, NULL if not registered) */
|
* (for auto-scanning, NULL if not registered) */
|
||||||
IHIDListener* m_listener;
|
IHIDListener* m_listener;
|
||||||
|
|
||||||
/* Set of presently-connected device tokens */
|
/* Set of presently-connected device tokens */
|
||||||
TDeviceTokens m_tokens;
|
TDeviceTokens m_tokens;
|
||||||
std::mutex m_tokensLock;
|
std::mutex m_tokensLock;
|
||||||
|
|
||||||
/* Friend methods for platform-listener to find/insert/remove
|
/* Friend methods for platform-listener to find/insert/remove
|
||||||
* tokens with type-filtering */
|
* tokens with type-filtering */
|
||||||
inline bool _hasToken(const std::string& path)
|
inline bool _hasToken(const std::string& path)
|
||||||
@ -80,9 +79,9 @@ private:
|
|||||||
m_tokensLock.unlock();
|
m_tokensLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
class CDeviceTokensHandle
|
class CDeviceTokensHandle
|
||||||
{
|
{
|
||||||
DeviceFinder& m_finder;
|
DeviceFinder& m_finder;
|
||||||
@ -93,7 +92,7 @@ public:
|
|||||||
inline TDeviceTokens::iterator begin() {return m_finder.m_tokens.begin();}
|
inline TDeviceTokens::iterator begin() {return m_finder.m_tokens.begin();}
|
||||||
inline TDeviceTokens::iterator end() {return m_finder.m_tokens.end();}
|
inline TDeviceTokens::iterator end() {return m_finder.m_tokens.end();}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Application must specify its interested device-types */
|
/* Application must specify its interested device-types */
|
||||||
DeviceFinder(std::unordered_set<std::type_index> types)
|
DeviceFinder(std::unordered_set<std::type_index> types)
|
||||||
: m_listener(NULL)
|
: m_listener(NULL)
|
||||||
@ -122,13 +121,13 @@ public:
|
|||||||
delete m_listener;
|
delete m_listener;
|
||||||
skDevFinder = NULL;
|
skDevFinder = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get interested device-type mask */
|
/* Get interested device-type mask */
|
||||||
inline const DeviceSignature::TDeviceSignatureSet& getTypes() const {return m_types;}
|
inline const DeviceSignature::TDeviceSignatureSet& getTypes() const {return m_types;}
|
||||||
|
|
||||||
/* Iterable set of tokens */
|
/* Iterable set of tokens */
|
||||||
inline CDeviceTokensHandle getTokens() {return CDeviceTokensHandle(*this);}
|
inline CDeviceTokensHandle getTokens() {return CDeviceTokensHandle(*this);}
|
||||||
|
|
||||||
/* Automatic device scanning */
|
/* Automatic device scanning */
|
||||||
inline bool startScanning()
|
inline bool startScanning()
|
||||||
{
|
{
|
||||||
@ -156,51 +155,15 @@ public:
|
|||||||
return m_listener->scanNow();
|
return m_listener->scanNow();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void deviceConnected(DeviceToken&) {}
|
virtual void deviceConnected(DeviceToken&) {}
|
||||||
virtual void deviceDisconnected(DeviceToken&, DeviceBase*) {}
|
virtual void deviceDisconnected(DeviceToken&, DeviceBase*) {}
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
/* Windows-specific WM_DEVICECHANGED handler */
|
/* Windows-specific WM_DEVICECHANGED handler */
|
||||||
static LRESULT winDevChangedHandler(WPARAM wParam, LPARAM lParam)
|
static LRESULT winDevChangedHandler(WPARAM wParam, LPARAM lParam);
|
||||||
{
|
#endif
|
||||||
PDEV_BROADCAST_HDR dbh = (PDEV_BROADCAST_HDR)lParam;
|
|
||||||
PDEV_BROADCAST_DEVICEINTERFACE dbhi = (PDEV_BROADCAST_DEVICEINTERFACE)lParam;
|
|
||||||
DeviceFinder* 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
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
51
lib/inputdev/DeviceFinder.cpp
Normal file
51
lib/inputdev/DeviceFinder.cpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#include "boo/inputdev/DeviceFinder.hpp"
|
||||||
|
|
||||||
|
#if _WIN32
|
||||||
|
#include <Dbt.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace boo
|
||||||
|
{
|
||||||
|
|
||||||
|
#if _WIN32
|
||||||
|
/* Windows-specific WM_DEVICECHANGED handler */
|
||||||
|
LRESULT DeviceFinder::winDevChangedHandler(WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
PDEV_BROADCAST_HDR dbh = (PDEV_BROADCAST_HDR)lParam;
|
||||||
|
PDEV_BROADCAST_DEVICEINTERFACE dbhi = (PDEV_BROADCAST_DEVICEINTERFACE)lParam;
|
||||||
|
DeviceFinder* 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
|
||||||
|
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
#include <initguid.h>
|
#include <initguid.h>
|
||||||
#include <Usbiodef.h>
|
#include <Usbiodef.h>
|
||||||
#include <winver.h>
|
#include <winver.h>
|
||||||
|
#include <Dbt.h>
|
||||||
|
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
#define D3D11_CREATE_DEVICE_FLAGS D3D11_CREATE_DEVICE_DEBUG
|
#define D3D11_CREATE_DEVICE_FLAGS D3D11_CREATE_DEVICE_DEBUG
|
||||||
|
Loading…
x
Reference in New Issue
Block a user