UWP support

This commit is contained in:
Jack Andersen 2017-12-05 17:20:59 -10:00
parent 598bce028b
commit f228f23661
23 changed files with 360 additions and 162 deletions

View File

@ -37,6 +37,7 @@ if(NOT GEKKO AND NOT CAFE AND NOT WINDOWS_STORE)
list(APPEND PLAT_SRCS list(APPEND PLAT_SRCS
lib/graphicsdev/GL.cpp lib/graphicsdev/GL.cpp
lib/graphicsdev/glew.c) lib/graphicsdev/glew.c)
list(APPEND _BOO_SYS_DEFINES -DBOO_HAS_GL=1)
list(APPEND PLAT_HDRS list(APPEND PLAT_HDRS
include/boo/graphicsdev/GLSLMacros.hpp include/boo/graphicsdev/GLSLMacros.hpp
@ -53,8 +54,8 @@ if(WINDOWS_STORE)
lib/win/WindowUWP.cpp lib/win/WindowUWP.cpp
lib/win/WinCommon.hpp lib/win/WinCommon.hpp
lib/win/UWPCommon.hpp lib/win/UWPCommon.hpp
lib/inputdev/HIDListenerWinUSB.cpp lib/inputdev/HIDListenerUWP.cpp
lib/inputdev/HIDDeviceWinUSB.cpp lib/inputdev/HIDDeviceUWP.cpp
lib/graphicsdev/D3D11.cpp lib/graphicsdev/D3D11.cpp
lib/graphicsdev/D3D12.cpp lib/graphicsdev/D3D12.cpp
lib/audiodev/WASAPI.cpp) lib/audiodev/WASAPI.cpp)

View File

