mirror of
https://github.com/AxioDL/boo.git
synced 2025-12-08 21:17:50 +00:00
UWP support
This commit is contained in:
@@ -55,12 +55,14 @@ size_t DeviceBase::receiveUSBInterruptTransfer(uint8_t* data, size_t length)
|
||||
}
|
||||
|
||||
#if _WIN32
|
||||
#if !WINDOWS_STORE
|
||||
const PHIDP_PREPARSED_DATA DeviceBase::getReportDescriptor()
|
||||
{
|
||||
if (m_hidDev)
|
||||
return m_hidDev->_getReportDescriptor();
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
std::vector<uint8_t> DeviceBase::getReportDescriptor()
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace boo
|
||||
|
||||
DeviceFinder* DeviceFinder::skDevFinder = nullptr;
|
||||
|
||||
#if _WIN32
|
||||
#if _WIN32 && !WINDOWS_STORE
|
||||
/* Windows-specific WM_DEVICECHANGED handler */
|
||||
LRESULT DeviceFinder::winDevChangedHandler(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
||||
@@ -21,8 +21,10 @@ void GenericPad::deviceDisconnected()
|
||||
void GenericPad::initialCycle()
|
||||
{
|
||||
#if _WIN32
|
||||
#if !WINDOWS_STORE
|
||||
const PHIDP_PREPARSED_DATA reportDesc = getReportDescriptor();
|
||||
m_parser.Parse(reportDesc);
|
||||
#endif
|
||||
#else
|
||||
std::vector<uint8_t> reportDesc = getReportDescriptor();
|
||||
m_parser.Parse(reportDesc.data(), reportDesc.size());
|
||||
|
||||
30
lib/inputdev/HIDDeviceUWP.cpp
Normal file
30
lib/inputdev/HIDDeviceUWP.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS 1 /* STFU MSVC */
|
||||
#include "IHIDDevice.hpp"
|
||||
#include "boo/inputdev/DeviceToken.hpp"
|
||||
#include "boo/inputdev/DeviceBase.hpp"
|
||||
|
||||
namespace boo
|
||||
{
|
||||
|
||||
class HIDDeviceUWP : public IHIDDevice
|
||||
{
|
||||
public:
|
||||
HIDDeviceUWP(DeviceToken& token, const std::shared_ptr<DeviceBase>& devImp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void _deviceDisconnected() {}
|
||||
bool _sendUSBInterruptTransfer(const uint8_t* data, size_t length) { return false; }
|
||||
size_t _receiveUSBInterruptTransfer(uint8_t* data, size_t length) { return 0; }
|
||||
bool _sendHIDReport(const uint8_t* data, size_t length, HIDReportType tp, uint32_t message) { return false; }
|
||||
size_t _receiveHIDReport(uint8_t* data, size_t length, HIDReportType tp, uint32_t message) { return false; }
|
||||
void _startThread() {}
|
||||
};
|
||||
|
||||
std::shared_ptr<IHIDDevice> IHIDDeviceNew(DeviceToken& token, const std::shared_ptr<DeviceBase>& devImp)
|
||||
{
|
||||
return std::make_shared<HIDDeviceUWP>(token, devImp);
|
||||
}
|
||||
|
||||
}
|
||||
26
lib/inputdev/HIDListenerUWP.cpp
Normal file
26
lib/inputdev/HIDListenerUWP.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS 1 /* STFU MSVC */
|
||||
#include "boo/inputdev/IHIDListener.hpp"
|
||||
#include "boo/inputdev/DeviceFinder.hpp"
|
||||
|
||||
namespace boo
|
||||
{
|
||||
|
||||
class HIDListenerUWP : public IHIDListener
|
||||
{
|
||||
public:
|
||||
HIDListenerUWP(DeviceFinder& finder) {}
|
||||
|
||||
/* Automatic device scanning */
|
||||
bool startScanning() { return false; }
|
||||
bool stopScanning() { return false; }
|
||||
|
||||
/* Manual device scanning */
|
||||
bool scanNow() { return false; }
|
||||
};
|
||||
|
||||
std::unique_ptr<IHIDListener> IHIDListenerNew(DeviceFinder& finder)
|
||||
{
|
||||
return std::make_unique<HIDListenerUWP>(finder);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -396,6 +396,7 @@ struct HIDReports
|
||||
};
|
||||
|
||||
#if _WIN32
|
||||
#if !WINDOWS_STORE
|
||||
HIDParser::ParserStatus HIDParser::Parse(const PHIDP_PREPARSED_DATA descriptorData)
|
||||
{
|
||||
/* User mode HID report descriptor isn't available on Win32.
|
||||
@@ -475,6 +476,7 @@ HIDParser::ParserStatus HIDParser::Parse(const PHIDP_PREPARSED_DATA descriptorDa
|
||||
m_status = ParserStatus::Done;
|
||||
return ParserStatus::Done;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
|
||||
HIDParser::ParserStatus
|
||||
@@ -721,6 +723,7 @@ std::pair<HIDUsagePage, HIDUsage> HIDParser::GetApplicationUsage(const uint8_t*
|
||||
#if _WIN32
|
||||
void HIDParser::EnumerateValues(const std::function<bool(const HIDMainItem& item)>& valueCB) const
|
||||
{
|
||||
#if !WINDOWS_STORE
|
||||
if (m_status != ParserStatus::Done)
|
||||
return;
|
||||
|
||||
@@ -731,6 +734,7 @@ void HIDParser::EnumerateValues(const std::function<bool(const HIDMainItem& item
|
||||
if (!valueCB(item))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
void HIDParser::EnumerateValues(const std::function<bool(const HIDMainItem& item)>& valueCB) const
|
||||
@@ -757,6 +761,7 @@ void HIDParser::EnumerateValues(const std::function<bool(const HIDMainItem& item
|
||||
void HIDParser::ScanValues(const std::function<bool(const HIDMainItem& item, int32_t value)>& valueCB,
|
||||
const uint8_t* data, size_t len) const
|
||||
{
|
||||
#if !WINDOWS_STORE
|
||||
if (m_status != ParserStatus::Done)
|
||||
return;
|
||||
|
||||
@@ -786,6 +791,7 @@ void HIDParser::ScanValues(const std::function<bool(const HIDMainItem& item, int
|
||||
return;
|
||||
++idx;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
|
||||
|
||||
@@ -20,7 +20,9 @@ class IHIDDevice : public std::enable_shared_from_this<IHIDDevice>
|
||||
virtual bool _sendUSBInterruptTransfer(const uint8_t* data, size_t length)=0;
|
||||
virtual size_t _receiveUSBInterruptTransfer(uint8_t* data, size_t length)=0;
|
||||
#if _WIN32
|
||||
#if !WINDOWS_STORE
|
||||
virtual const PHIDP_PREPARSED_DATA _getReportDescriptor()=0;
|
||||
#endif
|
||||
#else
|
||||
virtual std::vector<uint8_t> _getReportDescriptor()=0;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user