Skip to content

Commit

Permalink
build 0.18.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie committed Sep 17, 2023
1 parent dfe34f4 commit 9d90dd3
Show file tree
Hide file tree
Showing 43 changed files with 2,079 additions and 570 deletions.
2 changes: 1 addition & 1 deletion HandheldCompanion.iss
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ end;

#define MyAppSetupName 'Handheld Companion'
#define MyBuildId 'HandheldCompanion'
#define MyAppVersion '0.18.0.1'
#define MyAppVersion '0.18.0.3'
#define MyAppPublisher 'BenjaminLSR'
#define MyAppCopyright 'Copyright @ BenjaminLSR'
#define MyAppURL 'https://github.com/Valkirie/HandheldCompanion'
Expand Down
4 changes: 4 additions & 0 deletions HandheldCompanion/Actions/GyroActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ public class GyroActions : IActions

public ButtonState MotionTrigger = new();

public float gyroWeight = DefaultGyroWeight;

// const vars
public const int DefaultAxisAntiDeadZone = 15;
public const AxisLayoutFlags DefaultAxisLayoutFlags = AxisLayoutFlags.RightStick;

public const MouseActionsType DefaultMouseActionsType = MouseActionsType.Move;
public const int DefaultSensivity = 33;
public const int DefaultDeadzone = 10;
public const float DefaultGyroWeight = 1.2f;

