From e07f902751a4abc77447035ce9b3b8be43fcaea1 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Thu, 19 Oct 2017 03:21:33 -0500 Subject: [PATCH] Only load profiles as needed rather than at program startup --- DS4Windows/DS4Control/ControlService.cs | 6 ++++-- DS4Windows/DS4Forms/DS4Form.cs | 14 +++++--------- DS4Windows/DS4Library/DS4Device.cs | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index 9ea0fdb..61733c9 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -116,6 +116,7 @@ namespace DS4Windows device.SyncChange += this.On_SyncChange; device.SyncChange += DS4Devices.UpdateSerial; device.SerialChange += this.On_SerialChange; + LoadProfile(i, false, this, false); touchPad[i] = new Mouse(i, device); device.LightBarColor = getMainColor(i); @@ -294,6 +295,7 @@ namespace DS4Windows device.SyncChange += this.On_SyncChange; device.SyncChange += DS4Devices.UpdateSerial; device.SerialChange += this.On_SerialChange; + LoadProfile(i, false, this, false); touchPad[Index] = new Mouse(Index, device); device.LightBarColor = getMainColor(Index); device.Report += this.On_Report; @@ -729,9 +731,9 @@ namespace DS4Windows //device.getPreviousState(PreviousState[ind]); //DS4State pState = PreviousState[ind]; - if (!device.firstReport && device.IsAlive()) + if (device.firstReport && device.IsAlive()) { - device.firstReport = true; + device.firstReport = false; device.getUiContext()?.Post(new SendOrPostCallback(delegate (object state) { OnDeviceStatusChanged(this, ind); diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 90a1bd7..e363676 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -308,15 +308,6 @@ namespace DS4Windows opt.FormBorderStyle = FormBorderStyle.None; tabProfiles.Controls.Add(opt); - for (int i = 0; i < 4; i++) - { - LoadProfile(i, false, Program.rootHub, false); - if (UseCustomLed[i]) - lights[i].BackColor = CustomColor[i].ToColorA; - else - lights[i].BackColor = MainColor[i].ToColorA; - } - autoProfilesTimer.Elapsed += CheckAutoProfiles; autoProfilesTimer.Interval = 1000; @@ -1209,6 +1200,11 @@ namespace DS4Windows } Batteries[Index].Text = Program.rootHub.getDS4Battery(Index); + if (UseCustomLed[Index]) + lights[Index].BackColor = CustomColor[Index].ToColorA; + else + lights[Index].BackColor = MainColor[Index].ToColorA; + if (Pads[Index].Text != String.Empty) { if (runningBat) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index e4dbbbc..9b0ef71 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -659,7 +659,7 @@ namespace DS4Windows public double Latency = 0.0; public string error; - public bool firstReport = false; + public bool firstReport = true; public bool oldCharging = false; double curTimeDouble = 0.0; double oldTimeDouble = 0.0;