Add null extras detection when opening button mapping window

This commit is contained in:
Travis Nickles 2017-03-28 18:41:17 -07:00
parent ac4017fea2
commit 5ad4e83b58
2 changed files with 56 additions and 46 deletions

View File

@ -716,7 +716,7 @@ namespace DS4Windows
static int[] oldmouse = new int[4] { -1, -1, -1, -1 };
public static void MapCustom(int device, DS4State cState, DS4State MappedState, DS4StateExposed eState, Mouse tp, ControlService ctrl)
{
/* TODO: This method is slow sauce. Find ways to speed up action execution */
MappedState.LX = 127;
MappedState.LY = 127;
MappedState.RX = 127;

View File

@ -509,55 +509,65 @@ namespace DS4Windows
}
}
}
string[] extras = Global.GetDS4Extra(device, button.Name, rBShiftModifer.Checked).Split(',');
int b;
try
string dcExtras = Global.GetDS4Extra(device, button.Name, rBShiftModifer.Checked);
string[] extras = null;
if (!string.IsNullOrEmpty(dcExtras))
{
if (int.TryParse(extras[0], out b)) nUDHeavy.Value = b;
if (int.TryParse(extras[1], out b)) nUDLight.Value = b;
if (int.TryParse(extras[2], out b))
if (b == 1)
{
cBLightbar.Checked = true;
if (int.TryParse(extras[3], out b)) tBRedBar.Value = b;
if (int.TryParse(extras[4], out b)) tBGreenBar.Value = b;
if (int.TryParse(extras[5], out b)) tBBlueBar.Value = b;
if (int.TryParse(extras[6], out b)) nUDLightFlash.Value = b;
}
else
{
tBRedBar.Value = 255;
tBGreenBar.Value = 255;
tBBlueBar.Value = 255;
nUDLightFlash.Value = 0;
cBLightbar.Checked = false;
}
if (int.TryParse(extras[7], out b))
if (b == 1)
{
cBMouse.Checked = true;
if (int.TryParse(extras[8], out b)) nUDMouse.Value = b;
}
else
{
nUDMouse.Value = 25;
cBMouse.Checked = false;
}
extras = dcExtras.Split(',');
}
catch
if (extras != null)
{
nUDHeavy.Value = 0;
nUDLight.Value = 0;
tBRedBar.Value = 255;
tBGreenBar.Value = 255;
tBBlueBar.Value = 255;
nUDLightFlash.Value = 0;
cBLightbar.Checked = false;
nUDMouse.Value = 25;
cBMouse.Checked = false;
int b;
try
{
if (int.TryParse(extras[0], out b)) nUDHeavy.Value = b;
if (int.TryParse(extras[1], out b)) nUDLight.Value = b;
if (int.TryParse(extras[2], out b))
if (b == 1)
{
cBLightbar.Checked = true;
if (int.TryParse(extras[3], out b)) tBRedBar.Value = b;
if (int.TryParse(extras[4], out b)) tBGreenBar.Value = b;
if (int.TryParse(extras[5], out b)) tBBlueBar.Value = b;
if (int.TryParse(extras[6], out b)) nUDLightFlash.Value = b;
}
else
{
tBRedBar.Value = 255;
tBGreenBar.Value = 255;
tBBlueBar.Value = 255;
nUDLightFlash.Value = 0;
cBLightbar.Checked = false;
}
if (int.TryParse(extras[7], out b))
if (b == 1)
{
cBMouse.Checked = true;
if (int.TryParse(extras[8], out b)) nUDMouse.Value = b;
}
else
{
nUDMouse.Value = 25;
cBMouse.Checked = false;
}
}
catch
{
nUDHeavy.Value = 0;
nUDLight.Value = 0;
tBRedBar.Value = 255;
tBGreenBar.Value = 255;
tBBlueBar.Value = 255;
nUDLightFlash.Value = 0;
cBLightbar.Checked = false;
nUDMouse.Value = 25;
cBMouse.Checked = false;
}
}
extraChanged = false;
}