better deadzone with desktop fixed

This commit is contained in:
DavidRGriswold 2023-09-02 23:47:27 -03:00
parent ca6ac7b0fc
commit 288546b7d7
5 changed files with 27 additions and 38 deletions

View file

@ -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;

View file

@ -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;
}
}
}

View file

@ -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
);
}
}
}

View file

@ -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;

View file

@ -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;