From f321b56f9875368e30dd770670a33054f4a4b181 Mon Sep 17 00:00:00 2001 From: Cameron Beeley Date: Fri, 10 Jul 2026 17:57:51 +0100 Subject: [PATCH] Remove unreferenced private members Roslyn analyzers (IDE0051/CS0169) flag 53 private members as never referenced anywhere in the compilation. Remove them: the unused pass-through getters in DS4StateExposed, dead named constants across the device classes, and orphaned private helper methods. Pure deletion, no behavior change. --- DS4Windows/DS4Control/ControlService.cs | 1 - DS4Windows/DS4Control/Mapping.cs | 23 ------ DS4Windows/DS4Control/Mouse.cs | 10 --- DS4Windows/DS4Control/ScpUtil.cs | 73 ------------------- DS4Windows/DS4Forms/MainWindow.xaml.cs | 1 - DS4Windows/DS4Forms/RecordBox.xaml.cs | 11 --- .../ViewModels/CurrentOutDeviceViewModel.cs | 41 ----------- .../DS4Forms/ViewModels/TrayIconViewModel.cs | 2 - DS4Windows/DS4Library/DS4StateExposed.cs | 28 ------- .../DS4Library/InputDevices/JoyConDevice.cs | 8 -- .../InputDevices/SwitchProDevice.cs | 5 -- 11 files changed, 203 deletions(-) diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index 22cecdb..132b7f0 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -88,7 +88,6 @@ public class ControlService new OneEuroFilter3D(), new OneEuroFilter3D(), }; Thread tempThread; - Thread tempBusThread; Thread eventDispatchThread; Dispatcher eventDispatcher; public bool suspending; diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 077950a..43a5621 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -836,7 +836,6 @@ public class DeltaSettingsProcessorGroup 50, // DS4Controls.BLP 51, // DS4Controls.BRP }; - private static int macroEndIndex = DS4_CONTROL_MACRO_ARRAY_LEN - 1; // Special macros static bool altTabDone = true; @@ -849,9 +848,6 @@ public class DeltaSettingsProcessorGroup public static int prevmouseaccel = 0; private static double horizontalRemainder = 0.0, verticalRemainder = 0.0; public const int MOUSESPEEDFACTOR = 48; - private const double MOUSESTICKANTIOFFSET = 0.0128; - private const double MOUSESTICKMINVELOCITY = 67.5; - //private const double MOUSESTICKMINVELOCITY = 40.0; private static void RequestProfileSwitch(int device, string profileName, bool tempProfile, bool launchProgram, ControlService ctrl, Action afterLoad = null) @@ -1186,12 +1182,6 @@ public static int DS4ControltoInt(DS4Controls ctrl) return result; } - static double TValue(double value1, double value2, double percent) - { - percent /= 100f; - return value1 * percent + value2 * (1 - percent); - } - private static int ClampInt(int min, int value, int max) { return (value < min) ? min : (value > max) ? max : value; @@ -4044,11 +4034,6 @@ private static void RunLightbarMacro(ObservableCollection } } - private static bool IfAxisIsNotModified(int device, bool shift, DS4Controls dc) - { - return shift ? false : GetDS4CSetting(device, dc).actionType == DS4ControlSettings.ActionType.Default; - } - private static async void MapCustomAction(int device, DS4State cState, DS4State MappedState, DS4StateExposed eState, Mouse tp, ControlService ctrl, DS4StateFieldMapping fieldMapping, DS4StateFieldMapping outputfieldMapping) { @@ -5054,14 +5039,6 @@ private static bool PlayMacroCodeValue(int device, bool[] macrocontrol, DS4KeyTy return doDelayOnCaller; } - private static void EndMacro(int device, bool[] macrocontrol, string macro, DS4Controls control) - { - if ((macro.StartsWith("164/9/9/164") || macro.StartsWith("18/9/9/18")) && !altTabDone) - AltTabSwappingRelease(); - - if (control != DS4Controls.None) - macrodone[DS4ControltoInt(control)] = false; - } private static void EndMacro(int device, bool[] macrocontrol, List macro, DS4Controls control) { diff --git a/DS4Windows/DS4Control/Mouse.cs b/DS4Windows/DS4Control/Mouse.cs index 085676a..c94ba8d 100644 --- a/DS4Windows/DS4Control/Mouse.cs +++ b/DS4Windows/DS4Control/Mouse.cs @@ -1515,16 +1515,6 @@ private bool isRight(Touch t) return t.HwX >= 1920 * 2 / 5; } - private void AddEmptyTrackballEntry() - { - int iIndex = trackballBufferTail; - trackballXBuffer[iIndex] = 0; - trackballYBuffer[iIndex] = 0; - trackballBufferTail = (iIndex + 1) % TRACKBALL_BUFFER_LEN; - if (trackballBufferHead == trackballBufferTail) - trackballBufferHead = (trackballBufferHead + 1) % TRACKBALL_BUFFER_LEN; - } - private void ClearTouchMouseTrackballData() { Array.Clear(trackballXBuffer, 0, TRACKBALL_BUFFER_LEN); diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index e5460cd..575e7b9 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -3138,27 +3138,6 @@ public static DS4Color getTransitionedColor(ref DS4Color c1, ref DS4Color c2, do return cs; } - private static Color applyRatio(Color c1, Color c2, uint r) - { - float ratio = r / 100f; - float hue1 = c1.GetHue(); - float hue2 = c2.GetHue(); - float bri1 = c1.GetBrightness(); - float bri2 = c2.GetBrightness(); - float sat1 = c1.GetSaturation(); - float sat2 = c2.GetSaturation(); - float hr = hue2 - hue1; - float br = bri2 - bri1; - float sr = sat2 - sat1; - Color csR; - if (bri1 == 0) - csR = HuetoRGB(hue2, sat2, bri2 - br * ratio); - else - csR = HuetoRGB(hue2 - hr * ratio, sat2 - sr * ratio, bri2 - br * ratio); - - return csR; - } - public static Color HuetoRGB(float hue, float sat, float bri) { float C = (1 - Math.Abs(2 * bri) - 1) * sat; @@ -3204,10 +3183,6 @@ public static double Clamp(double min, double value, double max) return (value < min) ? min : (value > max) ? max : value; } - private static int ClampInt(int min, int value, int max) - { - return (value < min) ? min : (value > max) ? max : value; - } public static void InitOutputKBMHandler(string identifier) { @@ -4404,54 +4379,6 @@ private void PortOldGyroSettings(int device) } } - private string GetGyroOutModeString(GyroOutMode mode) - { - string result = "None"; - switch (mode) - { - case GyroOutMode.Controls: - result = "Controls"; - break; - case GyroOutMode.Mouse: - result = "Mouse"; - break; - case GyroOutMode.MouseJoystick: - result = "MouseJoystick"; - break; - case GyroOutMode.Passthru: - result = "Passthru"; - break; - default: - break; - } - - return result; - } - - private GyroOutMode GetGyroOutModeType(string modeString) - { - GyroOutMode result = GyroOutMode.None; - switch (modeString) - { - case "Controls": - result = GyroOutMode.Controls; - break; - case "Mouse": - result = GyroOutMode.Mouse; - break; - case "MouseJoystick": - result = GyroOutMode.MouseJoystick; - break; - case "Passthru": - result = GyroOutMode.Passthru; - break; - default: - break; - } - - return result; - } - private string GetLightbarModeString(LightbarMode mode) { string result = "DS4Win"; diff --git a/DS4Windows/DS4Forms/MainWindow.xaml.cs b/DS4Windows/DS4Forms/MainWindow.xaml.cs index ac527f3..af58e47 100644 --- a/DS4Windows/DS4Forms/MainWindow.xaml.cs +++ b/DS4Windows/DS4Forms/MainWindow.xaml.cs @@ -1151,7 +1151,6 @@ protected override void OnSourceInitialized(EventArgs e) private bool inHotPlug = false; private int hotplugCounter = 0; private object hotplugCounterLock = new object(); - private const int DBT_DEVNODES_CHANGED = 0x0007; private const int DBT_DEVICEARRIVAL = 0x8000; private const int DBT_DEVICEREMOVECOMPLETE = 0x8004; public const int WM_COPYDATA = 0x004A; diff --git a/DS4Windows/DS4Forms/RecordBox.xaml.cs b/DS4Windows/DS4Forms/RecordBox.xaml.cs index 6b5711e..92fde35 100644 --- a/DS4Windows/DS4Forms/RecordBox.xaml.cs +++ b/DS4Windows/DS4Forms/RecordBox.xaml.cs @@ -432,17 +432,6 @@ private void MacroListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e } } - private void RevertListItemTemplate() - { - if (recordBoxVM.EditMacroIndex >= 0) - { - ListBoxItem lbitem = macroListBox.ItemContainerGenerator.ContainerFromIndex(recordBoxVM.EditMacroIndex) - as ListBoxItem; - lbitem.ContentTemplate = this.FindResource("DisplayTemplate") as DataTemplate; - recordBoxVM.EditMacroIndex = -1; - } - } - private void UpdateDataRevertTemplate() { ListBoxItem lbitem = macroListBox.ItemContainerGenerator.ContainerFromIndex(recordBoxVM.EditMacroIndex) diff --git a/DS4Windows/DS4Forms/ViewModels/CurrentOutDeviceViewModel.cs b/DS4Windows/DS4Forms/ViewModels/CurrentOutDeviceViewModel.cs index c681c11..7e573b2 100644 --- a/DS4Windows/DS4Forms/ViewModels/CurrentOutDeviceViewModel.cs +++ b/DS4Windows/DS4Forms/ViewModels/CurrentOutDeviceViewModel.cs @@ -372,26 +372,6 @@ private void SlotDeviceEntry_FormPropChanged(object sender, EventArgs e) Dirty = true; } - private int DetermineDesiredChoiceIdx() - { - int result = 0; - switch (outSlotDevice.PermanentType) - { - case OutContType.None: - result = 0; - break; - case OutContType.X360: - result = 1; - break; - case OutContType.DS4: - result = 2; - break; - default: - break; - } - return result; - } - private int DetermineReserveChoiceIdx() { int result = 0; @@ -410,27 +390,6 @@ private int DetermineReserveChoiceIdx() return result; } - private OutContType DetermineDesiredTypeFromIdx() - { - OutContType result = OutContType.None; - switch (desiredTypeChoiceIndex) - { - case 0: - result = OutContType.None; - break; - case 1: - result = OutContType.X360; - break; - case 2: - result = OutContType.DS4; - break; - default: - break; - } - - return result; - } - private OutSlotDevice.ReserveStatus DetermineReserveChoiceFromIdx() { OutSlotDevice.ReserveStatus result = OutSlotDevice.ReserveStatus.Dynamic; diff --git a/DS4Windows/DS4Forms/ViewModels/TrayIconViewModel.cs b/DS4Windows/DS4Forms/ViewModels/TrayIconViewModel.cs index 8db2034..8401785 100644 --- a/DS4Windows/DS4Forms/ViewModels/TrayIconViewModel.cs +++ b/DS4Windows/DS4Forms/ViewModels/TrayIconViewModel.cs @@ -39,8 +39,6 @@ public class TrayIconViewModel private MenuItem minimizeItem; private MenuItem openProgramItem; private MenuItem closeItem; - private int? prevBattery = null; - public string TooltipText { diff --git a/DS4Windows/DS4Library/DS4StateExposed.cs b/DS4Windows/DS4Library/DS4StateExposed.cs index 9200722..225ad24 100644 --- a/DS4Windows/DS4Library/DS4StateExposed.cs +++ b/DS4Windows/DS4Library/DS4StateExposed.cs @@ -32,34 +32,6 @@ public DS4StateExposed(DS4State state) _state = state; } - bool Square { get { return _state.Square; } } - bool Triangle { get { return _state.Triangle; } } - bool Circle { get { return _state.Circle; } } - bool Cross { get { return _state.Cross; } } - bool DpadUp { get { return _state.DpadUp; } } - bool DpadDown { get { return _state.DpadDown; } } - bool DpadLeft { get { return _state.DpadLeft; } } - bool DpadRight { get { return _state.DpadRight; } } - bool L1 { get { return _state.L1; } } - bool L3 { get { return _state.L3; } } - bool R1 { get { return _state.R1; } } - bool R3 { get { return _state.R3; } } - bool Share { get { return _state.Share; } } - bool Options { get { return _state.Options; } } - bool PS { get { return _state.PS; } } - bool Touch1 { get { return _state.Touch1; } } - bool Touch2 { get { return _state.Touch2; } } - bool TouchButton { get { return _state.TouchButton; } } - bool Touch1Finger { get { return _state.Touch1Finger; } } - bool Touch2Fingers { get { return _state.Touch2Fingers; } } - byte LX { get { return _state.LX; } } - byte RX { get { return _state.RX; } } - byte LY { get { return _state.LY; } } - byte RY { get { return _state.RY; } } - byte L2 { get { return _state.L2; } } - byte R2 { get { return _state.R2; } } - int Battery { get { return _state.Battery; } } - public SixAxis Motion { get => _state.Motion; diff --git a/DS4Windows/DS4Library/InputDevices/JoyConDevice.cs b/DS4Windows/DS4Library/InputDevices/JoyConDevice.cs index 76dce42..12db170 100644 --- a/DS4Windows/DS4Library/InputDevices/JoyConDevice.cs +++ b/DS4Windows/DS4Library/InputDevices/JoyConDevice.cs @@ -62,12 +62,8 @@ public enum JoyConSide : uint Right, } - private const int AMP_REAL_MIN = 0; //private const int AMP_REAL_MAX = 1003; private const int AMP_LIMIT_MAX = 404; - private const int AMP_LIMIT_L_MAX = 404; - //private const int AMP_LIMIT_R_MAX = 206; - private const int AMP_LIMIT_R_MAX = 404; private static RumbleTableData[] fixedRumbleTable = new RumbleTableData[] { @@ -161,8 +157,6 @@ public struct StickAxisData public const int IMU_YAXIS_IDX = 1, IMU_PITCH_IDX = 1; public const int IMU_ZAXIS_IDX = 2, IMU_ROLL_IDX = 2; - private const double STICK_AXIS_MAX_CUTOFF = 0.96; - private const double STICK_AXIS_MIN_CUTOFF = 1.04; private const double STICK_AXIS_LS_X_MAX_CUTOFF = 0.96; private const double STICK_AXIS_LS_X_MIN_CUTOFF = 1.04; @@ -175,7 +169,6 @@ public struct StickAxisData private const double STICK_AXIS_RS_Y_MAX_CUTOFF = 0.96; private const double STICK_AXIS_RS_Y_MIN_CUTOFF = 1.14; - private const string BLUETOOTH_HID_GUID = "{00001124-0000-1000-8000-00805F9B34FB}"; private byte frameCount = 0; public byte FrameCount { get => frameCount; set => frameCount = value; } @@ -213,7 +206,6 @@ public struct StickAxisData // Converts raw gyro input value to dps. Equal to (4588/65535) private const float GYRO_IN_DEG_SEC_FACTOR = 0.070f; private new const int WARN_INTERVAL_BT = 40; - private new const int WARN_INTERVAL_USB = 30; private byte[] inputReportBuffer; private byte[] outputReportBuffer; private byte[] rumbleReportBuffer; diff --git a/DS4Windows/DS4Library/InputDevices/SwitchProDevice.cs b/DS4Windows/DS4Library/InputDevices/SwitchProDevice.cs index 7782942..f104a61 100644 --- a/DS4Windows/DS4Library/InputDevices/SwitchProDevice.cs +++ b/DS4Windows/DS4Library/InputDevices/SwitchProDevice.cs @@ -55,7 +55,6 @@ public static class SwitchProSubCmd public const byte ENABLE_VIBRATION = 0x48; } - private const int AMP_REAL_MIN = 0; //private const int AMP_REAL_MAX = 1003; //private const int AMP_LIMIT_MAX = 404; private const int AMP_LIMIT_MAX = 800; @@ -820,10 +819,6 @@ private void RunUSBSetup() //result = hidDevice.WriteOutputReportViaInterrupt(command, 500); } - // Deprecated method. Leave a stub for now - private void RunBluetoothSetup() - { - } private void EnableFastPollRate() {