Skip to content

Commit

Permalink
Implement profile-specific power settings (#202)
Browse files Browse the repository at this point in the history
* early work on per-profile TDP

* more work

* update profile default values

* reduce anti-deadzone tick frequency to 1

* rename a few variables

* fix profile listbox update

* improve power manager

* restore default TDP on foreground process changes

* improve logmanager when debugging over VS

* code cleanup
  • Loading branch information
Valkirie authored Jul 18, 2022
1 parent bdbd8f7 commit 08fe637
Show file tree
Hide file tree
Showing 26 changed files with 472 additions and 422 deletions.
10 changes: 10 additions & 0 deletions ControllerCommon/Managers/LogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Extensions.Logging;
using System.Diagnostics;
using ILogger = Microsoft.Extensions.Logging.ILogger;

namespace ControllerCommon.Managers
Expand All @@ -24,22 +25,31 @@ public static void Initialize(string name)

public static void LogInformation(string message, params object[] args)
{
Trace.TraceInformation(message, args);
logger.LogInformation(message, args);
}

public static void LogWarning(string message, params object[] args)
{
Trace.TraceWarning(message, args);
logger.LogWarning(message, args);
}

public static void LogCritical(string message, params object[] args)
{
Trace.TraceError(message, args);
logger.LogCritical(message, args);
}

public static void LogDebug(string message, params object[] args)
{
Trace.TraceInformation(message, args);
logger.LogDebug(message, args);
}

public static void LogError(string message, params object[] args)
{
Trace.TraceError(message, args);
logger.LogError(message, args);
}
}
Expand Down
154 changes: 80 additions & 74 deletions ControllerCommon/Profile.cs
Original file line number Diff line number Diff line change
@@ -1,88 +1,92 @@
using ControllerCommon.Utils;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace ControllerCommon
{
public enum ProfileErrorCode
{
None = 0,
MissingExecutable = 1,
MissingPath = 2,
MissingPermission = 3,
IsDefault = 4,
IsRunning = 5
}

[Serializable]
public class ProfileVector
{
public double x { get; set; }
public double y { get; set; }

public ProfileVector(double x, double y)
{
this.x = x;
this.y = y;
}
}

[Serializable]
public class Profile
{
// move me to HandheldCompanion ?
public static Dictionary<Input, string> InputDescription = new()
{
{ Input.JoystickCamera, Properties.Resources.JoystickCameraDesc },
{ Input.JoystickSteering, Properties.Resources.JoystickSteeringDesc },
{ Input.PlayerSpace, Properties.Resources.PlayerSpaceDesc }
};

public string name { get; set; }
public string path { get; set; }
public string executable { get; set; }
public bool isEnabled { get; set; } = true;

public bool whitelisted { get; set; } = false; // if true, can see through the HidHide cloak
public bool use_wrapper { get; set; } = false; // if true, deploy xinput1_3.dll
public float gyrometer { get; set; } = 1.0f; // gyroscope multiplicator (remove me)
public float accelerometer { get; set; } = 1.0f; // accelerometer multiplicator (remove me)

public int steering { get; set; } = 0; // 0 = Roll, 1 = Yaw
public float antideadzone { get; set; } = 0.0f; // todo: typeme

public bool inverthorizontal { get; set; } = false; // if true, invert horizontal axis
public bool invertvertical { get; set; } = false; // if false, invert vertical axis

public bool umc_enabled { get; set; } = true;

public Input umc_input { get; set; } = Input.JoystickCamera;
public Output umc_output { get; set; } = Output.RightStick;

// aiming
public float aiming_sensivity { get; set; } = 2.0f;

public List<ProfileVector> aiming_array { get; set; } = new();

// steering
public float steering_max_angle { get; set; } = 30.0f;
public float steering_power { get; set; } = 1.0f;
using ControllerCommon.Utils;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace ControllerCommon
{
public enum ProfileErrorCode
{
None = 0,
MissingExecutable = 1,
MissingPath = 2,
MissingPermission = 3,
IsDefault = 4,
IsRunning = 5
}

[Serializable]
public class ProfileVector
{
public double x { get; set; }
public double y { get; set; }

public ProfileVector(double x, double y)
{
this.x = x;
this.y = y;
}
}

[Serializable]
public class Profile
{
// move me to HandheldCompanion ?
public static Dictionary<Input, string> InputDescription = new()
{
{ Input.JoystickCamera, Properties.Resources.JoystickCameraDesc },
{ Input.JoystickSteering, Properties.Resources.JoystickSteeringDesc },
{ Input.PlayerSpace, Properties.Resources.PlayerSpaceDesc }
};

public string name { get; set; }
public string path { get; set; }
public string executable { get; set; }
public bool isEnabled { get; set; }

public bool whitelisted { get; set; } // if true, can see through the HidHide cloak
public bool use_wrapper { get; set; } // if true, deploy xinput1_3.dll
public float gyrometer { get; set; } = 1.0f; // gyroscope multiplicator (remove me)
public float accelerometer { get; set; } = 1.0f; // accelerometer multiplicator (remove me)

public int steering { get; set; } = 0; // 0 = Roll, 1 = Yaw
public float antideadzone { get; set; } = 0.0f; // todo: typeme

public bool inverthorizontal { get; set; } // if true, invert horizontal axis
public bool invertvertical { get; set; } // if false, invert vertical axis

public bool umc_enabled { get; set; }

public Input umc_input { get; set; } = Input.JoystickCamera;
public Output umc_output { get; set; } = Output.RightStick;

// aiming
public float aiming_sensivity { get; set; } = 2.0f;

public List<ProfileVector> aiming_array { get; set; } = new();

// steering
public float steering_max_angle { get; set; } = 30.0f;
public float steering_power { get; set; } = 1.0f;
public float steering_deadzone { get; set; } = 0.0f;

// flickstick
public bool flickstick_enabled { get; set; } = false;
public bool flickstick_enabled { get; set; }
public float flick_duration { get; set; } = 0.1f;
public float stick_sensivity { get; set; } = 3.0f;

// power
public bool TDP_override { get; set; }
public int TDP_value { get; set; }

public GamepadButtonFlagsExt umc_trigger { get; set; } = GamepadButtonFlagsExt.AlwaysOn;

// hidden settings
[JsonIgnore] public ProfileErrorCode error;
[JsonIgnore] public string fullpath { get; set; }
[JsonIgnore] public string json { get; set; }
[JsonIgnore] public bool isDefault { get; set; } = false;
[JsonIgnore] public bool isApplied { get; set; } = false;
[JsonIgnore] public bool isDefault { get; set; }
[JsonIgnore] public bool isRunning { get; set; }
[JsonIgnore] public static int array_size = 49; // x + 1 (hidden)

public Profile()
Expand Down Expand Up @@ -110,7 +114,9 @@ public Profile(string path) : this()
this.executable = AppProperties["FileName"];
this.name = ProductName;
this.path = this.fullpath = path;
this.isEnabled = false;

// enable the below variables when profile is created
this.umc_enabled = true;
}

public float GetSensiviy()
Expand Down
Loading

0 comments on commit 08fe637

Please sign in to comment.