Skip to content

Commit

Permalink
Add UI toggle to enable/disable the hibnernation gesture
Browse files Browse the repository at this point in the history
  • Loading branch information
fredemmott committed Jul 22, 2024
1 parent d869776 commit 7840d13
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 39 deletions.
8 changes: 7 additions & 1 deletion src/SettingsApp/MainWindow.idl
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
namespace HTCCSettings {
[default_interface] runtimeclass MainWindow : Microsoft.UI.Xaml.Window {
[default_interface] runtimeclass MainWindow : Microsoft.UI.Xaml.Window,
Microsoft.UI.Xaml.Data.INotifyPropertyChanged {
MainWindow();

// General settings
Boolean IsEnabled;
Boolean IsHibernationGestureEnabled;
Int16 PointerSource;
Int16 PointerSink;

Boolean IsPointerSourceOpenXRHandTracking {
get;
};

// XR_FB_hand_tracking_aim (Quest, Ultraleap Gemini 5.16+)
Boolean PinchToClick;
Boolean PinchToScroll;
Expand Down
76 changes: 38 additions & 38 deletions src/SettingsApp/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:DefaultBindMode="TwoWay">
<Grid RowDefinitions="Auto,*" x:Name="RootGrid">
<Border x:Name="AppTitleBar" Grid.Row="0" VerticalAlignment="Top" Background="{StaticResource WindowCaptionBackground}" Height="32">
<TextBlock Text="HTCC Settings" VerticalAlignment="Center" Margin="8,0,0,0" Style="{StaticResource CaptionTextBlockStyle}" />
<Grid RowDefinitions="Auto,*"
x:Name="RootGrid">
<Border x:Name="AppTitleBar"
Grid.Row="0"
VerticalAlignment="Top"
Background="{StaticResource WindowCaptionBackground}"
Height="32">
<TextBlock Text="HTCC Settings"
VerticalAlignment="Center"
Margin="8,0,0,0"
Style="{StaticResource CaptionTextBlockStyle}"/>
</Border>
<ScrollViewer
Grid.Row="1"
Expand All @@ -31,14 +39,19 @@
Header="Enable HTCC:"
OnContent="HTCC is enabled"
OffContent="HTCC is fully disabled in all games"
IsOn="{x:Bind IsEnabled}"
/>
IsOn="{x:Bind IsEnabled}"/>
<ComboBox
Header="Hand tracking device:"
SelectedIndex="{x:Bind PointerSource}">
<x:String>OpenXR hand tracking</x:String>
<x:String>PointCTRL</x:String>
</ComboBox>
<ToggleSwitch
Header="OpenXR hand tracking hibernation gesture:"
OnContent="HTCC will recognize the gesture"
OffContent="HTCC never hibernates"
IsOn="{x:Bind IsHibernationGestureEnabled}"
IsEnabled="{x:Bind IsPointerSourceOpenXRHandTracking, Mode=OneWay}"/>
<ComboBox
Header="Prefered game interface:"
SelectedIndex="{x:Bind PointerSink}">
Expand All @@ -49,8 +62,7 @@
<!-- XR_FB_hand_tracking_aim Settings -->
<TextBlock
Text="Gestures"
Style="{StaticResource SubtitleTextBlockStyle}"
/>
Style="{StaticResource SubtitleTextBlockStyle}"/>
<StackPanel
Orientation="Vertical"
Spacing="12"
Expand All @@ -68,14 +80,12 @@
Header="Pinch to click:"
OnContent="Enabled"
OffContent="Disabled"
IsOn="{x:Bind PinchToClick}"
/>
IsOn="{x:Bind PinchToClick}"/>
<ToggleSwitch
Header="Pinch to scroll:"
OnContent="Enabled"
OffContent="Disabled"
IsOn="{x:Bind PinchToScroll}"
/>
IsOn="{x:Bind PinchToScroll}"/>
</StackPanel>
<!-- PointCTRL -->
<Grid
Expand All @@ -84,14 +94,12 @@
Grid.Column="0"
Text="PointCTRL"
Style="{StaticResource SubtitleTextBlockStyle}"
VerticalAlignment="Center"
/>
VerticalAlignment="Center"/>
<Button
Grid.Column="1"
Content="Calibrate"
VerticalAlignment="Center"
Click="OnPointCtrlCalibrateClick"
/>
Click="OnPointCtrlCalibrateClick"/>
</Grid>
<StackPanel
Orientation="Vertical"
Expand All @@ -112,8 +120,7 @@
<!-- Workarounds -->
<TextBlock
Text="Workarounds"
Style="{StaticResource SubtitleTextBlockStyle}"
/>
Style="{StaticResource SubtitleTextBlockStyle}"/>
<StackPanel
Orientation="Vertical"
Spacing="12"
Expand All @@ -126,8 +133,7 @@
Header="Ignore XR_FB_hand_tracking_aim pose:"
OnContent="A finger joint pose is used instead"
OffContent="XR_FB_hand_tracking_aim's pose is used if available"
IsOn="{x:Bind DisableAimPointFB}"
/>
IsOn="{x:Bind DisableAimPointFB}"/>
<TextBlock Style="{StaticResource BodyTextBlockStyle}">
Some hand tracking drivers do not report that hand tracking features are supported;
it may be possible to enable HTCC in these cases with the options below. If the
Expand All @@ -137,14 +143,12 @@
Header="Force-enable XR_EXT_hand_tracking:"
OnContent="XR_EXT_hand_tracking is always assumed to be usable"
OffContent="XR_EXT_hand_tracking will be used if detected"
IsOn="{x:Bind ForceXRExtHandTracking}"
/>
IsOn="{x:Bind ForceXRExtHandTracking}"/>
<ToggleSwitch
Header="Force-enable XR_FB_hand_tracking_aim:"
OnContent="XR_FB_hand_tracking_aim is always assumed to be usable"
OffContent="XR_FB_hand_tracking_aim will be used if detected"
IsOn="{x:Bind ForceXRFBHandTrackingAim}"
/>
IsOn="{x:Bind ForceXRFBHandTrackingAim}"/>
</StackPanel>
<!-- VERSION INFO -->
<Grid ColumnDefinitions="Auto,*,Auto,Auto">
Expand All @@ -153,21 +157,18 @@
Glyph="&#xE74C;"
FontFamily="{StaticResource SymbolThemeFontFamily}"
Margin="0,0,12,0"
VerticalAlignment="Center"
/>
VerticalAlignment="Center"/>
<TextBlock
Grid.Column="1"
Text="About HTCC"
Style="{StaticResource SubtitleTextBlockStyle}"
VerticalAlignment="Center"/>
<Button
Grid.Column="2"
Content="Copy"
Click="OnCopyVersionDataClick"
VerticalAlignment="Center"
/>
<Button
Grid.Column="2"
Content="Copy"
Click="OnCopyVersionDataClick"
VerticalAlignment="Center"
Margin="0,0,8,0"
/>
Margin="0,0,8,0"/>
<Button
Grid.Column="3"
Click="OnSponsorClick">
Expand All @@ -177,9 +178,9 @@
Glyph="&#xEB51;"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Foreground="#db61a2"
/>
<TextBlock Grid.Column="1" Margin="8,0,0,0">
Foreground="#db61a2"/>
<TextBlock Grid.Column="1"
Margin="8,0,0,0">
Support HTCC
</TextBlock>
</Grid>
Expand All @@ -196,8 +197,7 @@
Grid.Row="0"
x:Name="VersionText"
Style="{ThemeResource BodyTextBlockStyle}"
IsTextSelectionEnabled="true"
/>
IsTextSelectionEnabled="true"/>
</Grid>
</StackPanel>
</ScrollViewer>
Expand Down
27 changes: 27 additions & 0 deletions src/SettingsApp/MainWindow.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,29 @@ void MainWindow::IsEnabled(bool enabled) noexcept {
}
}

bool MainWindow::IsHibernationGestureEnabled() const noexcept {
return HTCC::Config::HandTrackingHibernateGestureEnabled;
}

void MainWindow::IsHibernationGestureEnabled(bool value) noexcept {
HTCC::Config::SaveHandTrackingHibernateGestureEnabled(value);
}

bool MainWindow::IsPointerSourceOpenXRHandTracking() const noexcept {
return HTCC::Config::PointerSource == HTCC::PointerSource::OpenXRHandTracking;
}

int16_t MainWindow::PointerSource() const noexcept {
return static_cast<int16_t>(HTCC::Config::PointerSource);
}

void MainWindow::PointerSource(int16_t value) noexcept {
HTCC::Config::SavePointerSource(static_cast<HTCC::PointerSource>(value));

mPropertyChangedEvent(
*this,
winrt::Microsoft::UI::Xaml::Data::PropertyChangedEventArgs {
L"IsPointerSourceOpenXRHandTracking"});
}

int16_t MainWindow::PointerSink() const noexcept {
Expand Down Expand Up @@ -250,4 +267,14 @@ void MainWindow::ForceXRFBHandTrackingAim(bool value) noexcept {
HTCC::Config::SaveForceHaveXRFBHandTrackingAim(value);
}

winrt::event_token MainWindow::PropertyChanged(
const winrt::Microsoft::UI::Xaml::Data::PropertyChangedEventHandler&
handler) {
return mPropertyChangedEvent.add(handler);
}

void MainWindow::PropertyChanged(const winrt::event_token& token) noexcept {
return mPropertyChangedEvent.remove(token);
}

}// namespace winrt::HTCCSettings::implementation
13 changes: 13 additions & 0 deletions src/SettingsApp/MainWindow.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ struct MainWindow : MainWindowT<MainWindow> {
bool IsEnabled() const noexcept;
void IsEnabled(bool) noexcept;

bool IsHibernationGestureEnabled() const noexcept;
void IsHibernationGestureEnabled(bool) noexcept;

int16_t PointerSource() const noexcept;
void PointerSource(int16_t) noexcept;

bool IsPointerSourceOpenXRHandTracking() const noexcept;

int16_t PointerSink() const noexcept;
void PointerSink(int16_t) noexcept;

Expand Down Expand Up @@ -53,10 +58,18 @@ struct MainWindow : MainWindowT<MainWindow> {

void OnCopyVersionDataClick(const IInspectable&, const MUX::RoutedEventArgs&);

/// PropertyChanged
winrt::event_token PropertyChanged(
const winrt::Microsoft::UI::Xaml::Data::PropertyChangedEventHandler&);
void PropertyChanged(const winrt::event_token&) noexcept;

private:
void InitVersion();
std::string mVersionString;
HWND mHwnd {};

winrt::event<winrt::Microsoft::UI::Xaml::Data::PropertyChangedEventHandler>
mPropertyChangedEvent;
};
}// namespace winrt::HTCCSettings::implementation

Expand Down

0 comments on commit 7840d13

Please sign in to comment.