Skip to content

Commit

Permalink
implement default profile, improve precision and scrollbars
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie committed Dec 24, 2021
1 parent b9d20b6 commit 0934a6f
Show file tree
Hide file tree
Showing 10 changed files with 1,785 additions and 2,342 deletions.
35 changes: 10 additions & 25 deletions ControllerCommon/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ public enum InputStyle
Mouse = 3
}

public enum HapticIntensity
{
Low = 0,
Medium = 1,
High = 2,
Extreme = 3,
Insane = 4 // are you crazy !?
}

public class ProfileButton : DualShock4Button
{
public ProfileButton(int id, string name, ushort value) : base(id, name, value)
Expand All @@ -55,13 +46,15 @@ public class Profile

public bool umc_enabled { get; set; } = false;
public InputStyle umc_input { get; set; } = InputStyle.None;
public float umc_sensivity { get; set; } = 500.0f;

public HapticIntensity umc_intensity { get; set; } = HapticIntensity.Low;
public float umc_sensivity { get; set; } = 2.0f;
public float umc_intensity { get; set; } = 1.0f;

public int umc_trigger { get; set; } = 0;

[JsonIgnore] public ProfileErrorCode error;
[JsonIgnore] public string fullpath { get; set; }
[JsonIgnore] public bool IsDefault { get; set; } = false;

public Profile()
{
Expand All @@ -74,22 +67,14 @@ public Profile(string name, string path)
this.fullpath = path;
}

public float GetSensiviy()
{
return umc_sensivity * 500.0f;
}

public float GetIntensity()
{
switch (umc_intensity)
{
default:
case HapticIntensity.Low:
return 1.0f;
case HapticIntensity.Medium:
return 0.8f;
case HapticIntensity.High:
return 0.6f;
case HapticIntensity.Extreme:
return 0.4f;
case HapticIntensity.Insane:
return 0.2f;
}
return 1.0f - (umc_intensity / 20.0f) + 0.1f;
}

public override string ToString()
Expand Down
2 changes: 1 addition & 1 deletion ControllerCommon/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static byte NormalizeInput(short input)

public static short ComputeInput(short value, float input, float sensivity, float curve)
{
float compute = (float)(Math.Sign(input) * Math.Pow(Math.Abs(input) / 25.0f, curve) * 25.0f);
float compute = (float)(Math.Sign(input) * Math.Pow(Math.Abs(input) / 20.0f, curve) * 20.0f);
return (short)Math.Max(-32767, Math.Min(32767, value + compute * sensivity));
}

Expand Down
171 changes: 43 additions & 128 deletions ControllerHelper/ControllerHelper.Designer.cs

Large diffs are not rendered by default.

17 changes: 14 additions & 3 deletions ControllerHelper/ControllerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public void UpdateProcess(int ProcessId, string ProcessPath)
logger.LogInformation("Profile {0} applied", profile.name);
}
else
PipeClient.SendMessage(new PipeClientProfile() { profile = new Profile("default", "") });
PipeClient.SendMessage(new PipeClientProfile() { profile = ProfileManager.GetDefault() });
}
catch (Exception) { }
}
Expand Down Expand Up @@ -679,6 +679,9 @@ private void lB_Profiles_SelectedIndexChanged(object sender, EventArgs e)
}
else
{
// disable button if is default profile
b_DeleteProfile.Enabled = !profile.IsDefault;

gB_ProfileDetails.Enabled = true;
gB_ProfileOptions.Enabled = true;
gB_6axis.Enabled = true;
Expand All @@ -699,7 +702,7 @@ private void lB_Profiles_SelectedIndexChanged(object sender, EventArgs e)
cB_UniversalMC.Checked = profile.umc_enabled;
cB_UMCInputStyle.SelectedIndex = (int)profile.umc_input;
tB_UMCSensivity.Value = (int)profile.umc_sensivity;
cB_UMCIntensity.SelectedIndex = (int)profile.umc_intensity;
tB_UMCIntensity.Value = (int)profile.umc_intensity;

for (int idx = 0; idx < cB_UMCInputButton.Items.Count; idx++)
{
Expand Down Expand Up @@ -764,7 +767,7 @@ private void b_ApplyProfile_Click(object sender, EventArgs e)
profile.umc_enabled = cB_UniversalMC.Checked && cB_UniversalMC.Enabled;
profile.umc_input = (InputStyle)cB_UMCInputStyle.SelectedIndex;
profile.umc_sensivity = tB_UMCSensivity.Value;
profile.umc_intensity = (HapticIntensity)cB_UMCIntensity.SelectedIndex;
profile.umc_intensity = tB_UMCIntensity.Value;

profile.umc_trigger = 0;
foreach (DualShock4Button button in cB_UMCInputButton.SelectedItems)
Expand Down Expand Up @@ -819,6 +822,14 @@ private void cB_UMCInputStyle_SelectedIndexChanged(object sender, EventArgs e)
cB_UMCInputButton.Enabled = cB_UMCInputStyle.SelectedIndex != 0;
}

private void tB_UMCIntensity_Scroll(object sender, EventArgs e)
{
BeginInvoke((MethodInvoker)delegate ()
{
toolTip1.SetToolTip(tB_UMCIntensity, $"value: {tB_UMCIntensity.Value}");
});
}

private void cB_HIDcloak_CheckedChanged(object sender, EventArgs e)
{
PipeClient.SendMessage(new PipeClientSettings
Expand Down
3 changes: 3 additions & 0 deletions ControllerHelper/ControllerHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
<None Update="profiles\AYASpace.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="profiles\Default.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="profiles\Cemu.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Loading

0 comments on commit 0934a6f

Please sign in to comment.