@ -81,11 +81,12 @@ ApplicationRun(IApplication::EPlatformType platform,
return ApplicationRun(platform, cb, uniqueName, friendlyName, argv[0], args, singleInstance); return ApplicationRun(platform, cb, uniqueName, friendlyName, argv[0], args, singleInstance);
} }
#if WINAPI_FAMILY && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP #if WINDOWS_STORE
using namespace Windows::ApplicationModel::Core; using namespace Windows::ApplicationModel::Core;
ref struct ViewProvider sealed : IFrameworkViewSource ref struct ViewProvider sealed : IFrameworkViewSource
{ {
internal:
ViewProvider(boo::IApplicationCallback& appCb, ViewProvider(boo::IApplicationCallback& appCb,
SystemStringView uniqueName, SystemStringView uniqueName,
SystemStringView friendlyName, SystemStringView friendlyName,
@ -97,13 +98,15 @@ ref struct ViewProvider sealed : IFrameworkViewSource
{ {
SystemChar selfPath[1024]; SystemChar selfPath[1024];
GetModuleFileNameW(nullptr, selfPath, 1024); GetModuleFileNameW(nullptr, selfPath, 1024);
m_args.reserve(params.size() + 1); m_args.reserve(params->Length + 1);
m_args.emplace_back(selfPath); m_args.emplace_back(selfPath);
for (Platform::String^ str : params) for (Platform::String^ str : params)
m_args.emplace_back(str.Data()); m_args.emplace_back(str->Data());
} }
IFrameworkView^ CreateView(); public:
virtual IFrameworkView^ CreateView();
internal:
boo::IApplicationCallback& m_appCb; boo::IApplicationCallback& m_appCb;
SystemString m_uniqueName; SystemString m_uniqueName;
SystemString m_friendlyName; SystemString m_friendlyName;

View File

@ -2,6 +2,13 @@
#define BOO_SYSTEM_HPP #define BOO_SYSTEM_HPP
#ifdef _WIN32 #ifdef _WIN32
#include <winapifamily.h>
#if defined(WINAPI_FAMILY) && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP
#define WINDOWS_STORE 1
#else
#define WINDOWS_STORE 0
#endif
#include <windows.h> #include <windows.h>
#include <D3Dcommon.h> #include <D3Dcommon.h>
#include <wrl/client.h> #include <wrl/client.h>

View File

@ -1,5 +1,6 @@
#ifndef GDEV_GL_HPP #ifndef GDEV_GL_HPP
#define GDEV_GL_HPP #define GDEV_GL_HPP
#if BOO_HAS_GL
#include "IGraphicsDataFactory.hpp" #include "IGraphicsDataFactory.hpp"
#include "IGraphicsCommandQueue.hpp" #include "IGraphicsCommandQueue.hpp"
@ -62,4 +63,5 @@ public:
} }
#endif
#endif // GDEV_GL_HPP #endif // GDEV_GL_HPP

View File

@ -52,7 +52,9 @@ public:
/* High-Level API */ /* High-Level API */
#if _WIN32 #if _WIN32
#if !WINDOWS_STORE
const PHIDP_PREPARSED_DATA getReportDescriptor(); const PHIDP_PREPARSED_DATA getReportDescriptor();
#endif
#else #else
std::vector<uint8_t> getReportDescriptor(); std::vector<uint8_t> getReportDescriptor();
#endif #endif

View File

@ -181,9 +181,11 @@ private:
ParserStatus m_status = ParserStatus::OK; ParserStatus m_status = ParserStatus::OK;
#if _WIN32 #if _WIN32
#if !WINDOWS_STORE
std::vector<HIDMainItem> m_itemPool; std::vector<HIDMainItem> m_itemPool;
mutable std::vector<HIDP_DATA> m_dataList; mutable std::vector<HIDP_DATA> m_dataList;
PHIDP_PREPARSED_DATA m_descriptorData = nullptr; PHIDP_PREPARSED_DATA m_descriptorData = nullptr;
#endif
#else #else
std::unique_ptr<HIDMainItem[]> m_itemPool; std::unique_ptr<HIDMainItem[]> m_itemPool;
using Report = std::pair<uint32_t, std::pair<uint32_t, uint32_t>>; using Report = std::pair<uint32_t, std::pair<uint32_t, uint32_t>>;
@ -201,7 +203,9 @@ private:
public: public:
#if _WIN32 #if _WIN32
#if !WINDOWS_STORE
ParserStatus Parse(const PHIDP_PREPARSED_DATA descriptorData); ParserStatus Parse(const PHIDP_PREPARSED_DATA descriptorData);
#endif
#else #else
ParserStatus Parse(const uint8_t* descriptorData, size_t len); ParserStatus Parse(const uint8_t* descriptorData, size_t len);
static size_t CalculateMaxInputReportSize(const uint8_t* descriptorData, size_t len); static size_t CalculateMaxInputReportSize(const uint8_t* descriptorData, size_t len);

View File

@ -15,7 +15,7 @@ class DeviceFinder;
class IHIDListener class IHIDListener
{ {
public: public:
virtual ~IHIDListener() {} virtual ~IHIDListener() = default;
/* Automatic device scanning */ /* Automatic device scanning */
virtual bool startScanning()=0; virtual bool startScanning()=0;
@ -24,7 +24,7 @@ public:
/* Manual device scanning */ /* Manual device scanning */
virtual bool scanNow()=0; virtual bool scanNow()=0;
#if _WIN32 #if _WIN32 && !WINDOWS_STORE
/* External listener implementation (for Windows) */ /* External listener implementation (for Windows) */
virtual bool _extDevConnect(const char* path)=0; virtual bool _extDevConnect(const char* path)=0;
virtual bool _extDevDisconnect(const char* path)=0; virtual bool _extDevDisconnect(const char* path)=0;

View File

@ -8,8 +8,12 @@
#include <iterator> #include <iterator>
#if !WINDOWS_STORE
const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator); const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator); const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
#else
using namespace Windows::Media::Devices;
#endif
const IID IID_IAudioClient = __uuidof(IAudioClient); const IID IID_IAudioClient = __uuidof(IAudioClient);
const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient); const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient);
@ -23,14 +27,17 @@ static logvisor::Module Log("boo::WASAPI");
struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine
{ {
#if !WINDOWS_STORE
ComPtr<IMMDeviceEnumerator> m_enumerator; ComPtr<IMMDeviceEnumerator> m_enumerator;
ComPtr<IMMDevice> m_device; ComPtr<IMMDevice> m_device;
#endif
ComPtr<IAudioClient> m_audClient; ComPtr<IAudioClient> m_audClient;
ComPtr<IAudioRenderClient> m_renderClient; ComPtr<IAudioRenderClient> m_renderClient;
size_t m_curBufFrame = 0; size_t m_curBufFrame = 0;
std::vector<float> m_5msBuffer; std::vector<float> m_5msBuffer;
#if !WINDOWS_STORE
struct NotificationClient : public IMMNotificationClient struct NotificationClient : public IMMNotificationClient
{ {
WASAPIAudioVoiceEngine& m_parent; WASAPIAudioVoiceEngine& m_parent;
@ -122,9 +129,11 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine
return S_OK; return S_OK;
} }
} m_notificationClient; } m_notificationClient;
#endif
void _buildAudioRenderClient() void _buildAudioRenderClient()
{ {
#if !WINDOWS_STORE
if (FAILED(m_enumerator->GetDefaultAudioEndpoint(eRender, eConsole, &m_device))) if (FAILED(m_enumerator->GetDefaultAudioEndpoint(eRender, eConsole, &m_device)))
{ {
Log.report(logvisor::Fatal, L"unable to obtain default audio device"); Log.report(logvisor::Fatal, L"unable to obtain default audio device");
@ -138,12 +147,15 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine
m_device.Reset(); m_device.Reset();
return; return;
} }
#endif
WAVEFORMATEXTENSIBLE* pwfx; WAVEFORMATEXTENSIBLE* pwfx;
if (FAILED(m_audClient->GetMixFormat((WAVEFORMATEX**)&pwfx))) if (FAILED(m_audClient->GetMixFormat((WAVEFORMATEX**)&pwfx)))
{ {
Log.report(logvisor::Fatal, L"unable to obtain audio mix format from device"); Log.report(logvisor::Fatal, L"unable to obtain audio mix format from device");
#if !WINDOWS_STORE
m_device.Reset(); m_device.Reset();
#endif
return; return;
} }
@ -226,7 +238,9 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine
nullptr))) nullptr)))
{ {
Log.report(logvisor::Fatal, L"unable to initialize audio client"); Log.report(logvisor::Fatal, L"unable to initialize audio client");
#if !WINDOWS_STORE
m_device.Reset(); m_device.Reset();
#endif
CoTaskMemFree(pwfx); CoTaskMemFree(pwfx);
return; return;
} }
@ -251,7 +265,9 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine
else else
{ {
Log.report(logvisor::Fatal, L"unsupported bits-per-sample %d", pwfx->Format.wBitsPerSample); Log.report(logvisor::Fatal, L"unsupported bits-per-sample %d", pwfx->Format.wBitsPerSample);
#if !WINDOWS_STORE
m_device.Reset(); m_device.Reset();
#endif
return; return;
} }
} }
@ -266,7 +282,9 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine
else else
{ {
Log.report(logvisor::Fatal, L"unsupported floating-point bits-per-sample %d", pwfx->Format.wBitsPerSample); Log.report(logvisor::Fatal, L"unsupported floating-point bits-per-sample %d", pwfx->Format.wBitsPerSample);
#if !WINDOWS_STORE
m_device.Reset(); m_device.Reset();
#endif
return; return;
} }
} }
@ -277,7 +295,9 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine
if (FAILED(m_audClient->GetBufferSize(&bufferFrameCount))) if (FAILED(m_audClient->GetBufferSize(&bufferFrameCount)))
{ {
Log.report(logvisor::Fatal, L"unable to get audio buffer frame count"); Log.report(logvisor::Fatal, L"unable to get audio buffer frame count");
#if !WINDOWS_STORE
m_device.Reset(); m_device.Reset();
#endif
return; return;
} }
m_mixInfo.m_periodFrames = bufferFrameCount; m_mixInfo.m_periodFrames = bufferFrameCount;
@ -285,14 +305,78 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine
if (FAILED(m_audClient->GetService(IID_IAudioRenderClient, &m_renderClient))) if (FAILED(m_audClient->GetService(IID_IAudioRenderClient, &m_renderClient)))
{ {
Log.report(logvisor::Fatal, L"unable to create audio render client"); Log.report(logvisor::Fatal, L"unable to create audio render client");
#if !WINDOWS_STORE
m_device.Reset(); m_device.Reset();
#endif
return; return;
} }
} }
WASAPIAudioVoiceEngine() #if WINDOWS_STORE
: m_notificationClient(*this) struct CompletionHandler : IActivateAudioInterfaceCompletionHandler
{ {
WASAPIAudioVoiceEngine& e;
LONG _cRef = 1;
CompletionHandler(WASAPIAudioVoiceEngine& e) : e(e) {}
HRESULT ActivateCompleted(IActivateAudioInterfaceAsyncOperation* operation)
{
return e.ActivateCompleted(operation);
}
ULONG STDMETHODCALLTYPE AddRef()
{
return InterlockedIncrement(&_cRef);
}
ULONG STDMETHODCALLTYPE Release()
{
ULONG ulRef = InterlockedDecrement(&_cRef);
if (0 == ulRef)
{
delete this;
}
return ulRef;
}
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid, VOID **ppvInterface)
{
if (IID_IUnknown == riid)
{
AddRef();
*ppvInterface = (IUnknown*)this;
}
else if (__uuidof(IActivateAudioInterfaceCompletionHandler) == riid)
{
AddRef();
*ppvInterface = (IActivateAudioInterfaceCompletionHandler*)this;
}
else
{
*ppvInterface = NULL;
return E_NOINTERFACE;
}
return S_OK;
}
} m_completion = {*this};
HRESULT ActivateCompleted(IActivateAudioInterfaceAsyncOperation* operation)
{
ComPtr<IUnknown> punkAudioInterface;
HRESULT hrActivateResult;
operation->GetActivateResult(&hrActivateResult, &punkAudioInterface);
punkAudioInterface.As<IAudioClient>(&m_audClient);
_buildAudioRenderClient();
return ERROR_SUCCESS;
}
#endif
WASAPIAudioVoiceEngine()
#if !WINDOWS_STORE
: m_notificationClient(*this)
#endif
{
#if !WINDOWS_STORE
/* Enumerate default audio device */ /* Enumerate default audio device */
if (FAILED(CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, if (FAILED(CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr,
CLSCTX_ALL, IID_IMMDeviceEnumerator, CLSCTX_ALL, IID_IMMDeviceEnumerator,
@ -310,6 +394,11 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine
} }
_buildAudioRenderClient(); _buildAudioRenderClient();
#else
auto deviceIdStr = MediaDevice::GetDefaultAudioRenderId(Windows::Media::Devices::AudioDeviceRole::Default);
ComPtr<IActivateAudioInterfaceAsyncOperation> asyncOp;
ActivateAudioInterfaceAsync(deviceIdStr->Data(), __uuidof(IAudioClient3), nullptr, &m_completion, &asyncOp);
#endif
} }
bool m_started = false; bool m_started = false;
@ -411,6 +500,7 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine
} }
} }
#if !WINDOWS_STORE
std::vector<std::pair<std::string, std::string>> enumerateMIDIDevices() const std::vector<std::pair<std::string, std::string>> enumerateMIDIDevices() const
{ {
std::vector<std::pair<std::string, std::string>> ret; std::vector<std::pair<std::string, std::string>> ret;
@ -681,13 +771,53 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine
} }
bool useMIDILock() const {return true;} bool useMIDILock() const {return true;}
#else
std::vector<std::pair<std::string, std::string>> enumerateMIDIDevices() const
{
return {};
}
std::unique_ptr<IMIDIIn> newVirtualMIDIIn(ReceiveFunctor&& receiver)
{
return {};
}
std::unique_ptr<IMIDIOut> newVirtualMIDIOut()
{
return {};
}
std::unique_ptr<IMIDIInOut> newVirtualMIDIInOut(ReceiveFunctor&& receiver)
{
return {};
}
std::unique_ptr<IMIDIIn> newRealMIDIIn(const char* name, ReceiveFunctor&& receiver)
{
return {};
}
std::unique_ptr<IMIDIOut> newRealMIDIOut(const char* name)
{
return {};
}
std::unique_ptr<IMIDIInOut> newRealMIDIInOut(const char* name, ReceiveFunctor&& receiver)
{
return {};
}
bool useMIDILock() const {return false;}
#endif
}; };
std::unique_ptr<IAudioVoiceEngine> NewAudioVoiceEngine() std::unique_ptr<IAudioVoiceEngine> NewAudioVoiceEngine()
{ {
std::unique_ptr<IAudioVoiceEngine> ret = std::make_unique<WASAPIAudioVoiceEngine>(); std::unique_ptr<IAudioVoiceEngine> ret = std::make_unique<WASAPIAudioVoiceEngine>();
#if !WINDOWS_STORE
if (!static_cast<WASAPIAudioVoiceEngine&>(*ret).m_device) if (!static_cast<WASAPIAudioVoiceEngine&>(*ret).m_device)
return {}; return {};
#endif
return ret; return ret;
} }

View File

@ -41,7 +41,11 @@ static inline void ThrowIfFailed(HRESULT hr)
if (FAILED(hr)) if (FAILED(hr))
{ {
// Set a breakpoint on this line to catch Win32 API errors. // Set a breakpoint on this line to catch Win32 API errors.
#if !WINDOWS_STORE
_com_error err(hr); _com_error err(hr);
#else
_com_error err(hr, L"D3D11 fail");
#endif
LPCTSTR errMsg = err.ErrorMessage(); LPCTSTR errMsg = err.ErrorMessage();
Log.report(logvisor::Fatal, errMsg); Log.report(logvisor::Fatal, errMsg);
} }

View File

@ -38,7 +38,11 @@ static inline void ThrowIfFailed(HRESULT hr)
if (FAILED(hr)) if (FAILED(hr))
{ {
// Set a breakpoint on this line to catch Win32 API errors. // Set a breakpoint on this line to catch Win32 API errors.
#if !WINDOWS_STORE
_com_error err(hr); _com_error err(hr);
#else
_com_error err(hr, L"D3D12 fail");
#endif
LPCTSTR errMsg = err.ErrorMessage(); LPCTSTR errMsg = err.ErrorMessage();
Log.report(logvisor::Fatal, errMsg); Log.report(logvisor::Fatal, errMsg);
} }

View File

@ -55,12 +55,14 @@ size_t DeviceBase::receiveUSBInterruptTransfer(uint8_t* data, size_t length)
} }
#if _WIN32 #if _WIN32
#if !WINDOWS_STORE
const PHIDP_PREPARSED_DATA DeviceBase::getReportDescriptor() const PHIDP_PREPARSED_DATA DeviceBase::getReportDescriptor()
{ {
if (m_hidDev) if (m_hidDev)
return m_hidDev->_getReportDescriptor(); return m_hidDev->_getReportDescriptor();
return {}; return {};
} }
#endif
#else #else
std::vector<uint8_t> DeviceBase::getReportDescriptor() std::vector<uint8_t> DeviceBase::getReportDescriptor()
{ {

View File

@ -11,7 +11,7 @@ namespace boo
DeviceFinder* DeviceFinder::skDevFinder = nullptr; DeviceFinder* DeviceFinder::skDevFinder = nullptr;
#if _WIN32 #if _WIN32 && !WINDOWS_STORE
/* Windows-specific WM_DEVICECHANGED handler */ /* Windows-specific WM_DEVICECHANGED handler */
LRESULT DeviceFinder::winDevChangedHandler(WPARAM wParam, LPARAM lParam) LRESULT DeviceFinder::winDevChangedHandler(WPARAM wParam, LPARAM lParam)
{ {

View File

@ -21,8 +21,10 @@ void GenericPad::deviceDisconnected()
void GenericPad::initialCycle() void GenericPad::initialCycle()
{ {
#if _WIN32 #if _WIN32
#if !WINDOWS_STORE
const PHIDP_PREPARSED_DATA reportDesc = getReportDescriptor(); const PHIDP_PREPARSED_DATA reportDesc = getReportDescriptor();
m_parser.Parse(reportDesc); m_parser.Parse(reportDesc);
#endif
#else #else
std::vector<uint8_t> reportDesc = getReportDescriptor(); std::vector<uint8_t> reportDesc = getReportDescriptor();
m_parser.Parse(reportDesc.data(), reportDesc.size()); m_parser.Parse(reportDesc.data(), reportDesc.size());

View 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);
}
}

View 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);
}
}

View File

@ -396,6 +396,7 @@ struct HIDReports
}; };
#if _WIN32 #if _WIN32
#if !WINDOWS_STORE
HIDParser::ParserStatus HIDParser::Parse(const PHIDP_PREPARSED_DATA descriptorData) HIDParser::ParserStatus HIDParser::Parse(const PHIDP_PREPARSED_DATA descriptorData)
{ {
/* User mode HID report descriptor isn't available on Win32. /* 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; m_status = ParserStatus::Done;
return ParserStatus::Done; return ParserStatus::Done;
} }
#endif
#else #else
HIDParser::ParserStatus HIDParser::ParserStatus
@ -721,6 +723,7 @@ std::pair<HIDUsagePage, HIDUsage> HIDParser::GetApplicationUsage(const uint8_t*
#if _WIN32 #if _WIN32
void HIDParser::EnumerateValues(const std::function<bool(const HIDMainItem& item)>& valueCB) const void HIDParser::EnumerateValues(const std::function<bool(const HIDMainItem& item)>& valueCB) const
{ {
#if !WINDOWS_STORE
if (m_status != ParserStatus::Done) if (m_status != ParserStatus::Done)
return; return;
@ -731,6 +734,7 @@ void HIDParser::EnumerateValues(const std::function<bool(const HIDMainItem& item
if (!valueCB(item)) if (!valueCB(item))
return; return;
} }
#endif
} }
#else #else
void HIDParser::EnumerateValues(const std::function<bool(const HIDMainItem& item)>& valueCB) const 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, void HIDParser::ScanValues(const std::function<bool(const HIDMainItem& item, int32_t value)>& valueCB,
const uint8_t* data, size_t len) const const uint8_t* data, size_t len) const
{ {
#if !WINDOWS_STORE
if (m_status != ParserStatus::Done) if (m_status != ParserStatus::Done)
return; return;
@ -786,6 +791,7 @@ void HIDParser::ScanValues(const std::function<bool(const HIDMainItem& item, int
return; return;
++idx; ++idx;
} }
#endif
} }
#else #else

View File

@ -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 bool _sendUSBInterruptTransfer(const uint8_t* data, size_t length)=0;
virtual size_t _receiveUSBInterruptTransfer(uint8_t* data, size_t length)=0; virtual size_t _receiveUSBInterruptTransfer(uint8_t* data, size_t length)=0;
#if _WIN32 #if _WIN32
#if !WINDOWS_STORE
virtual const PHIDP_PREPARSED_DATA _getReportDescriptor()=0; virtual const PHIDP_PREPARSED_DATA _getReportDescriptor()=0;
#endif
#else #else
virtual std::vector<uint8_t> _getReportDescriptor()=0; virtual std::vector<uint8_t> _getReportDescriptor()=0;
#endif #endif

View File

@ -25,30 +25,9 @@ pD3DCreateBlob D3DCreateBlobPROC = nullptr;
static bool FindBestD3DCompile() static bool FindBestD3DCompile()
{ {
HMODULE d3dCompilelib = LoadLibraryW(L"D3DCompiler_47.dll"); D3DCompilePROC = D3DCompile;
if (!d3dCompilelib) D3DCreateBlobPROC = D3DCreateBlob;
{
d3dCompilelib = LoadLibraryW(L"D3DCompiler_46.dll");
if (!d3dCompilelib)
{
d3dCompilelib = LoadLibraryW(L"D3DCompiler_45.dll");
if (!d3dCompilelib)
{
d3dCompilelib = LoadLibraryW(L"D3DCompiler_44.dll");
if (!d3dCompilelib)
{
d3dCompilelib = LoadLibraryW(L"D3DCompiler_43.dll");
}
}
}
}
if (d3dCompilelib)
{
D3DCompilePROC = (pD3DCompile)GetProcAddress(d3dCompilelib, "D3DCompile");
D3DCreateBlobPROC = (pD3DCreateBlob)GetProcAddress(d3dCompilelib, "D3DCreateBlob");
return D3DCompilePROC != nullptr && D3DCreateBlobPROC != nullptr; return D3DCompilePROC != nullptr && D3DCreateBlobPROC != nullptr;
}
return false;
} }
namespace boo namespace boo
@ -91,14 +70,8 @@ public:
m_args(args), m_args(args),
m_singleInstance(singleInstance) m_singleInstance(singleInstance)
{ {
HMODULE dxgilib = LoadLibraryW(L"dxgi.dll");
if (!dxgilib)
Log.report(logvisor::Fatal, "unable to load dxgi.dll");
typedef HRESULT(WINAPI*CreateDXGIFactory1PROC)(REFIID riid, _COM_Outptr_ void **ppFactory); typedef HRESULT(WINAPI*CreateDXGIFactory1PROC)(REFIID riid, _COM_Outptr_ void **ppFactory);
CreateDXGIFactory1PROC MyCreateDXGIFactory1 = (CreateDXGIFactory1PROC)GetProcAddress(dxgilib, "CreateDXGIFactory1"); CreateDXGIFactory1PROC MyCreateDXGIFactory1 = CreateDXGIFactory1;
if (!MyCreateDXGIFactory1)
Log.report(logvisor::Fatal, "unable to find CreateDXGIFactory1 in DXGI.dll\n");
bool no12 = false; bool no12 = false;
for (const SystemString& arg : args) for (const SystemString& arg : args)
@ -106,30 +79,15 @@ public:
no12 = true; no12 = true;
#if _WIN32_WINNT_WIN10 #if _WIN32_WINNT_WIN10
HMODULE d3d12lib = LoadLibraryW(L"D3D12.dll"); if (!no12)
if (!no12 && d3d12lib)
{ {
#if _DEBUG
{
PFN_D3D12_GET_DEBUG_INTERFACE MyD3D12GetDebugInterface =
(PFN_D3D12_GET_DEBUG_INTERFACE)GetProcAddress(d3d12lib, "D3D12GetDebugInterface");
ComPtr<ID3D12Debug> debugController;
if (SUCCEEDED(MyD3D12GetDebugInterface(IID_PPV_ARGS(&debugController))))
{
debugController->EnableDebugLayer();
}
}
#endif
if (!FindBestD3DCompile()) if (!FindBestD3DCompile())
Log.report(logvisor::Fatal, "unable to find D3DCompile_[43-47].dll"); Log.report(logvisor::Fatal, "unable to find D3DCompile_[43-47].dll");
D3D12SerializeRootSignaturePROC = D3D12SerializeRootSignaturePROC = D3D12SerializeRootSignature;
(PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)GetProcAddress(d3d12lib, "D3D12SerializeRootSignature");
/* Create device */ /* Create device */
PFN_D3D12_CREATE_DEVICE MyD3D12CreateDevice = (PFN_D3D12_CREATE_DEVICE)GetProcAddress(d3d12lib, "D3D12CreateDevice"); PFN_D3D12_CREATE_DEVICE MyD3D12CreateDevice = D3D12CreateDevice;
if (!MyD3D12CreateDevice)
Log.report(logvisor::Fatal, "unable to find D3D12CreateDevice in D3D12.dll");
/* Obtain DXGI Factory */ /* Obtain DXGI Factory */
HRESULT hr = MyCreateDXGIFactory1(__uuidof(IDXGIFactory2), &m_3dCtx.m_ctx12.m_dxFactory); HRESULT hr = MyCreateDXGIFactory1(__uuidof(IDXGIFactory2), &m_3dCtx.m_ctx12.m_dxFactory);
@ -191,16 +149,12 @@ public:
} }
} }
#endif #endif
HMODULE d3d11lib = LoadLibraryW(L"D3D11.dll");
if (d3d11lib)
{ {
if (!FindBestD3DCompile()) if (!FindBestD3DCompile())
Log.report(logvisor::Fatal, "unable to find D3DCompile_[43-47].dll"); Log.report(logvisor::Fatal, "unable to find D3DCompile_[43-47].dll");
/* Create device proc */ /* Create device proc */
PFN_D3D11_CREATE_DEVICE MyD3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE)GetProcAddress(d3d11lib, "D3D11CreateDevice"); PFN_D3D11_CREATE_DEVICE MyD3D11CreateDevice = D3D11CreateDevice;
if (!MyD3D11CreateDevice)
Log.report(logvisor::Fatal, "unable to find D3D11CreateDevice in D3D11.dll");
/* Create device */ /* Create device */
D3D_FEATURE_LEVEL level = D3D_FEATURE_LEVEL_11_0; D3D_FEATURE_LEVEL level = D3D_FEATURE_LEVEL_11_0;
@ -215,9 +169,6 @@ public:
FAILED(tempCtx.As<ID3D11DeviceContext1>(&m_3dCtx.m_ctx11.m_devCtx)) || !m_3dCtx.m_ctx11.m_devCtx || FAILED(tempCtx.As<ID3D11DeviceContext1>(&m_3dCtx.m_ctx11.m_devCtx)) || !m_3dCtx.m_ctx11.m_devCtx ||
FAILED(m_3dCtx.m_ctx11.m_dev.As<IDXGIDevice2>(&device)) || !device) FAILED(m_3dCtx.m_ctx11.m_dev.As<IDXGIDevice2>(&device)) || !device)
{ {
MessageBoxW(nullptr, L"Windows 7 users should install 'Platform Update for Windows 7':\n"
L"https://www.microsoft.com/en-us/download/details.aspx?id=36805",
L"IDXGIDevice2 interface error", MB_OK | MB_ICONERROR);
exit(1); exit(1);
} }
@ -256,7 +207,7 @@ public:
int clientReturn = 0; int clientReturn = 0;
std::thread clientThread([&]() std::thread clientThread([&]()
{ {
std::string thrName = WCSTMBS(getFriendlyName().c_str()) + " Client Thread"; std::string thrName = WCSTMBS(getFriendlyName().data()) + " Client Thread";
logvisor::RegisterThreadName(thrName.c_str()); logvisor::RegisterThreadName(thrName.c_str());
clientReturn = m_callback.appMain(this); clientReturn = m_callback.appMain(this);
}); });

