mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14: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
|
@ -18,6 +18,23 @@ namespace winrt::ServoApp::implementation {
|
||||||
BrowserPage::BrowserPage() {
|
BrowserPage::BrowserPage() {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
BindServoEvents();
|
BindServoEvents();
|
||||||
|
if (!xrPkgChecker.IsInstalled()) {
|
||||||
|
XRPkgWarning().Visibility(Visibility::Visible);
|
||||||
|
xrPkgChecker.OnInstalled(
|
||||||
|
[=] { XRPkgWarning().Visibility(Visibility::Collapsed); },
|
||||||
|
std::chrono::seconds{5});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserPage::OnXRPkgWarningDismissClick(IInspectable const &,
|
||||||
|
RoutedEventArgs const &) {
|
||||||
|
xrPkgChecker.StopTracking();
|
||||||
|
XRPkgWarning().Visibility(Visibility::Collapsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserPage::OnXRPkgWarningInstallClick(IInspectable const &,
|
||||||
|
RoutedEventArgs const &) {
|
||||||
|
xrPkgChecker.OpenStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserPage::BindServoEvents() {
|
void BrowserPage::BindServoEvents() {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BrowserPage.g.h"
|
#include "BrowserPage.g.h"
|
||||||
|
#include "XRPkgChecker.h"
|
||||||
#include "ServoControl\ServoControl.h"
|
#include "ServoControl\ServoControl.h"
|
||||||
|
|
||||||
namespace winrt::ServoApp::implementation {
|
namespace winrt::ServoApp::implementation {
|
||||||
|
@ -34,9 +35,14 @@ public:
|
||||||
void LoadServoURI(Windows::Foundation::Uri uri);
|
void LoadServoURI(Windows::Foundation::Uri uri);
|
||||||
void SetTransientMode(bool);
|
void SetTransientMode(bool);
|
||||||
void SetArgs(hstring);
|
void SetArgs(hstring);
|
||||||
|
void OnXRPkgWarningInstallClick(Windows::Foundation::IInspectable const &,
|
||||||
|
Windows::UI::Xaml::RoutedEventArgs const &);
|
||||||
|
void OnXRPkgWarningDismissClick(Windows::Foundation::IInspectable const &,
|
||||||
|
Windows::UI::Xaml::RoutedEventArgs const &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void BindServoEvents();
|
void BindServoEvents();
|
||||||
|
XRPkgChecker xrPkgChecker;
|
||||||
};
|
};
|
||||||
} // namespace winrt::ServoApp::implementation
|
} // namespace winrt::ServoApp::implementation
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,7 @@
|
||||||
<RowDefinition Height="auto"/>
|
<RowDefinition Height="auto"/>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="auto"/>
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid Grid.Row="0" x:Name="navigationBar" Background="{ThemeResource InkToolbarButtonBackgroundThemeBrush}">
|
<Grid Grid.Row="0" x:Name="navigationBar" Background="{ThemeResource InkToolbarButtonBackgroundThemeBrush}">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
|
@ -126,5 +127,12 @@
|
||||||
</Grid>
|
</Grid>
|
||||||
<local:ServoControl TabIndex="0" x:Name="servoControl" Grid.Row="1"/>
|
<local:ServoControl TabIndex="0" x:Name="servoControl" Grid.Row="1"/>
|
||||||
<ProgressBar x:Name="transientLoadingIndicator" Visibility="Collapsed" Grid.Row="2"/>
|
<ProgressBar x:Name="transientLoadingIndicator" Visibility="Collapsed" Grid.Row="2"/>
|
||||||
|
<StackPanel Grid.Row="2" Background="LightYellow" Padding="10" BorderThickness="0,2,0,0" BorderBrush="Black" x:Name="XRPkgWarning" Visibility="Collapsed">
|
||||||
|
<TextBlock Margin="0,0" VerticalAlignment="Center">The package "Windows OpenXR Developer Preview" is not installed. WebXR pages won't work.</TextBlock>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Button Margin="0,10,10,0" Click="OnXRPkgWarningInstallClick">Install Package</Button>
|
||||||
|
<Button Margin="0,10,10,0" Click="OnXRPkgWarningDismissClick">Dismiss</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5" IgnorableNamespaces="uap mp uap5">
|
<Package
|
||||||
|
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||||
|
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
||||||
|
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||||
|
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
|
||||||
|
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
||||||
|
IgnorableNamespaces="uap mp uap5 rescap">
|
||||||
<Identity Name="1d265729-8836-4bd3-9992-4cb111d1068b" Publisher="CN=Allizom" Version="1.0.0.0" />
|
<Identity Name="1d265729-8836-4bd3-9992-4cb111d1068b" Publisher="CN=Allizom" Version="1.0.0.0" />
|
||||||
<mp:PhoneIdentity PhoneProductId="1d265729-8836-4bd3-9992-4cb111d1068b" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
<mp:PhoneIdentity PhoneProductId="1d265729-8836-4bd3-9992-4cb111d1068b" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
||||||
<Properties>
|
<Properties>
|
||||||
|
@ -44,6 +50,7 @@
|
||||||
</Application>
|
</Application>
|
||||||
</Applications>
|
</Applications>
|
||||||
<Capabilities>
|
<Capabilities>
|
||||||
|
<rescap:Capability Name="packageQuery" />
|
||||||
<Capability Name="internetClient" />
|
<Capability Name="internetClient" />
|
||||||
<Capability Name="codeGeneration" />
|
<Capability Name="codeGeneration" />
|
||||||
<Capability Name="privateNetworkClientServer" />
|
<Capability Name="privateNetworkClientServer" />
|
||||||
|
|
|
@ -133,6 +133,7 @@
|
||||||
<ClInclude Include="ServoControl\Servo.h" />
|
<ClInclude Include="ServoControl\Servo.h" />
|
||||||
<ClInclude Include="ServoControl\ServoControl.h" />
|
<ClInclude Include="ServoControl\ServoControl.h" />
|
||||||
<ClInclude Include="DefaultUrl.h" />
|
<ClInclude Include="DefaultUrl.h" />
|
||||||
|
<ClInclude Include="XRPkgChecker.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ApplicationDefinition Include="App.xaml">
|
<ApplicationDefinition Include="App.xaml">
|
||||||
|
@ -928,6 +929,7 @@
|
||||||
<ClCompile Include="ServoControl\OpenGLES.cpp" />
|
<ClCompile Include="ServoControl\OpenGLES.cpp" />
|
||||||
<ClCompile Include="ServoControl\Servo.cpp" />
|
<ClCompile Include="ServoControl\Servo.cpp" />
|
||||||
<ClCompile Include="ServoControl\ServoControl.cpp" />
|
<ClCompile Include="ServoControl\ServoControl.cpp" />
|
||||||
|
<ClCompile Include="XRPkgChecker.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Midl Include="App.idl">
|
<Midl Include="App.idl">
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<ClCompile Include="ServoControl\ServoControl.cpp">
|
<ClCompile Include="ServoControl\ServoControl.cpp">
|
||||||
<Filter>ServoControl</Filter>
|
<Filter>ServoControl</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="XRPkgChecker.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
|
@ -38,6 +39,7 @@
|
||||||
<Filter>ServoControl</Filter>
|
<Filter>ServoControl</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="DefaultUrl.h" />
|
<ClInclude Include="DefaultUrl.h" />
|
||||||
|
<ClInclude Include="XRPkgChecker.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Image Include="Assets\Wide310x150Logo.scale-200.png">
|
<Image Include="Assets\Wide310x150Logo.scale-200.png">
|
||||||
|
|
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
|
30
support/hololens/ServoApp/XRPkgChecker.h
Normal file
30
support/hololens/ServoApp/XRPkgChecker.h
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue