Permalink
Please
sign in to comment.
Showing
with
125 additions
and 1 deletion.
- +17 −0 support/hololens/ServoApp/BrowserPage.cpp
- +6 −0 support/hololens/ServoApp/BrowserPage.h
- +8 −0 support/hololens/ServoApp/BrowserPage.xaml
- +8 −1 support/hololens/ServoApp/Package.appxmanifest
- +2 −0 support/hololens/ServoApp/ServoApp.vcxproj
- +2 −0 support/hololens/ServoApp/ServoApp.vcxproj.filters
- +52 −0 support/hololens/ServoApp/XRPkgChecker.cpp
- +30 −0 support/hololens/ServoApp/XRPkgChecker.h
@@ -0,0 +1,52 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "pch.h" | ||
#include "XRPkgChecker.h" | ||
#include "logs.h" | ||
#include "winrt/Windows.Management.Deployment.h" | ||
|
||
using namespace winrt::Windows::Management::Deployment; | ||
|
||
namespace winrt { | ||
|
||
void XRPkgChecker::OnInstalled(std::function<void()> callback, | ||
winrt::Windows::Foundation::TimeSpan interval) { | ||
timer.Stop(); | ||
timer.Interval(interval); | ||
installed_callback = std::make_unique<std::function<void()>>(callback); | ||
timer.Tick({this, &XRPkgChecker::CheckXRPkgTick}); | ||
timer.Start(); | ||
} | ||
|
||
void XRPkgChecker::StopTracking() { | ||
installed_callback.reset(); | ||
timer.Stop(); | ||
} | ||
|
||
void XRPkgChecker::CheckXRPkgTick(Windows::Foundation::IInspectable const &, | ||
Windows::Foundation::IInspectable const &) { | ||
if (IsInstalled()) { | ||
(*installed_callback)(); | ||
StopTracking(); | ||
} | ||
} | ||
|
||
void XRPkgChecker::OpenStore() { | ||
std::wstring url = L"ms-windows-store://pdp/?PFN="; | ||
Windows::Foundation::Uri uri{url + OPENXR_PACKAGE_NAME}; | ||
Windows::System::Launcher::LaunchUriAsync(uri); | ||
} | ||
|
||
bool XRPkgChecker::IsInstalled() { | ||
auto current_user = L""; | ||
for (auto package : PackageManager().FindPackagesForUser(current_user)) { | ||
if (package.Id().Name() == OPENXR_PACKAGE_SHORT_NAME) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
} // namespace winrt |
@@ -0,0 +1,30 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#pragma once | ||
|
||
#include "pch.h" | ||
|
||
namespace winrt { | ||
class XRPkgChecker { | ||
|
||
public: | ||
void OnInstalled(std::function<void()> callback, | ||
winrt::Windows::Foundation::TimeSpan interval); | ||
bool IsInstalled(); | ||
void StopTracking(); | ||
void OpenStore(); | ||
|
||
private: | ||
std::unique_ptr<std::function<void()>> installed_callback; | ||
void CheckXRPkgTick(Windows::Foundation::IInspectable const &, | ||
Windows::Foundation::IInspectable const &); | ||
Windows::UI::Xaml::DispatcherTimer timer; | ||
inline static const hstring OPENXR_PACKAGE_NAME = | ||
L"Microsoft.MixedRealityRuntimeDeveloperPreview_8wekyb3d8bbwe"; | ||
inline static const hstring OPENXR_PACKAGE_SHORT_NAME = | ||
L"Microsoft.MixedRealityRuntimeDeveloperPreview"; | ||
}; | ||
|
||
} // namespace winrt |
0 comments on commit
75b522d