From 288546b7d70c46d9a630b73334b5779d4ae4f819 Mon Sep 17 00:00:00 2001 From: DavidRGriswold Date: Sat, 2 Sep 2023 23:47:27 -0300 Subject: [PATCH] better deadzone with desktop fixed --- SteamController/Devices/SteamAction.cs | 17 +---------------- SteamController/Devices/SteamButtons.cs | 14 ++++---------- .../Profiles/Default/GuideShortcutsProfile.cs | 13 +++++++++---- .../Profiles/Predefined/DS4Profile.cs | 11 +++++++---- .../Profiles/Predefined/X360Profile.cs | 10 ++++++---- 5 files changed, 27 insertions(+), 38 deletions(-) diff --git a/SteamController/Devices/SteamAction.cs b/SteamController/Devices/SteamAction.cs index ca1569c..4ebfd68 100644 --- a/SteamController/Devices/SteamAction.cs +++ b/SteamController/Devices/SteamAction.cs @@ -276,8 +276,6 @@ namespace SteamController.Devices public bool UseDeadzoneSetting {get; internal set;} = false; public short MinChange { get; internal set; } = 10; public DeltaValueMode DeltaValueMode { get; internal set; } = DeltaValueMode.Absolute; - public SteamAxis? PartnerAxis { get; internal set; } - public short Value { get { return ValueCanBeUsed ? rawValue : (short)0; } @@ -295,11 +293,7 @@ namespace SteamController.Devices public static implicit operator bool(SteamAxis button) => button.Active; public static implicit operator short(SteamAxis button) { - if (button.UseDeadzoneSetting) - button.Deadzone = Settings.Default.JoystickDeadZone; - int pValue = button.PartnerAxis?.Value ?? button.Value; - int dzValue = pValue == button.Value ? button.Value : (int)Math.Sqrt(pValue * pValue + button.Value * button.Value); - return dzValue > button.Deadzone ? button.Value : (short)0; + return button.Value; } public bool Active @@ -318,22 +312,13 @@ namespace SteamController.Devices { int value = 0; - int pValue = PartnerAxis?.Value ?? Value; - if (UseDeadzoneSetting) Deadzone = Settings.Default.JoystickDeadZone; - int dzValue = (int)Math.Sqrt(pValue * pValue + Value * Value); - switch (mode) { case DeltaValueMode.Absolute: - if (Math.Abs(dzValue) < Deadzone) - return 0.0; value = Value; break; case DeltaValueMode.AbsoluteTime: - - if (Math.Abs(dzValue) < Deadzone) - return 0.0; value = (int)(Value * (Controller?.DeltaTime ?? 0.0)); break; diff --git a/SteamController/Devices/SteamButtons.cs b/SteamController/Devices/SteamButtons.cs index d9c71e5..a9fd1c4 100644 --- a/SteamController/Devices/SteamButtons.cs +++ b/SteamController/Devices/SteamButtons.cs @@ -52,10 +52,10 @@ namespace SteamController.Devices public readonly SteamAxis GyroYaw = new SteamAxis(0x22); public readonly SteamAxis LeftTrigger = new SteamAxis(0x2C); public readonly SteamAxis RightTrigger = new SteamAxis(0x2E); - public readonly SteamAxis LeftThumbX = new SteamAxis(0x30) {UseDeadzoneSetting = true, MinChange = 10, DeltaValueMode = Devices.DeltaValueMode.AbsoluteTime }; - public readonly SteamAxis LeftThumbY = new SteamAxis(0x32) {UseDeadzoneSetting = true, MinChange = 10, DeltaValueMode = Devices.DeltaValueMode.AbsoluteTime }; - public readonly SteamAxis RightThumbX = new SteamAxis(0x34) {UseDeadzoneSetting = true, MinChange = 10, DeltaValueMode = Devices.DeltaValueMode.AbsoluteTime }; - public readonly SteamAxis RightThumbY = new SteamAxis(0x36) {UseDeadzoneSetting = true, MinChange = 10, DeltaValueMode = Devices.DeltaValueMode.AbsoluteTime }; + public readonly SteamAxis LeftThumbX = new SteamAxis(0x30) {MinChange = 10, DeltaValueMode = Devices.DeltaValueMode.AbsoluteTime }; + public readonly SteamAxis LeftThumbY = new SteamAxis(0x32) {MinChange = 10, DeltaValueMode = Devices.DeltaValueMode.AbsoluteTime }; + public readonly SteamAxis RightThumbX = new SteamAxis(0x34) {MinChange = 10, DeltaValueMode = Devices.DeltaValueMode.AbsoluteTime }; + public readonly SteamAxis RightThumbY = new SteamAxis(0x36) {MinChange = 10, DeltaValueMode = Devices.DeltaValueMode.AbsoluteTime }; public readonly SteamAxis LPadPressure = new SteamAxis(0x38); public readonly SteamAxis RPadPressure = new SteamAxis(0x38); @@ -71,12 +71,6 @@ namespace SteamController.Devices LeftThumbX.VirtualRight = BtnVirtualLeftThumbRight; LeftThumbY.VirtualLeft = BtnVirtualLeftThumbDown; LeftThumbY.VirtualRight = BtnVirtualLeftThumbUp; - - // set partner axes for circle deadzone - LeftThumbX.PartnerAxis = LeftThumbY; - LeftThumbY.PartnerAxis = LeftThumbX; - RightThumbX.PartnerAxis = RightThumbY; - RightThumbY.PartnerAxis = RightThumbX; } } } diff --git a/SteamController/Profiles/Default/GuideShortcutsProfile.cs b/SteamController/Profiles/Default/GuideShortcutsProfile.cs index 13a32b2..72698aa 100644 --- a/SteamController/Profiles/Default/GuideShortcutsProfile.cs +++ b/SteamController/Profiles/Default/GuideShortcutsProfile.cs @@ -129,10 +129,15 @@ namespace SteamController.Profiles.Default { if (c.Steam.RightThumbX || c.Steam.RightThumbY) { - c.Mouse.MoveBy( - c.Steam.RightThumbX.DeltaValue * Context.JoystickToMouseSensitivity, - -c.Steam.RightThumbY.DeltaValue * Context.JoystickToMouseSensitivity - ); + //use hardwired dead zone of 5000 for desktop mode + double dzcheck = Math.Sqrt(c.Steam.RightThumbX.Value*c.Steam.RightThumbX.Value + c.Steam.RightThumbY.Value*c.Steam.RightThumbY.Value); + if (dzcheck > 5000) { + c.Mouse.MoveBy( + c.Steam.RightThumbX.DeltaValue * Context.JoystickToMouseSensitivity, + -c.Steam.RightThumbY.DeltaValue * Context.JoystickToMouseSensitivity + ); + } + } } diff --git a/SteamController/Profiles/Predefined/DS4Profile.cs b/SteamController/Profiles/Predefined/DS4Profile.cs index a8586a0..48152f3 100644 --- a/SteamController/Profiles/Predefined/DS4Profile.cs +++ b/SteamController/Profiles/Predefined/DS4Profile.cs @@ -80,10 +80,13 @@ namespace SteamController.Profiles.Predefined context.DS4[DS4Controller.Triangle] = context.Steam.BtnY; // Sticks - context.DS4[DS4Controller.LeftThumbX] = context.Steam.LeftThumbX; - context.DS4[DS4Controller.LeftThumbY] = context.Steam.LeftThumbY; - context.DS4[DS4Controller.RightThumbX] = context.Steam.RightThumbX; - context.DS4[DS4Controller.RightThumbY] = context.Steam.RightThumbY; + double dzcheckR = Math.Sqrt(context.Steam.RightThumbX.Value*context.Steam.RightThumbX.Value + context.Steam.RightThumbY.Value*context.Steam.RightThumbY.Value); + double dzcheckL = Math.Sqrt(context.Steam.LeftThumbX.Value*context.Steam.LeftThumbX.Value + context.Steam.LeftThumbY.Value*context.Steam.LeftThumbY.Value); + + context.DS4[DS4Controller.LeftThumbX] = dzcheckL < Settings.Default.JoystickDeadZone ? (short)0: context.Steam.LeftThumbX; + context.DS4[DS4Controller.LeftThumbY] = dzcheckL < Settings.Default.JoystickDeadZone ? (short)0: context.Steam.LeftThumbY; + context.DS4[DS4Controller.RightThumbX] = dzcheckR < Settings.Default.JoystickDeadZone ? (short)0: context.Steam.RightThumbX; + context.DS4[DS4Controller.RightThumbY] = dzcheckR < Settings.Default.JoystickDeadZone ? (short)0: context.Steam.RightThumbY; context.DS4[DS4Controller.ThumbLeft] = context.Steam.BtnLeftStickPress; context.DS4[DS4Controller.ThumbRight] = context.Steam.BtnRightStickPress; diff --git a/SteamController/Profiles/Predefined/X360Profile.cs b/SteamController/Profiles/Predefined/X360Profile.cs index 021b038..8d3aba9 100644 --- a/SteamController/Profiles/Predefined/X360Profile.cs +++ b/SteamController/Profiles/Predefined/X360Profile.cs @@ -88,10 +88,12 @@ namespace SteamController.Profiles.Predefined context.X360[Xbox360Button.Y] = context.Steam.BtnY; // Sticks - context.X360[Xbox360Axis.LeftThumbX] = context.Steam.LeftThumbX; - context.X360[Xbox360Axis.LeftThumbY] = context.Steam.LeftThumbY; - context.X360[Xbox360Axis.RightThumbX] = context.Steam.RightThumbX; - context.X360[Xbox360Axis.RightThumbY] = context.Steam.RightThumbY; + double dzcheckR = Math.Sqrt(context.Steam.RightThumbX.Value*context.Steam.RightThumbX.Value + context.Steam.RightThumbY.Value*context.Steam.RightThumbY.Value); + double dzcheckL = Math.Sqrt(context.Steam.LeftThumbX.Value*context.Steam.LeftThumbX.Value + context.Steam.LeftThumbY.Value*context.Steam.LeftThumbY.Value); + context.X360[Xbox360Axis.LeftThumbX] = dzcheckL < Settings.Default.JoystickDeadZone ? (short)0: context.Steam.LeftThumbX; + context.X360[Xbox360Axis.LeftThumbY] = dzcheckL < Settings.Default.JoystickDeadZone ? (short)0: context.Steam.LeftThumbY; + context.X360[Xbox360Axis.RightThumbX] = dzcheckR < Settings.Default.JoystickDeadZone ? (short)0: context.Steam.RightThumbX; + context.X360[Xbox360Axis.RightThumbY] = dzcheckR < Settings.Default.JoystickDeadZone ? (short)0: context.Steam.RightThumbY; context.X360[Xbox360Button.LeftThumb] = context.Steam.BtnLeftStickPress; context.X360[Xbox360Button.RightThumb] = context.Steam.BtnRightStickPress;