View File

@ -3,8 +3,6 @@
#include "WinCommon.hpp" #include "WinCommon.hpp"
using namespace Windows::ApplicationModel::Core;
struct Boo3DAppContextUWP : Boo3DAppContext struct Boo3DAppContextUWP : Boo3DAppContext
{ {
bool isFullscreen(const boo::IWindow* window) bool isFullscreen(const boo::IWindow* window)

View File

@ -16,7 +16,7 @@
extern DWORD g_mainThreadId; extern DWORD g_mainThreadId;
#if _WIN32_WINNT_WINBLUE #if _WIN32_WINNT_WINBLUE && !WINDOWS_STORE
#include <ShellScalingApi.h> #include <ShellScalingApi.h>
typedef HRESULT (WINAPI* PFN_SetProcessDpiAwareness)( _In_ PROCESS_DPI_AWARENESS ); typedef HRESULT (WINAPI* PFN_SetProcessDpiAwareness)( _In_ PROCESS_DPI_AWARENESS );
typedef HRESULT (WINAPI* PFN_GetScaleFactorForMonitor)( _In_ HMONITOR, _Out_ DEVICE_SCALE_FACTOR *); typedef HRESULT (WINAPI* PFN_GetScaleFactorForMonitor)( _In_ HMONITOR, _Out_ DEVICE_SCALE_FACTOR *);
@ -187,12 +187,14 @@ struct Boo3DAppContextWin32 : Boo3DAppContext
return true; return true;
} }
#if !WINDOWS_STORE
OGLContext::Window& win = m_ctxOgl.m_windows[window]; OGLContext::Window& win = m_ctxOgl.m_windows[window];
if (fs && win.m_fs) if (fs && win.m_fs)
return false; return false;
else if (!fs && !win.m_fs) else if (!fs && !win.m_fs)
return false; return false;
SetFullscreen(win, fs); SetFullscreen(win, fs);
#endif
return true; return true;
} }
}; };

View File

