mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35:33 +01:00
Prompt user to install OpenXR package if not installed
This commit is contained in:
parent
c060f00535
commit
75b522d210
8 changed files with 125 additions and 1 deletions
52
support/hololens/ServoApp/XRPkgChecker.cpp
Normal file
52
support/hololens/ServoApp/XRPkgChecker.cpp
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue