Skip to content

Commit

Permalink
remove unused usings and fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie committed Aug 12, 2023
1 parent 022c9cb commit 942d758
Show file tree
Hide file tree
Showing 79 changed files with 1,251 additions and 1,348 deletions.
1 change: 0 additions & 1 deletion HandheldCompanion/Actions/MouseActions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using HandheldCompanion.Inputs;
using HandheldCompanion.Misc;
using HandheldCompanion.Simulators;
using System;
using System.ComponentModel;
Expand Down
1 change: 0 additions & 1 deletion HandheldCompanion/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Windows;
using HandheldCompanion.Managers;
using HandheldCompanion.Utils;
using HandheldCompanion.Managers;
using HandheldCompanion.Views;
using static HandheldCompanion.WinAPI;

Expand Down
8 changes: 4 additions & 4 deletions HandheldCompanion/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
2 changes: 1 addition & 1 deletion HandheldCompanion/Controllers/GordonController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public override void UpdateInputs(long ticks)
Inputs.ButtonState[ButtonFlags.B2] = input.State.ButtonState[GordonControllerButton.BtnB];
Inputs.ButtonState[ButtonFlags.B3] = input.State.ButtonState[GordonControllerButton.BtnX];
Inputs.ButtonState[ButtonFlags.B4] = input.State.ButtonState[GordonControllerButton.BtnY];

Inputs.ButtonState[ButtonFlags.DPadUp] = input.State.ButtonState[GordonControllerButton.BtnDpadUp];
Inputs.ButtonState[ButtonFlags.DPadDown] = input.State.ButtonState[GordonControllerButton.BtnDpadDown];
Inputs.ButtonState[ButtonFlags.DPadLeft] = input.State.ButtonState[GordonControllerButton.BtnDpadLeft];
Expand Down
18 changes: 11 additions & 7 deletions HandheldCompanion/Controllers/IController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,31 +88,35 @@ public abstract class IController

// todo: make this a custom control !
protected Border ui_border = new()
{ CornerRadius = new CornerRadius(4, 4, 4, 4), Padding = new Thickness(15, 12, 12, 12) };
{ CornerRadius = new CornerRadius(4, 4, 4, 4), Padding = new Thickness(15, 12, 12, 12) };

protected Button ui_button_hide = new()
{
Width = 100, FontSize = 14, VerticalAlignment = VerticalAlignment.Center,
Width = 100,
FontSize = 14,
VerticalAlignment = VerticalAlignment.Center,
Style = Application.Current.FindResource("AccentButtonStyle") as Style
};

protected Button ui_button_hook = new()
{
Width = 100, FontSize = 14, VerticalAlignment = VerticalAlignment.Center,
Width = 100,
FontSize = 14,
VerticalAlignment = VerticalAlignment.Center,
Style = Application.Current.FindResource("AccentButtonStyle") as Style
};

protected SimpleStackPanel ui_dock_buttons = new()
{ Spacing = 6, Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right };
{ Spacing = 6, Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right };

protected DockPanel ui_dock_content = new() { HorizontalAlignment = HorizontalAlignment.Left };
protected Grid ui_grid = new();

protected FontIcon ui_icon = new()
{ Glyph = "\uE7FC", Height = 40, HorizontalAlignment = HorizontalAlignment.Center };
{ Glyph = "\uE7FC", Height = 40, HorizontalAlignment = HorizontalAlignment.Center };

protected TextBlock ui_name = new()
{ VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(12, 0, 0, 0) };
{ VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(12, 0, 0, 0) };

protected int UserIndex;
protected double VibrationStrength = 1.0d;
Expand Down Expand Up @@ -330,7 +334,7 @@ public void Hide(bool powerCycle = true)
// get HidHideDevice
HidHideDevice hideDevice = HidHide.GetHidHideDevice(Details.baseContainerDeviceInstanceId);
if (hideDevice is not null)
foreach(HidHideSubDevice subDevice in hideDevice.Devices)
foreach (HidHideSubDevice subDevice in hideDevice.Devices)
HidHide.HidePath(subDevice.DeviceInstancePath);

HidHide.HidePath(Details.deviceInstanceId);
Expand Down
3 changes: 1 addition & 2 deletions HandheldCompanion/Controllers/NeptuneController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using HandheldCompanion.Managers;
using steam_hidapi.net;
Expand Down Expand Up @@ -108,7 +107,7 @@ public override void UpdateInputs(long ticks)

Inputs.ButtonState[ButtonFlags.L2Full] = L2 > Gamepad.TriggerThreshold * 8;
Inputs.ButtonState[ButtonFlags.R2Full] = R2 > Gamepad.TriggerThreshold * 8;

Inputs.AxisState[AxisFlags.L2] = (short)L2;
Inputs.AxisState[AxisFlags.R2] = (short)R2;

Expand Down
31 changes: 20 additions & 11 deletions HandheldCompanion/Controllers/XInputController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Media;
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
Expand Down Expand Up @@ -239,25 +238,32 @@ public override string GetGlyph(AxisLayoutFlags axis)
[StructLayout(LayoutKind.Explicit)]
protected struct XInputGamepad
{
[MarshalAs(UnmanagedType.I2)] [FieldOffset(0)]
[MarshalAs(UnmanagedType.I2)]
[FieldOffset(0)]
public short wButtons;

[MarshalAs(UnmanagedType.I1)] [FieldOffset(2)]
[MarshalAs(UnmanagedType.I1)]
[FieldOffset(2)]
public byte bLeftTrigger;

[MarshalAs(UnmanagedType.I1)] [FieldOffset(3)]
[MarshalAs(UnmanagedType.I1)]
[FieldOffset(3)]
public byte bRightTrigger;

[MarshalAs(UnmanagedType.I2)] [FieldOffset(4)]
[MarshalAs(UnmanagedType.I2)]
[FieldOffset(4)]
public short sThumbLX;

[MarshalAs(UnmanagedType.I2)] [FieldOffset(6)]
[MarshalAs(UnmanagedType.I2)]
[FieldOffset(6)]
public short sThumbLY;

[MarshalAs(UnmanagedType.I2)] [FieldOffset(8)]
[MarshalAs(UnmanagedType.I2)]
[FieldOffset(8)]
public short sThumbRX;

[MarshalAs(UnmanagedType.I2)] [FieldOffset(10)]
[MarshalAs(UnmanagedType.I2)]
[FieldOffset(10)]
public short sThumbRY;
}

Expand All @@ -272,13 +278,16 @@ protected struct XInputVibration
[StructLayout(LayoutKind.Explicit)]
protected struct XInputCapabilities
{
[MarshalAs(UnmanagedType.I1)] [FieldOffset(0)]
[MarshalAs(UnmanagedType.I1)]
[FieldOffset(0)]
private readonly byte Type;

[MarshalAs(UnmanagedType.I1)] [FieldOffset(1)]
[MarshalAs(UnmanagedType.I1)]
[FieldOffset(1)]
public byte SubType;

[MarshalAs(UnmanagedType.I2)] [FieldOffset(2)]
[MarshalAs(UnmanagedType.I2)]
[FieldOffset(2)]
public short Flags;

[FieldOffset(4)] public XInputGamepad Gamepad;
Expand Down
42 changes: 20 additions & 22 deletions HandheldCompanion/Controls/Layout/LayoutTemplate.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using HandheldCompanion;
using HandheldCompanion.Actions;

using GregsStack.InputSimulatorStandard.Native;
using HandheldCompanion.Actions;
using HandheldCompanion.Controllers;
using Newtonsoft.Json;
using HandheldCompanion.Inputs;
Expand Down Expand Up @@ -69,8 +67,8 @@ private LayoutTemplate(string name, string description, string author, bool isIn
switch (Name)
{
case "Desktop":
{
Layout.AxisLayout = new SortedDictionary<AxisLayoutFlags, IActions>
{
Layout.AxisLayout = new SortedDictionary<AxisLayoutFlags, IActions>
{
{
AxisLayoutFlags.LeftStick,
Expand All @@ -90,7 +88,7 @@ private LayoutTemplate(string name, string description, string author, bool isIn
}
};

Layout.ButtonLayout = new()
Layout.ButtonLayout = new()
{
{ ButtonFlags.B1, new List<IActions>() { new KeyboardActions { Key = VirtualKeyCode.RETURN } } },
{ ButtonFlags.B2, new List<IActions>() { new KeyboardActions { Key = VirtualKeyCode.ESCAPE } } },
Expand All @@ -114,21 +112,21 @@ private LayoutTemplate(string name, string description, string author, bool isIn
{ ButtonFlags.LeftPadClick, new List<IActions>() { new MouseActions { MouseType = MouseActionsType.RightButton } } },
{ ButtonFlags.RightPadClick, new List<IActions>() { new MouseActions { MouseType = MouseActionsType.LeftButton } } }
};
}
}
break;

case "Gamepad (Nintendo)":
{
Layout.ButtonLayout[ButtonFlags.B1] = new List<IActions>() { new ButtonActions { Button = ButtonFlags.B2 } };
Layout.ButtonLayout[ButtonFlags.B2] = new List<IActions>() { new ButtonActions { Button = ButtonFlags.B1 } };
Layout.ButtonLayout[ButtonFlags.B3] = new List<IActions>() { new ButtonActions { Button = ButtonFlags.B4 } };
Layout.ButtonLayout[ButtonFlags.B4] = new List<IActions>() { new ButtonActions { Button = ButtonFlags.B3 } };
}
{
Layout.ButtonLayout[ButtonFlags.B1] = new List<IActions>() { new ButtonActions { Button = ButtonFlags.B2 } };
Layout.ButtonLayout[ButtonFlags.B2] = new List<IActions>() { new ButtonActions { Button = ButtonFlags.B1 } };
Layout.ButtonLayout[ButtonFlags.B3] = new List<IActions>() { new ButtonActions { Button = ButtonFlags.B4 } };
Layout.ButtonLayout[ButtonFlags.B4] = new List<IActions>() { new ButtonActions { Button = ButtonFlags.B3 } };
}
break;

case "Keyboard (WASD) and Mouse":
{
Layout.AxisLayout = new SortedDictionary<AxisLayoutFlags, IActions>
{
Layout.AxisLayout = new SortedDictionary<AxisLayoutFlags, IActions>
{
{
AxisLayoutFlags.RightStick,
Expand All @@ -140,7 +138,7 @@ private LayoutTemplate(string name, string description, string author, bool isIn
}
};

Layout.ButtonLayout = new()
Layout.ButtonLayout = new()
{
{ ButtonFlags.B1, new List<IActions>() { new KeyboardActions { Key = VirtualKeyCode.SPACE } } },
{ ButtonFlags.B2, new List<IActions>() { new KeyboardActions { Key = VirtualKeyCode.VK_E } } },
Expand Down Expand Up @@ -176,19 +174,19 @@ private LayoutTemplate(string name, string description, string author, bool isIn

{ ButtonFlags.RightPadClick, new List<IActions>() { new MouseActions { MouseType = MouseActionsType.LeftButton } } }
};
}
}
break;

case "Gamepad with Mouse Trackpad":
{
Layout.AxisLayout[AxisLayoutFlags.RightPad] = new MouseActions { MouseType = MouseActionsType.Move };
}
{
Layout.AxisLayout[AxisLayoutFlags.RightPad] = new MouseActions { MouseType = MouseActionsType.Move };
}
break;

case "Gamepad with Joystick Trackpad":
{
Layout.AxisLayout[AxisLayoutFlags.RightPad] = new AxisActions { Axis = AxisLayoutFlags.RightStick };
}
{
Layout.AxisLayout[AxisLayoutFlags.RightPad] = new AxisActions { Axis = AxisLayoutFlags.RightStick };
}
break;
}
}
Expand Down
18 changes: 9 additions & 9 deletions HandheldCompanion/Controls/Mapping/AxisMapping.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private void Action_SelectionChanged(object sender, SelectionChangedEventArgs e)

// create a label, store MouseActionsType as Tag and Label as controller specific string
var buttonLabel = new Label
{ Tag = mouseType, Content = EnumUtils.GetDescriptionFromEnumValue(mouseType) };
{ Tag = mouseType, Content = EnumUtils.GetDescriptionFromEnumValue(mouseType) };
TargetComboBox.Items.Add(buttonLabel);

if (mouseType.Equals(((MouseActions)Actions).MouseType))
Expand Down Expand Up @@ -163,17 +163,17 @@ private void Target_SelectionChanged(object sender, SelectionChangedEventArgs e)
switch (Actions.ActionType)
{
case ActionType.Joystick:
{
var buttonLabel = TargetComboBox.SelectedItem as Label;
((AxisActions)Actions).Axis = (AxisLayoutFlags)buttonLabel.Tag;
}
{
var buttonLabel = TargetComboBox.SelectedItem as Label;
((AxisActions)Actions).Axis = (AxisLayoutFlags)buttonLabel.Tag;
}
break;

case ActionType.Mouse:
{
var buttonLabel = TargetComboBox.SelectedItem as Label;
((MouseActions)Actions).MouseType = (MouseActionsType)buttonLabel.Tag;
}
{
var buttonLabel = TargetComboBox.SelectedItem as Label;
((MouseActions)Actions).MouseType = (MouseActionsType)buttonLabel.Tag;
}
break;
}

Expand Down
29 changes: 13 additions & 16 deletions HandheldCompanion/Controls/Mapping/ButtonMapping.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using HandheldCompanion.Actions;
using HandheldCompanion.Controllers;

using HandheldCompanion.Utils;
using GregsStack.InputSimulatorStandard.Native;
using HandheldCompanion.Actions;
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
using HandheldCompanion.Simulators;
using Inkore.UI.WPF.Modern.Controls;

namespace HandheldCompanion.Controls;
Expand Down Expand Up @@ -161,7 +158,7 @@ private void Action_SelectionChanged(object sender, SelectionChangedEventArgs e)

// create a label, store MouseActionsType as Tag and Label as controller specific string
var buttonLabel = new Label
{ Tag = mouseType, Content = EnumUtils.GetDescriptionFromEnumValue(mouseType) };
{ Tag = mouseType, Content = EnumUtils.GetDescriptionFromEnumValue(mouseType) };
TargetComboBox.Items.Add(buttonLabel);

if (mouseType.Equals(((MouseActions)Actions).MouseType))
Expand Down Expand Up @@ -208,24 +205,24 @@ private void Target_SelectionChanged(object sender, SelectionChangedEventArgs e)
switch (Actions.ActionType)
{
case ActionType.Button:
{
var buttonLabel = TargetComboBox.SelectedItem as Label;
((ButtonActions)Actions).Button = (ButtonFlags)buttonLabel.Tag;
}
{
var buttonLabel = TargetComboBox.SelectedItem as Label;
((ButtonActions)Actions).Button = (ButtonFlags)buttonLabel.Tag;
}
break;

case ActionType.Keyboard:
{
var buttonLabel = TargetComboBox.SelectedItem as Label;
((KeyboardActions)Actions).Key = (VirtualKeyCode)buttonLabel.Tag;
}
{
var buttonLabel = TargetComboBox.SelectedItem as Label;
((KeyboardActions)Actions).Key = (VirtualKeyCode)buttonLabel.Tag;
}
break;

case ActionType.Mouse:
{
var buttonLabel = TargetComboBox.SelectedItem as Label;
((MouseActions)Actions).MouseType = (MouseActionsType)buttonLabel.Tag;
}
{
var buttonLabel = TargetComboBox.SelectedItem as Label;
((MouseActions)Actions).MouseType = (MouseActionsType)buttonLabel.Tag;
}
break;
}

Expand Down
8 changes: 4 additions & 4 deletions HandheldCompanion/Controls/Mapping/TriggerMapping.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ private void Target_SelectionChanged(object sender, SelectionChangedEventArgs e)
switch (Actions.ActionType)
{
case ActionType.Trigger:
{
var buttonLabel = TargetComboBox.SelectedItem as Label;
((TriggerActions)Actions).Axis = (AxisLayoutFlags)buttonLabel.Tag;
}
{
var buttonLabel = TargetComboBox.SelectedItem as Label;
((TriggerActions)Actions).Axis = (AxisLayoutFlags)buttonLabel.Tag;
}
break;
}

Expand Down
Loading

0 comments on commit 942d758

Please sign in to comment.