@ -8,7 +8,10 @@
#include "boo/audiodev/IAudioVoiceEngine.hpp" #include "boo/audiodev/IAudioVoiceEngine.hpp"
using namespace Windows::UI::Core; using namespace Windows::UI::Core;
using namespace Windows::UI::ViewManagement;
using namespace Windows::System; using namespace Windows::System;
using namespace Windows::Graphics::Display;
using namespace Windows::Foundation;
namespace boo namespace boo
{ {
@ -178,67 +181,59 @@ public:
} }
}; };
static void genFrameDefault(MONITORINFO* screen, int& xOut, int& yOut, int& wOut, int& hOut) static uint32_t translateKeysym(CoreWindow^ window, VirtualKey sym,
{ ESpecialKey& specialSym, EModifierKey& modifierSym)
float width = screen->rcMonitor.right * 2.0 / 3.0;
float height = screen->rcMonitor.bottom * 2.0 / 3.0;
xOut = (screen->rcMonitor.right - width) / 2.0;
yOut = (screen->rcMonitor.bottom - height) / 2.0;
wOut = width;
hOut = height;
}
static uint32_t translateKeysym(VirtualKey sym, ESpecialKey& specialSym, EModifierKey& modifierSym)
{ {
specialSym = ESpecialKey::None; specialSym = ESpecialKey::None;
modifierSym = EModifierKey::None; modifierSym = EModifierKey::None;
if (sym >= VirtualKey_F1 && sym <= VirtualKey_F12) if (sym >= VirtualKey::F1 && sym <= VirtualKey::F12)
specialSym = ESpecialKey(uint32_t(ESpecialKey::F1) + sym - VirtualKey_F1); specialSym = ESpecialKey(uint32_t(ESpecialKey::F1) + uint32_t(sym - VirtualKey::F1));
else if (sym == VirtualKey_Escape) else if (sym == VirtualKey::Escape)
specialSym = ESpecialKey::Esc; specialSym = ESpecialKey::Esc;
else if (sym == VirtualKey_Enter) else if (sym == VirtualKey::Enter)
specialSym = ESpecialKey::Enter; specialSym = ESpecialKey::Enter;
else if (sym == VirtualKey_Back) else if (sym == VirtualKey::Back)
specialSym = ESpecialKey::Backspace; specialSym = ESpecialKey::Backspace;
else if (sym == VirtualKey_Insert) else if (sym == VirtualKey::Insert)
specialSym = ESpecialKey::Insert; specialSym = ESpecialKey::Insert;
else if (sym == VirtualKey_Delete) else if (sym == VirtualKey::Delete)
specialSym = ESpecialKey::Delete; specialSym = ESpecialKey::Delete;
else if (sym == VirtualKey_Home) else if (sym == VirtualKey::Home)
specialSym = ESpecialKey::Home; specialSym = ESpecialKey::Home;
else if (sym == VirtualKey_End) else if (sym == VirtualKey::End)
specialSym = ESpecialKey::End; specialSym = ESpecialKey::End;
else if (sym == VirtualKey_PageUp) else if (sym == VirtualKey::PageUp)
specialSym = ESpecialKey::PgUp; specialSym = ESpecialKey::PgUp;
else if (sym == VirtualKey_PageDown) else if (sym == VirtualKey::PageDown)
specialSym = ESpecialKey::PgDown; specialSym = ESpecialKey::PgDown;
else if (sym == VirtualKey_Left) else if (sym == VirtualKey::Left)
specialSym = ESpecialKey::Left; specialSym = ESpecialKey::Left;
else if (sym == VirtualKey_Right) else if (sym == VirtualKey::Right)
specialSym = ESpecialKey::Right; specialSym = ESpecialKey::Right;
else if (sym == VirtualKey_Up) else if (sym == VirtualKey::Up)
specialSym = ESpecialKey::Up; specialSym = ESpecialKey::Up;
else if (sym == VirtualKey_Down) else if (sym == VirtualKey::Down)
specialSym = ESpecialKey::Down; specialSym = ESpecialKey::Down;
else if (sym == VirtualKey_Shift) else if (sym == VirtualKey::Shift)
modifierSym = EModifierKey::Shift; modifierSym = EModifierKey::Shift;
else if (sym == VirtualKey_Control) else if (sym == VirtualKey::Control)
modifierSym = EModifierKey::Ctrl; modifierSym = EModifierKey::Ctrl;
else if (sym == VirtualKey_Menu) else if (sym == VirtualKey::Menu)
modifierSym = EModifierKey::Alt; modifierSym = EModifierKey::Alt;
else if (sym >= VirtualKey_A && sym <= VirtualKey_Z) else if (sym >= VirtualKey::A && sym <= VirtualKey::Z)
return sym - VirtualKey_A + window->GetKeyState(VirtualKey_Shift) ? 'A' : 'a' return uint32_t(sym - VirtualKey::A) +
(window->GetKeyState(VirtualKey::Shift) != CoreVirtualKeyStates::None) ? 'A' : 'a';
return 0; return 0;
} }
static EModifierKey translateModifiers(CoreWindow^ window) static EModifierKey translateModifiers(CoreWindow^ window)
{ {
EModifierKey retval = EModifierKey::None; EModifierKey retval = EModifierKey::None;
if (window->GetKeyState(VirtualKey_Shift) != None) if (window->GetKeyState(VirtualKey::Shift) != CoreVirtualKeyStates::None)
retval |= EModifierKey::Shift; retval |= EModifierKey::Shift;
if (window->GetKeyState(VirtualKey_Control) != None) if (window->GetKeyState(VirtualKey::Control) != CoreVirtualKeyStates::None)
retval |= EModifierKey::Ctrl; retval |= EModifierKey::Ctrl;
if (window->GetKeyState(LefVirtualKey_Menu) != None) if (window->GetKeyState(VirtualKey::Menu) != CoreVirtualKeyStates::None)
retval |= EModifierKey::Alt; retval |= EModifierKey::Alt;
return retval; return retval;
} }
@ -253,7 +248,36 @@ class WindowUWP : public IWindow
public: public:
WindowUWP(SystemStringView title, Boo3DAppContext& b3dCtx, uint32_t sampleCount) ref struct EventReceiver sealed
{
void OnKeyDown(CoreWindow^ window, KeyEventArgs^ keyEventArgs)
{
w.OnKeyDown(window, keyEventArgs);
}
void OnKeyUp(CoreWindow^ window, KeyEventArgs^ keyEventArgs)
{
w.OnKeyUp(window, keyEventArgs);
}
void OnClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
{
w.OnClosed(sender, args);
}
internal:
WindowUWP& w;
EventReceiver(WindowUWP& w) : w(w)
{
w.m_coreWindow->KeyDown += ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &EventReceiver::OnKeyDown);
w.m_coreWindow->KeyUp += ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &EventReceiver::OnKeyUp);
w.m_coreWindow->Closed += ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &EventReceiver::OnClosed);
}
};
EventReceiver^ m_eventReceiver;
WindowUWP(SystemStringView title, Boo3DAppContextUWP& b3dCtx, uint32_t sampleCount)
: m_eventReceiver(ref new EventReceiver(*this))
{ {
IGraphicsContext::EGraphicsAPI api = IGraphicsContext::EGraphicsAPI::D3D11; IGraphicsContext::EGraphicsAPI api = IGraphicsContext::EGraphicsAPI::D3D11;
#if _WIN32_WINNT_WIN10 #if _WIN32_WINNT_WIN10
@ -263,9 +287,6 @@ public:
m_gfxCtx.reset(new GraphicsContextUWPD3D(api, this, m_coreWindow, b3dCtx, sampleCount)); m_gfxCtx.reset(new GraphicsContextUWPD3D(api, this, m_coreWindow, b3dCtx, sampleCount));
setTitle(title); setTitle(title);
m_coreWindow->KeyDown += ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &WindowUWP::OnKeyDown);
m_coreWindow->KeyUp += ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &WindowUWP::OnKeyUp);
m_coreWindow->Closed += ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &WindowUWP::OnClosed);
} }
~WindowUWP() ~WindowUWP()
@ -293,12 +314,12 @@ public:
SystemString getTitle() SystemString getTitle()
{ {
return SystemString(m_appView->Title.Data()); return SystemString(m_appView->Title->Data());
} }
void setTitle(SystemStringView title) void setTitle(SystemStringView title)
{ {
m_appView->Title = title.data(); m_appView->Title = ref new Platform::String(title.data());
} }
void setCursor(EMouseCursor cursor) void setCursor(EMouseCursor cursor)
@ -315,18 +336,18 @@ public:
void getWindowFrame(float& xOut, float& yOut, float& wOut, float& hOut) const void getWindowFrame(float& xOut, float& yOut, float& wOut, float& hOut) const
{ {
xOut = m_coreWindow->bounds.X; xOut = m_coreWindow->Bounds.X;
yOut = m_coreWindow->bounds.Y; yOut = m_coreWindow->Bounds.Y;
wOut = m_coreWindow->bounds.Width; wOut = m_coreWindow->Bounds.Width;
hOut = m_coreWindow->bounds.Height; hOut = m_coreWindow->Bounds.Height;
} }
void getWindowFrame(int& xOut, int& yOut, int& wOut, int& hOut) const void getWindowFrame(int& xOut, int& yOut, int& wOut, int& hOut) const
{ {
xOut = m_coreWindow->bounds.X; xOut = m_coreWindow->Bounds.X;
yOut = m_coreWindow->bounds.Y; yOut = m_coreWindow->Bounds.Y;
wOut = m_coreWindow->bounds.Width; wOut = m_coreWindow->Bounds.Width;
hOut = m_coreWindow->bounds.Height; hOut = m_coreWindow->Bounds.Height;
} }
void setWindowFrame(float x, float y, float w, float h) void setWindowFrame(float x, float y, float w, float h)
@ -339,8 +360,8 @@ public:
float getVirtualPixelFactor() const float getVirtualPixelFactor() const
{ {
DisplayInformation dispInfo = DisplayInformation::GetForCurrentView(); DisplayInformation^ dispInfo = DisplayInformation::GetForCurrentView();
return dispInfo.LogicalDpi / 96.f; return dispInfo->LogicalDpi / 96.f;
} }
bool isFullscreen() const bool isFullscreen() const
@ -359,6 +380,7 @@ public:
bool clipboardCopy(EClipboardType type, const uint8_t* data, size_t sz) bool clipboardCopy(EClipboardType type, const uint8_t* data, size_t sz)
{ {
return false;
} }
std::unique_ptr<uint8_t[]> clipboardPaste(EClipboardType type, size_t& sz) std::unique_ptr<uint8_t[]> clipboardPaste(EClipboardType type, size_t& sz)
@ -383,12 +405,10 @@ public:
} }
void OnKeyDown(CoreWindow^ window, KeyEventArgs^ keyEventArgs) void OnKeyDown(CoreWindow^ window, KeyEventArgs^ keyEventArgs)
{
if (auto w = m_window.lock())
{ {
ESpecialKey specialKey; ESpecialKey specialKey;
EModifierKey modifierKey; EModifierKey modifierKey;
uint32_t charCode = translateKeysym(keyEventArgs->VirtualKey, specialKey, modifierKey); uint32_t charCode = translateKeysym(m_coreWindow, keyEventArgs->VirtualKey, specialKey, modifierKey);
EModifierKey modifierMask = translateModifiers(window); EModifierKey modifierMask = translateModifiers(window);
bool repeat = keyEventArgs->KeyStatus.RepeatCount > 1; bool repeat = keyEventArgs->KeyStatus.RepeatCount > 1;
if (charCode) if (charCode)
@ -398,23 +418,19 @@ public:
else if (modifierKey != EModifierKey::None) else if (modifierKey != EModifierKey::None)
m_callback->modKeyDown(modifierKey, repeat); m_callback->modKeyDown(modifierKey, repeat);
} }
}
void OnKeyUp(CoreWindow^ window, KeyEventArgs^ keyEventArgs) void OnKeyUp(CoreWindow^ window, KeyEventArgs^ keyEventArgs)
{
if (auto w = m_window.lock())
{ {
ESpecialKey specialKey; ESpecialKey specialKey;
EModifierKey modifierKey; EModifierKey modifierKey;
uint32_t charCode = translateKeysym(keyEventArgs->VirtualKey, specialKey, modifierKey); uint32_t charCode = translateKeysym(m_coreWindow, keyEventArgs->VirtualKey, specialKey, modifierKey);
EModifierKey modifierMask = translateModifiers(window); EModifierKey modifierMask = translateModifiers(window);
if (charCode) if (charCode)
m_callback->charKeyDown(charCode, modifierMask); m_callback->charKeyUp(charCode, modifierMask);
else if (specialKey != ESpecialKey::None) else if (specialKey != ESpecialKey::None)
m_callback->specialKeyDown(specialKey, modifierMask); m_callback->specialKeyUp(specialKey, modifierMask);
else if (modifierKey != EModifierKey::None) else if (modifierKey != EModifierKey::None)
m_callback->modKeyDown(modifierKey); m_callback->modKeyUp(modifierKey);
}
} }
void OnClosed(CoreWindow ^sender, CoreWindowEventArgs ^args) void OnClosed(CoreWindow ^sender, CoreWindowEventArgs ^args)
@ -459,7 +475,7 @@ public:
}; };
std::shared_ptr<IWindow> _WindowUAPNew(SystemStringView title, Boo3DAppContext& d3dCtx, std::shared_ptr<IWindow> _WindowUWPNew(SystemStringView title, Boo3DAppContextUWP& d3dCtx,
uint32_t sampleCount) uint32_t sampleCount)
{ {
return std::make_shared<WindowUWP>(title, d3dCtx, sampleCount); return std::make_shared<WindowUWP>(title, d3dCtx, sampleCount);

@ -1 +1 @@
Subproject commit 59741b63b88ce6c1135733a326e3cbfaf8d22e0c Subproject commit 408ae926d76128fa23a12607d0a1e0a970ab3554

View File

@ -336,6 +336,7 @@ struct TestApplicationCallback : IApplicationCallback
/* Make shader pipeline */ /* Make shader pipeline */
boo::ObjToken<IShaderPipeline> pipeline; boo::ObjToken<IShaderPipeline> pipeline;
auto plat = ctx.platform(); auto plat = ctx.platform();
#if BOO_HAS_GL
if (plat == IGraphicsDataFactory::Platform::OpenGL) if (plat == IGraphicsDataFactory::Platform::OpenGL)
{ {
GLDataFactory::Context& glF = dynamic_cast<GLDataFactory::Context&>(ctx); GLDataFactory::Context& glF = dynamic_cast<GLDataFactory::Context&>(ctx);
@ -369,9 +370,10 @@ struct TestApplicationCallback : IApplicationCallback
BlendFactor::One, BlendFactor::Zero, BlendFactor::One, BlendFactor::Zero,
Primitive::TriStrips, boo::ZTest::LEqual, Primitive::TriStrips, boo::ZTest::LEqual,
true, true, false, CullMode::None); true, true, false, CullMode::None);
} } else
#endif
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
else if (plat == IGraphicsDataFactory::Platform::Vulkan) if (plat == IGraphicsDataFactory::Platform::Vulkan)
{ {
VulkanDataFactory::Context& vkF = dynamic_cast<VulkanDataFactory::Context&>(ctx); VulkanDataFactory::Context& vkF = dynamic_cast<VulkanDataFactory::Context&>(ctx);
@ -402,10 +404,10 @@ struct TestApplicationCallback : IApplicationCallback
pipeline = vkF.newShaderPipeline(VS, FS, vfmt, BlendFactor::One, BlendFactor::Zero, pipeline = vkF.newShaderPipeline(VS, FS, vfmt, BlendFactor::One, BlendFactor::Zero,
Primitive::TriStrips, boo::ZTest::LEqual, Primitive::TriStrips, boo::ZTest::LEqual,
true, true, false, CullMode::None); true, true, false, CullMode::None);
} } else
#endif #endif
#if _WIN32 #if _WIN32
else if (plat == IGraphicsDataFactory::Platform::D3D12 || if (plat == IGraphicsDataFactory::Platform::D3D12 ||
plat == IGraphicsDataFactory::Platform::D3D11) plat == IGraphicsDataFactory::Platform::D3D11)
{ {
ID3DDataFactory::Context& d3dF = dynamic_cast<ID3DDataFactory::Context&>(ctx); ID3DDataFactory::Context& d3dF = dynamic_cast<ID3DDataFactory::Context&>(ctx);
@ -434,9 +436,9 @@ struct TestApplicationCallback : IApplicationCallback
BlendFactor::One, BlendFactor::Zero, BlendFactor::One, BlendFactor::Zero,
Primitive::TriStrips, boo::ZTest::LEqual, Primitive::TriStrips, boo::ZTest::LEqual,
true, true, false, CullMode::None); true, true, false, CullMode::None);
} } else
#elif BOO_HAS_METAL #elif BOO_HAS_METAL
else if (plat == IGraphicsDataFactory::Platform::Metal) if (plat == IGraphicsDataFactory::Platform::Metal)
{ {
MetalDataFactory::Context& metalF = dynamic_cast<MetalDataFactory::Context&>(ctx); MetalDataFactory::Context& metalF = dynamic_cast<MetalDataFactory::Context&>(ctx);
@ -466,8 +468,9 @@ struct TestApplicationCallback : IApplicationCallback
pipeline = metalF.newShaderPipeline(VS, FS, nullptr, nullptr, vfmt, 1, pipeline = metalF.newShaderPipeline(VS, FS, nullptr, nullptr, vfmt, 1,
BlendFactor::One, BlendFactor::Zero, Primitive::TriStrips, BlendFactor::One, BlendFactor::Zero, Primitive::TriStrips,
boo::ZTest::LEqual, true, true, true, boo::CullMode::None); boo::ZTest::LEqual, true, true, true, boo::CullMode::None);
} } else
#endif #endif
{}
/* Make shader data binding */ /* Make shader data binding */
self->m_binding = self->m_binding =
@ -581,6 +584,7 @@ struct TestApplicationCallback : IApplicationCallback
} }
#if !WINDOWS_STORE
#if _WIN32 #if _WIN32
int wmain(int argc, const boo::SystemChar** argv) int wmain(int argc, const boo::SystemChar** argv)
#else #else
@ -596,7 +600,7 @@ int main(int argc, const boo::SystemChar** argv)
return ret; return ret;
} }
#if WINAPI_FAMILY && !WINAPI_PARTITION_DESKTOP #else
using namespace Windows::ApplicationModel::Core; using namespace Windows::ApplicationModel::Core;
[Platform::MTAThread] [Platform::MTAThread]
@ -605,12 +609,14 @@ int WINAPIV main(Platform::Array<Platform::String^>^ params)
logvisor::RegisterStandardExceptions(); logvisor::RegisterStandardExceptions();
logvisor::RegisterConsoleLogger(); logvisor::RegisterConsoleLogger();
boo::TestApplicationCallback appCb; boo::TestApplicationCallback appCb;
auto viewProvider = ref new ViewProvider(appCb, _S("boo"), _S("boo"), params, false); boo::ViewProvider^ viewProvider =
ref new boo::ViewProvider(appCb, _S("boo"), _S("boo"), _S("boo"), params, false);
CoreApplication::Run(viewProvider); CoreApplication::Run(viewProvider);
return 0; return 0;
} }
#endif
#elif _WIN32 #if _WIN32 && !WINDOWS_STORE
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int) int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int)
{ {
int argc = 0; int argc = 0;