From 5ad4e83b58c1a9f2da8e670b54b13a9ad82fc0da Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Tue, 28 Mar 2017 18:41:17 -0700 Subject: [PATCH] Add null extras detection when opening button mapping window --- DS4Windows/DS4Control/Mapping.cs | 2 +- DS4Windows/DS4Forms/KBM360.cs | 100 +++++++++++++++++-------------- 2 files changed, 56 insertions(+), 46 deletions(-) diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 38b580f..715ffdc 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -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; diff --git a/DS4Windows/DS4Forms/KBM360.cs b/DS4Windows/DS4Forms/KBM360.cs index 7cf95ed..a3e23f4 100644 --- a/DS4Windows/DS4Forms/KBM360.cs +++ b/DS4Windows/DS4Forms/KBM360.cs @@ -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; }