Added null check for method.

Should help prevent crashing on a quick connect and disconnect caused by a
bad USB cable
This commit is contained in:
Travis Nickles 2019-03-25 21:38:08 -05:00
parent ee21cba66a
commit 0d957b0bfa

View File

@ -1405,6 +1405,11 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
private void Enable_Controls(int device, bool on) private void Enable_Controls(int device, bool on)
{ {
DS4Device dev = Program.rootHub.DS4Controllers[device];
ConnectionType conType = ConnectionType.USB;
if (dev != null)
conType = dev.ConnectionType;
Pads[device].Visible = on; Pads[device].Visible = on;
ebns[device].Visible = on; ebns[device].Visible = on;
lights[device].Visible = on; lights[device].Visible = on;
@ -1412,8 +1417,7 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
shortcuts[device].Visible = on; shortcuts[device].Visible = on;
Batteries[device].Visible = on; Batteries[device].Visible = on;
linkedProfileCB[device].Visible = on; linkedProfileCB[device].Visible = on;
disconnectShortcuts[device].Visible = on && disconnectShortcuts[device].Visible = on && conType != ConnectionType.USB;
Program.rootHub.DS4Controllers[device].ConnectionType != ConnectionType.USB;
} }
protected void On_Debug(object sender, DebugEventArgs e) protected void On_Debug(object sender, DebugEventArgs e)