Skip to content

Commit

Permalink
AntiDeadzone slider for Quicktools and improve range (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperH2O authored Sep 16, 2022
1 parent af5956f commit 785c59e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion HandheldCompanion/Views/Pages/ProfilesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@

<DockPanel Grid.Column="1" Margin="12,0,0,0" ScrollViewer.PanningMode="HorizontalOnly">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Value, ElementName=tb_ProfileAntiDeadzone, Mode=OneWay}" />
<Slider Margin="6,0,0,0" Name="tb_ProfileAntiDeadzone" VerticalAlignment="Center" AutoToolTipPlacement="TopLeft" LargeChange="10" Maximum="100" TickPlacement="BottomRight" SmallChange="1" TickFrequency="1" IsSnapToTickEnabled="True" IsMoveToPointEnabled="True" />
<Slider Margin="6,0,0,0" Name="tb_ProfileAntiDeadzone" VerticalAlignment="Center" AutoToolTipPlacement="TopLeft" LargeChange="10" Maximum="40" TickPlacement="BottomRight" SmallChange="1" TickFrequency="1" IsSnapToTickEnabled="True" IsMoveToPointEnabled="True" />
</DockPanel>
</Grid>

Expand Down
24 changes: 24 additions & 0 deletions HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,30 @@
</DockPanel>
</ui:SimpleStackPanel>

<ui:SimpleStackPanel Spacing="10" Name="GridAntiDeadzone">
<!-- Separator -->
<Separator BorderBrush="{DynamicResource SystemControlBackgroundChromeMediumBrush}" BorderThickness="0 1 0 0" />

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="420"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>

<StackPanel Orientation="Vertical">
<TextBlock Text="{x:Static resx:Resources.ProfilesPage_AntiDeadzone}" FontSize="14"/>
<TextBlock Text="{x:Static resx:Resources.ProfilesPage_AntiDeadzoneDesc}" Foreground="{DynamicResource SystemControlForegroundBaseMediumBrush}" FontSize="12" TextWrapping="Wrap"/>
</StackPanel>
</Grid>

<!-- Content -->
<DockPanel Grid.Column="1" Margin="0,0,0,0" ScrollViewer.PanningMode="HorizontalOnly">
<TextBlock Width="30" TextAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Left" Text="{Binding Value, StringFormat=N0, ElementName=SliderAntiDeadzone, Mode=OneWay}" />
<Slider Name="SliderAntiDeadzone" Margin="8,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Center" AutoToolTipPlacement="TopLeft" LargeChange="5" Maximum="40" Minimum="1" Value="1" TickPlacement="BottomRight" SmallChange="1" AutoToolTipPrecision="0" IsSnapToTickEnabled="True" IsMoveToPointEnabled="True"
ValueChanged="SliderAntiDeadzone_ValueChanged" />
</DockPanel>
</ui:SimpleStackPanel>

</ui:SimpleStackPanel>
</Border>
</Grid>
Expand Down
18 changes: 17 additions & 1 deletion HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ private void ProfileUpdated(Profile profile, bool backgroundtask, bool isCurrent

TDPToggle.IsOn = profile.TDP_override;

// Sensivity settings
// Slider settings
SliderSensivity.Value = profile.aiming_sensivity;
SliderAntiDeadzone.Value = profile.antideadzone;

if (backgroundtask)
return;
Expand Down Expand Up @@ -228,10 +229,12 @@ private void cB_Input_SelectionChanged(object sender, SelectionChangedEventArgs
case Input.JoystickCamera:
cB_Output.SelectedIndex = (int)Output.RightStick;
GridSensivity.Visibility = Visibility.Visible;
GridAntiDeadzone.Visibility = Visibility.Visible;
break;
case Input.JoystickSteering:
cB_Output.SelectedIndex = (int)Output.LeftStick;
GridSensivity.Visibility = Visibility.Collapsed;
GridAntiDeadzone.Visibility = Visibility.Collapsed;
break;
}

Expand Down Expand Up @@ -326,5 +329,18 @@ private void SliderSensivity_ValueChanged(object sender, RoutedPropertyChangedEv
currentProfile.aiming_sensivity = (float)SliderSensivity.Value;
UpdateProfile();
}

private void SliderAntiDeadzone_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (currentProfile is null)
return;

if (!IsReady)
return;

// Antideadzone settings
currentProfile.antideadzone = (float)SliderAntiDeadzone.Value;
UpdateProfile();
}
}
}

0 comments on commit 785c59e

Please sign in to comment.