Only load profiles as needed rather than at program startup

This commit is contained in:
Travis Nickles 2017-10-19 03:21:33 -05:00
parent d9ee5d3263
commit e07f902751
3 changed files with 10 additions and 12 deletions

View File

@ -116,6 +116,7 @@ namespace DS4Windows
device.SyncChange += this.On_SyncChange; device.SyncChange += this.On_SyncChange;
device.SyncChange += DS4Devices.UpdateSerial; device.SyncChange += DS4Devices.UpdateSerial;
device.SerialChange += this.On_SerialChange; device.SerialChange += this.On_SerialChange;
LoadProfile(i, false, this, false);
touchPad[i] = new Mouse(i, device); touchPad[i] = new Mouse(i, device);
device.LightBarColor = getMainColor(i); device.LightBarColor = getMainColor(i);
@ -294,6 +295,7 @@ namespace DS4Windows
device.SyncChange += this.On_SyncChange; device.SyncChange += this.On_SyncChange;
device.SyncChange += DS4Devices.UpdateSerial; device.SyncChange += DS4Devices.UpdateSerial;
device.SerialChange += this.On_SerialChange; device.SerialChange += this.On_SerialChange;
LoadProfile(i, false, this, false);
touchPad[Index] = new Mouse(Index, device); touchPad[Index] = new Mouse(Index, device);
device.LightBarColor = getMainColor(Index); device.LightBarColor = getMainColor(Index);
device.Report += this.On_Report; device.Report += this.On_Report;
@ -729,9 +731,9 @@ namespace DS4Windows
//device.getPreviousState(PreviousState[ind]); //device.getPreviousState(PreviousState[ind]);
//DS4State pState = 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) device.getUiContext()?.Post(new SendOrPostCallback(delegate (object state)
{ {
OnDeviceStatusChanged(this, ind); OnDeviceStatusChanged(this, ind);

View File

@ -308,15 +308,6 @@ namespace DS4Windows
opt.FormBorderStyle = FormBorderStyle.None; opt.FormBorderStyle = FormBorderStyle.None;
tabProfiles.Controls.Add(opt); 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.Elapsed += CheckAutoProfiles;
autoProfilesTimer.Interval = 1000; autoProfilesTimer.Interval = 1000;
@ -1209,6 +1200,11 @@ namespace DS4Windows
} }
Batteries[Index].Text = Program.rootHub.getDS4Battery(Index); 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 (Pads[Index].Text != String.Empty)
{ {
if (runningBat) if (runningBat)

View File

@ -659,7 +659,7 @@ namespace DS4Windows
public double Latency = 0.0; public double Latency = 0.0;
public string error; public string error;
public bool firstReport = false; public bool firstReport = true;
public bool oldCharging = false; public bool oldCharging = false;
double curTimeDouble = 0.0; double curTimeDouble = 0.0;
double oldTimeDouble = 0.0; double oldTimeDouble = 0.0;