From f050df5f81991e11f63654638908fdda3d31d222 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Fri, 7 Apr 2017 08:59:15 -0700 Subject: [PATCH] Change input delay warning status depending on connection type. No longer use a fixed interval --- DS4Windows/DS4Forms/Options.cs | 10 ++++++---- DS4Windows/DS4Library/DS4Device.cs | 7 ++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index 6225f63..15043a6 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -593,7 +593,8 @@ namespace DS4Windows // MEMS gyro data is all calibrated to roughly -1G..1G for values -0x2000..0x1fff // Enough additional acceleration and we are no longer mostly measuring Earth's gravity... // We should try to indicate setpoints of the calibration when exposing this measurement.... - if (Program.rootHub.DS4Controllers[(int)nUDSixaxis.Value - 1] == null) + DS4Device ds = Program.rootHub.DS4Controllers[(int)nUDSixaxis.Value - 1]; + if (ds == null) { EnableReadings(false); lbInputDelay.Text = Properties.Resources.InputDelay.Replace("*number*", Properties.Resources.NA); @@ -719,14 +720,15 @@ namespace DS4Windows lbR2Track.ForeColor = Color.Black; - double latency = Program.rootHub.DS4Controllers[(int)nUDSixaxis.Value - 1].Latency; + double latency = ds.Latency; + int warnInterval = ds.getWarnInterval(); lbInputDelay.Text = Properties.Resources.InputDelay.Replace("*number*", latency.ToString()); - if (latency > 10) + if (latency > warnInterval) { lbInputDelay.BackColor = Color.Red; lbInputDelay.ForeColor = Color.White; } - else if (latency > 5) + else if (latency > (warnInterval / 2)) { lbInputDelay.BackColor = Color.Yellow; lbInputDelay.ForeColor = Color.Black; diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 8454086..330b0b2 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -87,7 +87,7 @@ namespace DS4Windows public override string ToString() => $"Red: {red} Green: {green} Blue: {blue}"; } - public enum ConnectionType : byte { BT, USB, SONYWA }; // Prioritize Bluetooth when both BT and USB are connected. + public enum ConnectionType : byte { BT, SONYWA, USB }; // Prioritize Bluetooth when both BT and USB are connected. /** * The haptics engine uses a stack of these states representing the light bar and rumble motor settings. @@ -145,6 +145,11 @@ namespace DS4Windows private bool charging; private bool outputRumble = false; private int warnInterval = WARN_INTERVAL_USB; + public int getWarnInterval() + { + return warnInterval; + } + private bool exitOutputThread = false; private object exitLocker = new object(); public event EventHandler Report = null;