public GyroActions()
{
Expand Down
101 changes: 65 additions & 36 deletions HandheldCompanion/Controllers/IController.xaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,73 @@
<UserControl x:Class="HandheldCompanion.Controllers.IController"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:HandheldCompanion.Controllers"
xmlns:resx="clr-namespace:HandheldCompanion.Properties"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl
x:Class="HandheldCompanion.Controllers.IController"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:HandheldCompanion.Controllers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:resx="clr-namespace:HandheldCompanion.Properties"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">

<Border
Padding="15,12,12,12"
Background="{DynamicResource SystemControlPageBackgroundAltHighBrush}"
CornerRadius="{DynamicResource ControlCornerRadius}">
Padding="15,12,12,12"
Background="{DynamicResource SystemControlPageBackgroundAltHighBrush}"
CornerRadius="{DynamicResource ControlCornerRadius}">

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*" MinWidth="200" />
<ColumnDefinition Width="5*" MinWidth="200" />
</Grid.ColumnDefinitions>
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*" MinWidth="200" />
<ColumnDefinition Width="5*" MinWidth="200" />
</Grid.ColumnDefinitions>

<DockPanel>
<ui:FontIcon

Height="40"
HorizontalAlignment="Center"
FontFamily="{DynamicResource SymbolThemeFontFamily}"
Glyph="&#xE7FC;" />
<DockPanel>
<ui:FontIcon
Height="40"
HorizontalAlignment="Center"
FontFamily="{DynamicResource SymbolThemeFontFamily}"
Glyph="&#xE7FC;" />

<TextBlock Name="ui_name" Style="{StaticResource BodyTextBlockStyle}" VerticalAlignment="Center" Margin="12,0,0,0" />
</DockPanel>
<TextBlock
Name="ui_name"
Margin="12,0,0,0"
VerticalAlignment="Center"
Style="{StaticResource BodyTextBlockStyle}" />
</DockPanel>

<DockPanel Grid.Column="1" HorizontalAlignment="Right">
<Button Name="ui_button_hook"
Style="{DynamicResource AccentButtonStyle}" Width="100" FontSize="14" Click="ui_button_hook_Click"/>
<Button Name="ui_button_hide"
Style="{DynamicResource AccentButtonStyle}" Width="100" FontSize="14" Margin="6,0,0,0" Click="ui_button_hide_Click"/>
<Button Name="ui_button_calibrate"
Style="{DynamicResource AccentButtonStyle}" Width="100" FontSize="14" Margin="6,0,0,0" Visibility="Collapsed" Click="ui_button_calibrate_Click" Content="Calibrate"/>
</DockPanel>
</Grid>
<DockPanel Grid.Column="1" HorizontalAlignment="Right">
<Button
Name="ui_button_hook"
Width="100"
Click="ui_button_hook_Click"
FontSize="14"
Style="{DynamicResource AccentButtonStyle}" />
<Button
Name="ui_button_hide"
Width="100"
Margin="6,0,0,0"
Click="ui_button_hide_Click"
FontSize="14"
Style="{DynamicResource AccentButtonStyle}" />
<Button
Name="ui_button_calibrate"
Width="100"
Margin="6,0,0,0"
Click="ui_button_calibrate_Click"
Content="Calibrate"
FontSize="14"
Style="{DynamicResource AccentButtonStyle}"
Visibility="Collapsed" />
</DockPanel>
</Grid>

<ui:ProgressBar
Name="ProgressBarUpdate"
d:Visibility="Visible"
IsIndeterminate="True"
Visibility="Collapsed" />
</StackPanel>
</Border>
</UserControl>
73 changes: 52 additions & 21 deletions HandheldCompanion/Controllers/IController.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ protected void RefreshControls()
// UI thread (async)
Application.Current.Dispatcher.BeginInvoke(() =>
{
if (!IsEnabled)
return;

ui_button_hook.Content = IsPlugged() ? Properties.Resources.Controller_Disconnect : Properties.Resources.Controller_Connect;
ui_button_hide.Content = IsHidden() ? Properties.Resources.Controller_Unhide : Properties.Resources.Controller_Hide;
ui_button_calibrate.Visibility = Capabilities.HasFlag(ControllerCapabilities.Calibration) ? Visibility.Visible : Visibility.Collapsed;
Expand Down Expand Up @@ -266,50 +269,78 @@ public bool IsHidden()

public void Hide(bool powerCycle = true)
{
if (IsHidden())
HideHID();

// set flag
powerCycle = powerCycle && this is not SteamController;

if (powerCycle)
{
// UI thread (async)
Application.Current.Dispatcher.BeginInvoke(() =>
{
IsEnabled = false;
ProgressBarUpdate.Visibility = Visibility.Visible;
});

ControllerManager.PowerCyclers[Details.baseContainerDeviceInstanceId] = true;
Details.CyclePort();
return;
}

// get HidHideDevice
HidHideDevice hideDevice = HidHide.GetHidHideDevice(Details.baseContainerDeviceInstanceId);
if (hideDevice is not null)
foreach (HidHideSubDevice subDevice in hideDevice.Devices)
HidHide.HidePath(subDevice.DeviceInstancePath);
RefreshControls();
}

HidHide.HidePath(Details.deviceInstanceId);
HidHide.HidePath(Details.baseContainerDeviceInstanceId);
public void Unhide(bool powerCycle = true)
{
UnhideHID();

// set flag
powerCycle = powerCycle && this is not SteamController;

if (powerCycle)
{
// UI thread (async)
Application.Current.Dispatcher.BeginInvoke(() =>
{
IsEnabled = false;
ProgressBarUpdate.Visibility = Visibility.Visible;
});

ControllerManager.PowerCyclers[Details.baseContainerDeviceInstanceId] = true;
Details.CyclePort();
return;
}

RefreshControls();
}

public void Unhide(bool powerCycle = true)
public void HideHID()
{
if (!IsHidden())
return;
HidHide.HidePath(Details.baseContainerDeviceInstanceId);
HidHide.HidePath(Details.deviceInstanceId);

/*
// get HidHideDevice
HidHideDevice hideDevice = HidHide.GetHidHideDevice(Details.baseContainerDeviceInstanceId);
if (hideDevice is not null)
foreach (HidHideSubDevice subDevice in hideDevice.Devices)
HidHide.UnhidePath(subDevice.DeviceInstancePath);
HidHide.HidePath(subDevice.DeviceInstancePath);
*/
}

HidHide.UnhidePath(Details.deviceInstanceId);
public void UnhideHID()
{
HidHide.UnhidePath(Details.baseContainerDeviceInstanceId);
HidHide.UnhidePath(Details.deviceInstanceId);

// set flag
if (powerCycle)
{
ControllerManager.PowerCyclers[Details.baseContainerDeviceInstanceId] = true;
Details.CyclePort();
}

RefreshControls();
/*
// get HidHideDevice
HidHideDevice hideDevice = HidHide.GetHidHideDevice(Details.baseContainerDeviceInstanceId);
if (hideDevice is not null)
foreach (HidHideSubDevice subDevice in hideDevice.Devices)
HidHide.UnhidePath(subDevice.DeviceInstancePath);
*/
}

protected virtual void Calibrate()
Expand Down
54 changes: 54 additions & 0 deletions HandheldCompanion/Controls/Mapping/GyroMapping.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,60 @@

<ui:SimpleStackPanel Spacing="6">
<ui:SimpleStackPanel Spacing="6">

<!-- Separator -->
<Separator
BorderBrush="{DynamicResource SystemControlBackgroundChromeMediumBrush}"
BorderThickness="0,1,0,0"
Opacity="0.25" />

<!-- Gyro Weight -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*" MinWidth="200" />
<ColumnDefinition Width="5*" MinWidth="200" />
</Grid.ColumnDefinitions>

<StackPanel Orientation="Vertical">
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="Gyrometer weight" />
<TextBlock
Foreground="{DynamicResource SystemControlForegroundBaseMediumBrush}"
Style="{StaticResource CaptionTextBlockStyle}"
Text="Modify the gyrometer weight when applied against joystick movements"
TextWrapping="Wrap" />
</StackPanel>

<DockPanel
Grid.Column="1"
Margin="12,0,0,0"
ScrollViewer.PanningMode="HorizontalOnly">
<TextBlock
Width="35"
VerticalAlignment="Center"
Text="{Binding Value, StringFormat=N1, ElementName=Slider_GyroWeight, Mode=OneWay}"
TextAlignment="Center" />
<Slider
x:Name="Slider_GyroWeight"
Margin="6,0,0,0"
VerticalAlignment="Center"
AutoToolTipPrecision="1"
IsMoveToPointEnabled="True"
IsSnapToTickEnabled="True"
Maximum="2.0"
Minimum="1.0"
Style="{DynamicResource SliderStyle1}"
TickFrequency="0.1"
TickPlacement="BottomRight"
ValueChanged="Slider_GyroWeight_ValueChanged" />
</DockPanel>
</Grid>

<!-- Separator -->
<Separator
BorderBrush="{DynamicResource SystemControlBackgroundChromeMediumBrush}"
BorderThickness="0,1,0,0"
Opacity="0.25" />

<!-- Improve circularity -->
<Grid>
<Grid.ColumnDefinitions>
Expand Down
11 changes: 11 additions & 0 deletions HandheldCompanion/Controls/Mapping/GyroMapping.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ private void Action_SelectionChanged(object sender, SelectionChangedEventArgs e)
TargetComboBox.SelectedIndex = 0;

// settings
Slider_GyroWeight.Value = ((AxisActions)Actions).gyroWeight;
Axis2AxisImproveCircularity.IsOn = ((AxisActions)Actions).ImproveCircularity;
Axis2AxisAutoRotate.IsOn = ((AxisActions)Actions).AutoRotate;
Axis2AxisRotation.Value = (((AxisActions)Actions).AxisInverted ? 180 : 0) +
Expand Down Expand Up @@ -452,6 +453,16 @@ private void cB_UMC_MotionDefaultOffOn_SelectionChanged(object sender, Selection
base.Update();
}

private void Slider_GyroWeight_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (this.Actions is null)
return;

((GyroActions)this.Actions).gyroWeight = (float)Slider_GyroWeight.Value;

base.Update();
}

private void TriggerCreated(Hotkey hotkey)
{
switch (hotkey.inputsHotkey.Listener)
Expand Down
Loading

0 comments on commit 9d90dd3

Please sign in to comment.