Group fields used for lightbar routine

This commit is contained in:
Travis Nickles 2020-02-22 12:32:19 -06:00
parent 456e1dc410
commit 53fc454a20
5 changed files with 240 additions and 136 deletions

View File

@ -42,22 +42,25 @@ namespace DS4Windows
public static void updateLightBar(DS4Device device, int deviceNum) public static void updateLightBar(DS4Device device, int deviceNum)
{ {
DS4Color color; DS4Color color;
if (!defaultLight && !forcelight[deviceNum]) bool useForceLight = forcelight[deviceNum];
LightbarSettingInfo lightbarSettingInfo = getLightbarSettingsInfo(deviceNum);
LightbarDS4WinInfo lightModeInfo = lightbarSettingInfo.ds4winSettings;
if (!defaultLight && !useForceLight)
{ {
if (getUseCustomLed(deviceNum)) if (lightModeInfo.useCustomLed)
{ {
if (getLedAsBatteryIndicator(deviceNum)) if (lightModeInfo.ledAsBattery)
{ {
ref DS4Color fullColor = ref getCustomColor(deviceNum); ref DS4Color fullColor = ref lightModeInfo.m_CustomLed; // ref getCustomColor(deviceNum);
ref DS4Color lowColor = ref getLowColor(deviceNum); ref DS4Color lowColor = ref lightModeInfo.m_LowLed; //ref getLowColor(deviceNum);
color = getTransitionedColor(ref lowColor, ref fullColor, device.getBattery()); color = getTransitionedColor(ref lowColor, ref fullColor, device.getBattery());
} }
else else
color = getCustomColor(deviceNum); color = lightModeInfo.m_CustomLed; //getCustomColor(deviceNum);
} }
else else
{ {
double rainbow = getRainbow(deviceNum); double rainbow = lightModeInfo.rainbow;// getRainbow(deviceNum);
if (rainbow > 0) if (rainbow > 0)
{ {
// Display rainbow // Display rainbow
@ -76,8 +79,8 @@ namespace DS4Windows
else if (counters[deviceNum] > 180000) else if (counters[deviceNum] > 180000)
counters[deviceNum] = 0; counters[deviceNum] = 0;
double maxSat = GetMaxSatRainbow(deviceNum); double maxSat = lightModeInfo.maxRainbowSat; // GetMaxSatRainbow(deviceNum);
if (getLedAsBatteryIndicator(deviceNum)) if (lightModeInfo.ledAsBattery)
{ {
byte useSat = (byte)(maxSat == 1.0 ? byte useSat = (byte)(maxSat == 1.0 ?
device.getBattery() * 2.55 : device.getBattery() * 2.55 :
@ -89,10 +92,10 @@ namespace DS4Windows
(byte)(maxSat == 1.0 ? 255 : 255 * maxSat)); (byte)(maxSat == 1.0 ? 255 : 255 * maxSat));
} }
else if (getLedAsBatteryIndicator(deviceNum)) else if (lightModeInfo.ledAsBattery)
{ {
ref DS4Color fullColor = ref getMainColor(deviceNum); ref DS4Color fullColor = ref lightModeInfo.m_Led; //ref getMainColor(deviceNum);
ref DS4Color lowColor = ref getLowColor(deviceNum); ref DS4Color lowColor = ref lightModeInfo.m_LowLed; //ref getLowColor(deviceNum);
color = getTransitionedColor(ref lowColor, ref fullColor, device.getBattery()); color = getTransitionedColor(ref lowColor, ref fullColor, device.getBattery());
} }
else else
@ -101,15 +104,15 @@ namespace DS4Windows
} }
} }
if (device.getBattery() <= getFlashAt(deviceNum) && !defaultLight && !device.isCharging()) if (device.getBattery() <= lightModeInfo.flashAt && !defaultLight && !device.isCharging())
{ {
ref DS4Color flashColor = ref getFlashColor(deviceNum); ref DS4Color flashColor = ref lightModeInfo.m_FlashLed; //ref getFlashColor(deviceNum);
if (!(flashColor.red == 0 && if (!(flashColor.red == 0 &&
flashColor.green == 0 && flashColor.green == 0 &&
flashColor.blue == 0)) flashColor.blue == 0))
color = flashColor; color = flashColor;
if (getFlashType(deviceNum) == 1) if (lightModeInfo.flashType == 1)
{ {
double ratio = 0.0; double ratio = 0.0;
@ -158,7 +161,7 @@ namespace DS4Windows
} }
int idleDisconnectTimeout = getIdleDisconnectTimeout(deviceNum); int idleDisconnectTimeout = getIdleDisconnectTimeout(deviceNum);
if (idleDisconnectTimeout > 0 && getLedAsBatteryIndicator(deviceNum) && if (idleDisconnectTimeout > 0 && lightModeInfo.ledAsBattery &&
(!device.isCharging() || device.getBattery() >= 100)) (!device.isCharging() || device.getBattery() >= 100))
{ {
// Fade lightbar by idle time // Fade lightbar by idle time
@ -182,7 +185,7 @@ namespace DS4Windows
if (device.isCharging() && device.getBattery() < 100) if (device.isCharging() && device.getBattery() < 100)
{ {
switch (getChargingType(deviceNum)) switch (lightModeInfo.chargingType)
{ {
case 1: case 1:
{ {
@ -243,14 +246,14 @@ namespace DS4Windows
} }
case 3: case 3:
{ {
color = getChargingColor(deviceNum); color = lightModeInfo.m_ChargingLed; //getChargingColor(deviceNum);
break; break;
} }
default: break; default: break;
} }
} }
} }
else if (forcelight[deviceNum]) else if (useForceLight)
{ {
color = forcedColor[deviceNum]; color = forcedColor[deviceNum];
} }
@ -297,12 +300,12 @@ namespace DS4Windows
if (haptics.IsLightBarSet()) if (haptics.IsLightBarSet())
{ {
if (forcelight[deviceNum] && forcedFlash[deviceNum] > 0) if (useForceLight && forcedFlash[deviceNum] > 0)
{ {
haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = (byte)(25 - forcedFlash[deviceNum]); haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = (byte)(25 - forcedFlash[deviceNum]);
haptics.LightBarExplicitlyOff = true; haptics.LightBarExplicitlyOff = true;
} }
else if (device.getBattery() <= getFlashAt(deviceNum) && getFlashType(deviceNum) == 0 && !defaultLight && !device.isCharging()) else if (device.getBattery() <= lightModeInfo.flashAt && lightModeInfo.flashType == 0 && !defaultLight && !device.isCharging())
{ {
int level = device.getBattery() / 10; int level = device.getBattery() / 10;
if (level >= 10) if (level >= 10)

View File

@ -43,4 +43,56 @@ namespace DS4Windows
public bool useSmoothing; public bool useSmoothing;
public double smoothWeight; public double smoothWeight;
} }
public enum LightbarMode : uint
{
None,
DS4Win,
Passthru,
}
public class LightbarDS4WinInfo
{
public bool useCustomLed;
public bool ledAsBattery;
public DS4Color m_CustomLed = new DS4Color(0, 0, 255);
public DS4Color m_Led;
public DS4Color m_LowLed;
public DS4Color m_ChargingLed;
public DS4Color m_FlashLed;
public double rainbow;
public double maxRainbowSat = 1.0;
public int flashAt;
public byte flashType;
public int chargingType;
}
public class LightbarSettingInfo
{
public LightbarMode mode = LightbarMode.DS4Win;
public LightbarDS4WinInfo ds4winSettings = new LightbarDS4WinInfo();
public LightbarMode Mode
{
get => mode;
set
{
if (mode == value) return;
mode = value;
ChangedMode?.Invoke(this, EventArgs.Empty);
}
}
public event EventHandler ChangedMode;
public LightbarSettingInfo()
{
/*ChangedMode += (sender, e) =>
{
if (mode != LightbarMode.DS4Win)
{
ds4winSettings = null;
}
};
*/
}
}
} }

View File

@ -1066,6 +1066,12 @@ namespace DS4Windows
return m_Config.chargingType[index]; return m_Config.chargingType[index];
} }
public static LightbarSettingInfo[] LightbarSettingsInfo => m_Config.lightbarSettingInfo;
public static LightbarSettingInfo getLightbarSettingsInfo(int index)
{
return m_Config.lightbarSettingInfo[index];
}
public static bool[] DinputOnly => m_Config.dinputOnly; public static bool[] DinputOnly => m_Config.dinputOnly;
public static bool getDInputOnly(int index) public static bool getDInputOnly(int index)
{ {
@ -1223,40 +1229,46 @@ namespace DS4Windows
public static void SetGyroMouseToggle(int index, bool value, ControlService control) public static void SetGyroMouseToggle(int index, bool value, ControlService control)
=> m_Config.SetGyroMouseToggle(index, value, control); => m_Config.SetGyroMouseToggle(index, value, control);
public static DS4Color[] MainColor => m_Config.m_Leds; //public static DS4Color[] MainColor => m_Config.m_Leds;
public static ref DS4Color getMainColor(int index) public static ref DS4Color getMainColor(int index)
{ {
return ref m_Config.m_Leds[index]; return ref m_Config.lightbarSettingInfo[index].ds4winSettings.m_Led;
//return ref m_Config.m_Leds[index];
} }
public static DS4Color[] LowColor => m_Config.m_LowLeds; //public static DS4Color[] LowColor => m_Config.m_LowLeds;
public static ref DS4Color getLowColor(int index) public static ref DS4Color getLowColor(int index)
{ {
return ref m_Config.m_LowLeds[index]; return ref m_Config.lightbarSettingInfo[index].ds4winSettings.m_LowLed;
//return ref m_Config.m_LowLeds[index];
} }
public static DS4Color[] ChargingColor => m_Config.m_ChargingLeds; //public static DS4Color[] ChargingColor => m_Config.m_ChargingLeds;
public static ref DS4Color getChargingColor(int index) public static ref DS4Color getChargingColor(int index)
{ {
return ref m_Config.m_ChargingLeds[index]; return ref m_Config.lightbarSettingInfo[index].ds4winSettings.m_ChargingLed;
//return ref m_Config.m_ChargingLeds[index];
} }
public static DS4Color[] CustomColor => m_Config.m_CustomLeds; //public static DS4Color[] CustomColor => m_Config.m_CustomLeds;
public static ref DS4Color getCustomColor(int index) public static ref DS4Color getCustomColor(int index)
{ {
return ref m_Config.m_CustomLeds[index]; return ref m_Config.lightbarSettingInfo[index].ds4winSettings.m_CustomLed;
//return ref m_Config.m_CustomLeds[index];
} }
public static bool[] UseCustomLed => m_Config.useCustomLeds; //public static bool[] UseCustomLed => m_Config.useCustomLeds;
public static bool getUseCustomLed(int index) public static bool getUseCustomLed(int index)
{ {
return m_Config.useCustomLeds[index]; return m_Config.lightbarSettingInfo[index].ds4winSettings.useCustomLed;
//return m_Config.useCustomLeds[index];
} }
public static DS4Color[] FlashColor => m_Config.m_FlashLeds; //public static DS4Color[] FlashColor => m_Config.m_FlashLeds;
public static ref DS4Color getFlashColor(int index) public static ref DS4Color getFlashColor(int index)
{ {
return ref m_Config.m_FlashLeds[index]; return ref m_Config.lightbarSettingInfo[index].ds4winSettings.m_FlashLed;
//return ref m_Config.m_FlashLeds[index];
} }
public static byte[] TapSensitivity => m_Config.tapSensitivity; public static byte[] TapSensitivity => m_Config.tapSensitivity;
@ -2140,6 +2152,13 @@ namespace DS4Windows
public double[] maxRainbowSat = new double[5] { 1.0, 1.0, 1.0, 1.0, 1.0 }; public double[] maxRainbowSat = new double[5] { 1.0, 1.0, 1.0, 1.0, 1.0 };
public int[] chargingType = new int[5] { 0, 0, 0, 0, 0 }; public int[] chargingType = new int[5] { 0, 0, 0, 0, 0 };
public LightbarSettingInfo[] lightbarSettingInfo = new LightbarSettingInfo[5]
{
new LightbarSettingInfo(), new LightbarSettingInfo(),
new LightbarSettingInfo(), new LightbarSettingInfo(),
new LightbarSettingInfo()
};
public string[] launchProgram = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; public string[] launchProgram = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty };
public bool[] dinputOnly = new bool[5] { false, false, false, false, false }; public bool[] dinputOnly = new bool[5] { false, false, false, false, false };
public bool[] startTouchpadOff = new bool[5] { false, false, false, false, false }; public bool[] startTouchpadOff = new bool[5] { false, false, false, false, false };
@ -2154,10 +2173,12 @@ namespace DS4Windows
public bool[] gyroMouseStickTriggerTurns = new bool[5] { true, true, true, true, true }; public bool[] gyroMouseStickTriggerTurns = new bool[5] { true, true, true, true, true };
public GyroMouseStickInfo[] gyroMStickInfo = new GyroMouseStickInfo[5] public GyroMouseStickInfo[] gyroMStickInfo = new GyroMouseStickInfo[5]
{ {
new GyroMouseStickInfo(), new GyroMouseStickInfo(), new GyroMouseStickInfo(),
new GyroMouseStickInfo(),
new GyroMouseStickInfo(), new GyroMouseStickInfo(), new GyroMouseStickInfo(), new GyroMouseStickInfo(),
new GyroMouseStickInfo() new GyroMouseStickInfo()
}; };
public bool[] gyroMouseStickToggle = new bool[5] { false, false, false, public bool[] gyroMouseStickToggle = new bool[5] { false, false, false,
false, false }; false, false };
@ -2249,6 +2270,17 @@ namespace DS4Windows
profileActions[i].Add("Disconnect Controller"); profileActions[i].Add("Disconnect Controller");
profileActionCount[i] = profileActions[i].Count; profileActionCount[i] = profileActions[i].Count;
} }
SetupDefaultColors();
}
private void SetupDefaultColors()
{
lightbarSettingInfo[0].ds4winSettings.m_Led = new DS4Color(Color.Blue);
lightbarSettingInfo[1].ds4winSettings.m_Led = new DS4Color(Color.Red);
lightbarSettingInfo[2].ds4winSettings.m_Led = new DS4Color(Color.Green);
lightbarSettingInfo[3].ds4winSettings.m_Led = new DS4Color(Color.Pink);
lightbarSettingInfo[4].ds4winSettings.m_Led = new DS4Color(Color.White);
} }
private string stickOutputCurveString(int id) private string stickOutputCurveString(int id)
@ -2450,26 +2482,28 @@ namespace DS4Windows
Node = m_Xdoc.CreateNode(XmlNodeType.Element, "DS4Windows", null); Node = m_Xdoc.CreateNode(XmlNodeType.Element, "DS4Windows", null);
LightbarDS4WinInfo lightInfo = lightbarSettingInfo[device].ds4winSettings;
XmlNode xmlFlushHIDQueue = m_Xdoc.CreateNode(XmlNodeType.Element, "flushHIDQueue", null); xmlFlushHIDQueue.InnerText = flushHIDQueue[device].ToString(); Node.AppendChild(xmlFlushHIDQueue); XmlNode xmlFlushHIDQueue = m_Xdoc.CreateNode(XmlNodeType.Element, "flushHIDQueue", null); xmlFlushHIDQueue.InnerText = flushHIDQueue[device].ToString(); Node.AppendChild(xmlFlushHIDQueue);
XmlNode xmlTouchToggle = m_Xdoc.CreateNode(XmlNodeType.Element, "touchToggle", null); xmlTouchToggle.InnerText = enableTouchToggle[device].ToString(); Node.AppendChild(xmlTouchToggle); XmlNode xmlTouchToggle = m_Xdoc.CreateNode(XmlNodeType.Element, "touchToggle", null); xmlTouchToggle.InnerText = enableTouchToggle[device].ToString(); Node.AppendChild(xmlTouchToggle);
XmlNode xmlIdleDisconnectTimeout = m_Xdoc.CreateNode(XmlNodeType.Element, "idleDisconnectTimeout", null); xmlIdleDisconnectTimeout.InnerText = idleDisconnectTimeout[device].ToString(); Node.AppendChild(xmlIdleDisconnectTimeout); XmlNode xmlIdleDisconnectTimeout = m_Xdoc.CreateNode(XmlNodeType.Element, "idleDisconnectTimeout", null); xmlIdleDisconnectTimeout.InnerText = idleDisconnectTimeout[device].ToString(); Node.AppendChild(xmlIdleDisconnectTimeout);
XmlNode xmlColor = m_Xdoc.CreateNode(XmlNodeType.Element, "Color", null); XmlNode xmlColor = m_Xdoc.CreateNode(XmlNodeType.Element, "Color", null);
xmlColor.InnerText = m_Leds[device].red.ToString() + "," + m_Leds[device].green.ToString() + "," + m_Leds[device].blue.ToString(); xmlColor.InnerText = lightInfo.m_Led.red.ToString() + "," + lightInfo.m_Led.green.ToString() + "," + lightInfo.m_Led.blue.ToString();
Node.AppendChild(xmlColor); Node.AppendChild(xmlColor);
XmlNode xmlRumbleBoost = m_Xdoc.CreateNode(XmlNodeType.Element, "RumbleBoost", null); xmlRumbleBoost.InnerText = rumble[device].ToString(); Node.AppendChild(xmlRumbleBoost); XmlNode xmlRumbleBoost = m_Xdoc.CreateNode(XmlNodeType.Element, "RumbleBoost", null); xmlRumbleBoost.InnerText = rumble[device].ToString(); Node.AppendChild(xmlRumbleBoost);
XmlNode xmlRumbleAutostopTime = m_Xdoc.CreateNode(XmlNodeType.Element, "RumbleAutostopTime", null); xmlRumbleAutostopTime.InnerText = rumbleAutostopTime[device].ToString(); Node.AppendChild(xmlRumbleAutostopTime); XmlNode xmlRumbleAutostopTime = m_Xdoc.CreateNode(XmlNodeType.Element, "RumbleAutostopTime", null); xmlRumbleAutostopTime.InnerText = rumbleAutostopTime[device].ToString(); Node.AppendChild(xmlRumbleAutostopTime);
XmlNode xmlLedAsBatteryIndicator = m_Xdoc.CreateNode(XmlNodeType.Element, "ledAsBatteryIndicator", null); xmlLedAsBatteryIndicator.InnerText = ledAsBattery[device].ToString(); Node.AppendChild(xmlLedAsBatteryIndicator); XmlNode xmlLedAsBatteryIndicator = m_Xdoc.CreateNode(XmlNodeType.Element, "ledAsBatteryIndicator", null); xmlLedAsBatteryIndicator.InnerText = lightInfo.ledAsBattery.ToString(); Node.AppendChild(xmlLedAsBatteryIndicator);
XmlNode xmlLowBatteryFlash = m_Xdoc.CreateNode(XmlNodeType.Element, "FlashType", null); xmlLowBatteryFlash.InnerText = flashType[device].ToString(); Node.AppendChild(xmlLowBatteryFlash); XmlNode xmlLowBatteryFlash = m_Xdoc.CreateNode(XmlNodeType.Element, "FlashType", null); xmlLowBatteryFlash.InnerText = lightInfo.flashType.ToString(); Node.AppendChild(xmlLowBatteryFlash);
XmlNode xmlFlashBatterAt = m_Xdoc.CreateNode(XmlNodeType.Element, "flashBatteryAt", null); xmlFlashBatterAt.InnerText = flashAt[device].ToString(); Node.AppendChild(xmlFlashBatterAt); XmlNode xmlFlashBatterAt = m_Xdoc.CreateNode(XmlNodeType.Element, "flashBatteryAt", null); xmlFlashBatterAt.InnerText = lightInfo.flashAt.ToString(); Node.AppendChild(xmlFlashBatterAt);
XmlNode xmlTouchSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "touchSensitivity", null); xmlTouchSensitivity.InnerText = touchSensitivity[device].ToString(); Node.AppendChild(xmlTouchSensitivity); XmlNode xmlTouchSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "touchSensitivity", null); xmlTouchSensitivity.InnerText = touchSensitivity[device].ToString(); Node.AppendChild(xmlTouchSensitivity);
XmlNode xmlLowColor = m_Xdoc.CreateNode(XmlNodeType.Element, "LowColor", null); XmlNode xmlLowColor = m_Xdoc.CreateNode(XmlNodeType.Element, "LowColor", null);
xmlLowColor.InnerText = m_LowLeds[device].red.ToString() + "," + m_LowLeds[device].green.ToString() + "," + m_LowLeds[device].blue.ToString(); xmlLowColor.InnerText = lightInfo.m_LowLed.red.ToString() + "," + lightInfo.m_LowLed.green.ToString() + "," + lightInfo.m_LowLed.blue.ToString();
Node.AppendChild(xmlLowColor); Node.AppendChild(xmlLowColor);
XmlNode xmlChargingColor = m_Xdoc.CreateNode(XmlNodeType.Element, "ChargingColor", null); XmlNode xmlChargingColor = m_Xdoc.CreateNode(XmlNodeType.Element, "ChargingColor", null);
xmlChargingColor.InnerText = m_ChargingLeds[device].red.ToString() + "," + m_ChargingLeds[device].green.ToString() + "," + m_ChargingLeds[device].blue.ToString(); xmlChargingColor.InnerText = lightInfo.m_ChargingLed.red.ToString() + "," + lightInfo.m_ChargingLed.green.ToString() + "," + lightInfo.m_ChargingLed.blue.ToString();
Node.AppendChild(xmlChargingColor); Node.AppendChild(xmlChargingColor);
XmlNode xmlFlashColor = m_Xdoc.CreateNode(XmlNodeType.Element, "FlashColor", null); XmlNode xmlFlashColor = m_Xdoc.CreateNode(XmlNodeType.Element, "FlashColor", null);
xmlFlashColor.InnerText = m_FlashLeds[device].red.ToString() + "," + m_FlashLeds[device].green.ToString() + "," + m_FlashLeds[device].blue.ToString(); xmlFlashColor.InnerText = lightInfo.m_FlashLed.red.ToString() + "," + lightInfo.m_FlashLed.green.ToString() + "," + lightInfo.m_FlashLed.blue.ToString();
Node.AppendChild(xmlFlashColor); Node.AppendChild(xmlFlashColor);
XmlNode xmlTouchpadJitterCompensation = m_Xdoc.CreateNode(XmlNodeType.Element, "touchpadJitterCompensation", null); xmlTouchpadJitterCompensation.InnerText = touchpadJitterCompensation[device].ToString(); Node.AppendChild(xmlTouchpadJitterCompensation); XmlNode xmlTouchpadJitterCompensation = m_Xdoc.CreateNode(XmlNodeType.Element, "touchpadJitterCompensation", null); xmlTouchpadJitterCompensation.InnerText = touchpadJitterCompensation[device].ToString(); Node.AppendChild(xmlTouchpadJitterCompensation);
XmlNode xmlLowerRCOn = m_Xdoc.CreateNode(XmlNodeType.Element, "lowerRCOn", null); xmlLowerRCOn.InnerText = lowerRCOn[device].ToString(); Node.AppendChild(xmlLowerRCOn); XmlNode xmlLowerRCOn = m_Xdoc.CreateNode(XmlNodeType.Element, "lowerRCOn", null); xmlLowerRCOn.InnerText = lowerRCOn[device].ToString(); Node.AppendChild(xmlLowerRCOn);
@ -2486,8 +2520,8 @@ namespace DS4Windows
XmlNode xmlL2MaxOutput = m_Xdoc.CreateNode(XmlNodeType.Element, "L2MaxOutput", null); xmlL2MaxOutput.InnerText = l2ModInfo[device].maxOutput.ToString(); Node.AppendChild(xmlL2MaxOutput); XmlNode xmlL2MaxOutput = m_Xdoc.CreateNode(XmlNodeType.Element, "L2MaxOutput", null); xmlL2MaxOutput.InnerText = l2ModInfo[device].maxOutput.ToString(); Node.AppendChild(xmlL2MaxOutput);
XmlNode xmlR2MaxOutput = m_Xdoc.CreateNode(XmlNodeType.Element, "R2MaxOutput", null); xmlR2MaxOutput.InnerText = r2ModInfo[device].maxOutput.ToString(); Node.AppendChild(xmlR2MaxOutput); XmlNode xmlR2MaxOutput = m_Xdoc.CreateNode(XmlNodeType.Element, "R2MaxOutput", null); xmlR2MaxOutput.InnerText = r2ModInfo[device].maxOutput.ToString(); Node.AppendChild(xmlR2MaxOutput);
XmlNode xmlButtonMouseSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "ButtonMouseSensitivity", null); xmlButtonMouseSensitivity.InnerText = buttonMouseSensitivity[device].ToString(); Node.AppendChild(xmlButtonMouseSensitivity); XmlNode xmlButtonMouseSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "ButtonMouseSensitivity", null); xmlButtonMouseSensitivity.InnerText = buttonMouseSensitivity[device].ToString(); Node.AppendChild(xmlButtonMouseSensitivity);
XmlNode xmlRainbow = m_Xdoc.CreateNode(XmlNodeType.Element, "Rainbow", null); xmlRainbow.InnerText = rainbow[device].ToString(); Node.AppendChild(xmlRainbow); XmlNode xmlRainbow = m_Xdoc.CreateNode(XmlNodeType.Element, "Rainbow", null); xmlRainbow.InnerText = lightInfo.rainbow.ToString(); Node.AppendChild(xmlRainbow);
XmlNode xmlMaxSatRainbow = m_Xdoc.CreateNode(XmlNodeType.Element, "MaxSatRainbow", null); xmlMaxSatRainbow.InnerText = Convert.ToInt32(maxRainbowSat[device] * 100.0).ToString(); Node.AppendChild(xmlMaxSatRainbow); XmlNode xmlMaxSatRainbow = m_Xdoc.CreateNode(XmlNodeType.Element, "MaxSatRainbow", null); xmlMaxSatRainbow.InnerText = Convert.ToInt32(lightInfo.maxRainbowSat * 100.0).ToString(); Node.AppendChild(xmlMaxSatRainbow);
XmlNode xmlLSD = m_Xdoc.CreateNode(XmlNodeType.Element, "LSDeadZone", null); xmlLSD.InnerText = lsModInfo[device].deadZone.ToString(); Node.AppendChild(xmlLSD); XmlNode xmlLSD = m_Xdoc.CreateNode(XmlNodeType.Element, "LSDeadZone", null); xmlLSD.InnerText = lsModInfo[device].deadZone.ToString(); Node.AppendChild(xmlLSD);
XmlNode xmlRSD = m_Xdoc.CreateNode(XmlNodeType.Element, "RSDeadZone", null); xmlRSD.InnerText = rsModInfo[device].deadZone.ToString(); Node.AppendChild(xmlRSD); XmlNode xmlRSD = m_Xdoc.CreateNode(XmlNodeType.Element, "RSDeadZone", null); xmlRSD.InnerText = rsModInfo[device].deadZone.ToString(); Node.AppendChild(xmlRSD);
XmlNode xmlLSAD = m_Xdoc.CreateNode(XmlNodeType.Element, "LSAntiDeadZone", null); xmlLSAD.InnerText = lsModInfo[device].antiDeadZone.ToString(); Node.AppendChild(xmlLSAD); XmlNode xmlLSAD = m_Xdoc.CreateNode(XmlNodeType.Element, "LSAntiDeadZone", null); xmlLSAD.InnerText = lsModInfo[device].antiDeadZone.ToString(); Node.AppendChild(xmlLSAD);
@ -2512,7 +2546,7 @@ namespace DS4Windows
xmlSens.InnerText = $"{LSSens[device]}|{RSSens[device]}|{l2Sens[device]}|{r2Sens[device]}|{SXSens[device]}|{SZSens[device]}"; xmlSens.InnerText = $"{LSSens[device]}|{RSSens[device]}|{l2Sens[device]}|{r2Sens[device]}|{SXSens[device]}|{SZSens[device]}";
Node.AppendChild(xmlSens); Node.AppendChild(xmlSens);
XmlNode xmlChargingType = m_Xdoc.CreateNode(XmlNodeType.Element, "ChargingType", null); xmlChargingType.InnerText = chargingType[device].ToString(); Node.AppendChild(xmlChargingType); XmlNode xmlChargingType = m_Xdoc.CreateNode(XmlNodeType.Element, "ChargingType", null); xmlChargingType.InnerText = lightInfo.chargingType.ToString(); Node.AppendChild(xmlChargingType);
XmlNode xmlMouseAccel = m_Xdoc.CreateNode(XmlNodeType.Element, "MouseAcceleration", null); xmlMouseAccel.InnerText = mouseAccel[device].ToString(); Node.AppendChild(xmlMouseAccel); XmlNode xmlMouseAccel = m_Xdoc.CreateNode(XmlNodeType.Element, "MouseAcceleration", null); xmlMouseAccel.InnerText = mouseAccel[device].ToString(); Node.AppendChild(xmlMouseAccel);
//XmlNode xmlShiftMod = m_Xdoc.CreateNode(XmlNodeType.Element, "ShiftModifier", null); xmlShiftMod.InnerText = shiftModifier[device].ToString(); Node.AppendChild(xmlShiftMod); //XmlNode xmlShiftMod = m_Xdoc.CreateNode(XmlNodeType.Element, "ShiftModifier", null); xmlShiftMod.InnerText = shiftModifier[device].ToString(); Node.AppendChild(xmlShiftMod);
XmlNode xmlLaunchProgram = m_Xdoc.CreateNode(XmlNodeType.Element, "LaunchProgram", null); xmlLaunchProgram.InnerText = launchProgram[device].ToString(); Node.AppendChild(xmlLaunchProgram); XmlNode xmlLaunchProgram = m_Xdoc.CreateNode(XmlNodeType.Element, "LaunchProgram", null); xmlLaunchProgram.InnerText = launchProgram[device].ToString(); Node.AppendChild(xmlLaunchProgram);
@ -3065,6 +3099,7 @@ namespace DS4Windows
} }
OutContType oldContType = Global.activeOutDevType[device]; OutContType oldContType = Global.activeOutDevType[device];
LightbarDS4WinInfo lightInfo = lightbarSettingInfo[device].ds4winSettings;
// Make sure to reset currently set profile values before parsing // Make sure to reset currently set profile values before parsing
ResetProfile(device); ResetProfile(device);
@ -3087,21 +3122,21 @@ namespace DS4Windows
else else
colors = new string[0]; colors = new string[0];
m_Leds[device].red = byte.Parse(colors[0]); lightInfo.m_Led.red = byte.Parse(colors[0]);
m_Leds[device].green = byte.Parse(colors[1]); lightInfo.m_Led.green = byte.Parse(colors[1]);
m_Leds[device].blue = byte.Parse(colors[2]); lightInfo.m_Led.blue = byte.Parse(colors[2]);
} }
catch { missingSetting = true; } catch { missingSetting = true; }
if (m_Xdoc.SelectSingleNode("/" + rootname + "/Color") == null) if (m_Xdoc.SelectSingleNode("/" + rootname + "/Color") == null)
{ {
//Old method of color saving //Old method of color saving
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/Red"); Byte.TryParse(Item.InnerText, out m_Leds[device].red); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/Red"); Byte.TryParse(Item.InnerText, out lightInfo.m_Led.red); }
catch { missingSetting = true; } catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/Green"); Byte.TryParse(Item.InnerText, out m_Leds[device].green); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/Green"); Byte.TryParse(Item.InnerText, out lightInfo.m_Led.green); }
catch { missingSetting = true; } catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/Blue"); Byte.TryParse(Item.InnerText, out m_Leds[device].blue); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/Blue"); Byte.TryParse(Item.InnerText, out lightInfo.m_Led.blue); }
catch { missingSetting = true; } catch { missingSetting = true; }
} }
@ -3111,13 +3146,13 @@ namespace DS4Windows
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RumbleAutostopTime"); Int32.TryParse(Item.InnerText, out rumbleAutostopTime[device]); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RumbleAutostopTime"); Int32.TryParse(Item.InnerText, out rumbleAutostopTime[device]); }
catch { missingSetting = true; } catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/ledAsBatteryIndicator"); Boolean.TryParse(Item.InnerText, out ledAsBattery[device]); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/ledAsBatteryIndicator"); Boolean.TryParse(Item.InnerText, out lightInfo.ledAsBattery); }
catch { missingSetting = true; } catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/FlashType"); Byte.TryParse(Item.InnerText, out flashType[device]); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/FlashType"); Byte.TryParse(Item.InnerText, out lightInfo.flashType); }
catch { missingSetting = true; } catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/flashBatteryAt"); Int32.TryParse(Item.InnerText, out flashAt[device]); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/flashBatteryAt"); Int32.TryParse(Item.InnerText, out lightInfo.flashAt); }
catch { missingSetting = true; } catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/touchSensitivity"); Byte.TryParse(Item.InnerText, out touchSensitivity[device]); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/touchSensitivity"); Byte.TryParse(Item.InnerText, out touchSensitivity[device]); }
@ -3133,20 +3168,20 @@ namespace DS4Windows
else else
colors = new string[0]; colors = new string[0];
m_LowLeds[device].red = byte.Parse(colors[0]); lightInfo.m_LowLed.red = byte.Parse(colors[0]);
m_LowLeds[device].green = byte.Parse(colors[1]); lightInfo.m_LowLed.green = byte.Parse(colors[1]);
m_LowLeds[device].blue = byte.Parse(colors[2]); lightInfo.m_LowLed.blue = byte.Parse(colors[2]);
} }
catch { missingSetting = true; } catch { missingSetting = true; }
if (m_Xdoc.SelectSingleNode("/" + rootname + "/LowColor") == null) if (m_Xdoc.SelectSingleNode("/" + rootname + "/LowColor") == null)
{ {
//Old method of color saving //Old method of color saving
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LowRed"); byte.TryParse(Item.InnerText, out m_LowLeds[device].red); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LowRed"); byte.TryParse(Item.InnerText, out lightInfo.m_LowLed.red); }
catch { missingSetting = true; } catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LowGreen"); byte.TryParse(Item.InnerText, out m_LowLeds[device].green); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LowGreen"); byte.TryParse(Item.InnerText, out lightInfo.m_LowLed.green); }
catch { missingSetting = true; } catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LowBlue"); byte.TryParse(Item.InnerText, out m_LowLeds[device].blue); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LowBlue"); byte.TryParse(Item.InnerText, out lightInfo.m_LowLed.blue); }
catch { missingSetting = true; } catch { missingSetting = true; }
} }
@ -3160,19 +3195,19 @@ namespace DS4Windows
else else
colors = new string[0]; colors = new string[0];
m_ChargingLeds[device].red = byte.Parse(colors[0]); lightInfo.m_ChargingLed.red = byte.Parse(colors[0]);
m_ChargingLeds[device].green = byte.Parse(colors[1]); lightInfo.m_ChargingLed.green = byte.Parse(colors[1]);
m_ChargingLeds[device].blue = byte.Parse(colors[2]); lightInfo.m_ChargingLed.blue = byte.Parse(colors[2]);
} }
catch { missingSetting = true; } catch { missingSetting = true; }
if (m_Xdoc.SelectSingleNode("/" + rootname + "/ChargingColor") == null) if (m_Xdoc.SelectSingleNode("/" + rootname + "/ChargingColor") == null)
{ {
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/ChargingRed"); Byte.TryParse(Item.InnerText, out m_ChargingLeds[device].red); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/ChargingRed"); Byte.TryParse(Item.InnerText, out lightInfo.m_ChargingLed.red); }
catch { missingSetting = true; } catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/ChargingGreen"); Byte.TryParse(Item.InnerText, out m_ChargingLeds[device].green); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/ChargingGreen"); Byte.TryParse(Item.InnerText, out lightInfo.m_ChargingLed.green); }
catch { missingSetting = true; } catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/ChargingBlue"); Byte.TryParse(Item.InnerText, out m_ChargingLeds[device].blue); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/ChargingBlue"); Byte.TryParse(Item.InnerText, out lightInfo.m_ChargingLed.blue); }
catch { missingSetting = true; } catch { missingSetting = true; }
} }
@ -3184,9 +3219,9 @@ namespace DS4Windows
colors = Item.InnerText.Split(','); colors = Item.InnerText.Split(',');
else else
colors = new string[0]; colors = new string[0];
m_FlashLeds[device].red = byte.Parse(colors[0]); lightInfo.m_FlashLed.red = byte.Parse(colors[0]);
m_FlashLeds[device].green = byte.Parse(colors[1]); lightInfo.m_FlashLed.green = byte.Parse(colors[1]);
m_FlashLeds[device].blue = byte.Parse(colors[2]); lightInfo.m_FlashLed.blue = byte.Parse(colors[2]);
} }
catch { missingSetting = true; } catch { missingSetting = true; }
@ -3265,13 +3300,13 @@ namespace DS4Windows
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/ButtonMouseSensitivity"); int.TryParse(Item.InnerText, out buttonMouseSensitivity[device]); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/ButtonMouseSensitivity"); int.TryParse(Item.InnerText, out buttonMouseSensitivity[device]); }
catch { missingSetting = true; } catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/Rainbow"); double.TryParse(Item.InnerText, out rainbow[device]); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/Rainbow"); double.TryParse(Item.InnerText, out lightInfo.rainbow); }
catch { rainbow[device] = 0; missingSetting = true; } catch { rainbow[device] = 0; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/MaxSatRainbow"); try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/MaxSatRainbow");
int.TryParse(Item.InnerText, out int temp); int.TryParse(Item.InnerText, out int temp);
maxRainbowSat[device] = Math.Max(0, Math.Min(100, temp)) / 100.0; lightInfo.maxRainbowSat = Math.Max(0, Math.Min(100, temp)) / 100.0;
} }
catch { maxRainbowSat[device] = 1.0; missingSetting = true; } catch { lightInfo.maxRainbowSat = 1.0; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSDeadZone"); int.TryParse(Item.InnerText, out lsModInfo[device].deadZone); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSDeadZone"); int.TryParse(Item.InnerText, out lsModInfo[device].deadZone); }
catch { lsModInfo[device].deadZone = 10; missingSetting = true; } catch { lsModInfo[device].deadZone = 10; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSDeadZone"); int.TryParse(Item.InnerText, out rsModInfo[device].deadZone); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSDeadZone"); int.TryParse(Item.InnerText, out rsModInfo[device].deadZone); }
@ -3365,7 +3400,7 @@ namespace DS4Windows
} }
catch { missingSetting = true; } catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/ChargingType"); int.TryParse(Item.InnerText, out chargingType[device]); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/ChargingType"); int.TryParse(Item.InnerText, out lightInfo.chargingType); }
catch { missingSetting = true; } catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/MouseAcceleration"); bool.TryParse(Item.InnerText, out mouseAccel[device]); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/MouseAcceleration"); bool.TryParse(Item.InnerText, out mouseAccel[device]); }
catch { missingSetting = true; } catch { missingSetting = true; }
@ -4781,8 +4816,7 @@ namespace DS4Windows
idleDisconnectTimeout[device] = 0; idleDisconnectTimeout[device] = 0;
touchpadJitterCompensation[device] = true; touchpadJitterCompensation[device] = true;
lowerRCOn[device] = false; lowerRCOn[device] = false;
ledAsBattery[device] = false;
flashType[device] = 0;
rumble[device] = 100; rumble[device] = 100;
rumbleAutostopTime[device] = 0; rumbleAutostopTime[device] = 0;
touchSensitivity[device] = 100; touchSensitivity[device] = 100;
@ -4806,13 +4840,12 @@ namespace DS4Windows
doubleTap[device] = false; doubleTap[device] = false;
scrollSensitivity[device] = 0; scrollSensitivity[device] = 0;
touchpadInvert[device] = 0; touchpadInvert[device] = 0;
rainbow[device] = 0;
maxRainbowSat[device] = 1.0;
flashAt[device] = 0;
mouseAccel[device] = false; mouseAccel[device] = false;
btPollRate[device] = 4; btPollRate[device] = 4;
m_LowLeds[device] = new DS4Color(Color.Black); LightbarDS4WinInfo lightInfo = lightbarSettingInfo[device].ds4winSettings;
lightInfo.m_LowLed = new DS4Color(Color.Black);
//m_LowLeds[device] = new DS4Color(Color.Black);
Color tempColor = Color.Blue; Color tempColor = Color.Blue;
switch(device) switch(device)
@ -4825,13 +4858,29 @@ namespace DS4Windows
default: tempColor = Color.Blue; break; default: tempColor = Color.Blue; break;
} }
m_Leds[device] = new DS4Color(tempColor); lightInfo.m_Led = new DS4Color(tempColor);
lightInfo.m_ChargingLed = new DS4Color(Color.Black);
lightInfo.m_FlashLed = new DS4Color(Color.Black);
lightInfo.flashAt = 0;
lightInfo.flashType = 0;
lightInfo.chargingType = 0;
lightInfo.rainbow = 0;
lightInfo.maxRainbowSat = 1.0;
lightInfo.ledAsBattery = false;
/*m_Leds[device] = new DS4Color(tempColor);
m_ChargingLeds[device] = new DS4Color(Color.Black); m_ChargingLeds[device] = new DS4Color(Color.Black);
m_FlashLeds[device] = new DS4Color(Color.Black); m_FlashLeds[device] = new DS4Color(Color.Black);
//useCustomLeds[device] = false; //useCustomLeds[device] = false;
//m_CustomLeds[device] = new DS4Color(Color.Blue); //m_CustomLeds[device] = new DS4Color(Color.Blue);
chargingType[device] = 0; chargingType[device] = 0;
rainbow[device] = 0;
maxRainbowSat[device] = 1.0;
flashAt[device] = 0;
ledAsBattery[device] = false;
flashType[device] = 0;
*/
launchProgram[device] = string.Empty; launchProgram[device] = string.Empty;
dinputOnly[device] = false; dinputOnly[device] = false;
startTouchpadOff[device] = false; startTouchpadOff[device] = false;

View File

@ -198,13 +198,13 @@ namespace DS4WinWPF.DS4Forms.ViewModels
get get
{ {
DS4Color color; DS4Color color;
if (Global.UseCustomLed[devIndex]) if (Global.LightbarSettingsInfo[devIndex].ds4winSettings.useCustomLed)
{ {
color = Global.CustomColor[devIndex]; color = Global.LightbarSettingsInfo[devIndex].ds4winSettings.m_CustomLed; //Global.CustomColor[devIndex];
} }
else else
{ {
color = Global.MainColor[devIndex]; color = Global.LightbarSettingsInfo[devIndex].ds4winSettings.m_Led;
} }
return $"#FF{color.red.ToString("X2")}{color.green.ToString("X2")}{color.blue.ToString("X2")}"; return $"#FF{color.red.ToString("X2")}{color.green.ToString("X2")}{color.blue.ToString("X2")}";
} }
@ -217,7 +217,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
get get
{ {
DS4Color color; DS4Color color;
color = Global.CustomColor[devIndex]; color = Global.LightbarSettingsInfo[devIndex].ds4winSettings.m_CustomLed;
return new Color() { R = color.red, G = color.green, B = color.blue, A = 255 }; return new Color() { R = color.red, G = color.green, B = color.blue, A = 255 };
} }
} }
@ -321,7 +321,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
HookEvents(true); HookEvents(true);
} }
useCustomColor = Global.UseCustomLed[devIndex]; useCustomColor = Global.LightbarSettingsInfo[devIndex].ds4winSettings.useCustomLed;
} }
public void ChangeSelectedProfile() public void ChangeSelectedProfile()
@ -428,7 +428,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
{ {
useCustomColor = false; useCustomColor = false;
RefreshLightContext(); RefreshLightContext();
Global.UseCustomLed[devIndex] = false; Global.LightbarSettingsInfo[devIndex].ds4winSettings.useCustomLed = false;
LightColorChanged?.Invoke(this, EventArgs.Empty); LightColorChanged?.Invoke(this, EventArgs.Empty);
} }
@ -436,7 +436,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
{ {
useCustomColor = true; useCustomColor = true;
RefreshLightContext(); RefreshLightContext();
Global.UseCustomLed[devIndex] = true; Global.LightbarSettingsInfo[devIndex].ds4winSettings.useCustomLed = true;
LightColorChanged?.Invoke(this, EventArgs.Empty); LightColorChanged?.Invoke(this, EventArgs.Empty);
RequestColorPicker?.Invoke(this); RequestColorPicker?.Invoke(this);
} }
@ -449,7 +449,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public void UpdateCustomLightColor(Color color) public void UpdateCustomLightColor(Color color)
{ {
Global.CustomColor[devIndex] = new DS4Color() { red = color.R, green = color.G, blue = color.B }; Global.LightbarSettingsInfo[devIndex].ds4winSettings.m_CustomLed = new DS4Color() { red = color.R, green = color.G, blue = color.B };
LightColorChanged?.Invoke(this, EventArgs.Empty); LightColorChanged?.Invoke(this, EventArgs.Empty);
} }

View File

@ -28,7 +28,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
get get
{ {
System.Windows.Media.Brush tempBrush; System.Windows.Media.Brush tempBrush;
ref DS4Color color = ref Global.MainColor[device]; ref DS4Color color = ref Global.LightbarSettingsInfo[device].ds4winSettings.m_Led;
if (!RainbowExists) if (!RainbowExists)
{ {
lightbarColBrush.Color = new System.Windows.Media.Color() lightbarColBrush.Color = new System.Windows.Media.Color()
@ -54,7 +54,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
{ {
get get
{ {
ref DS4Color color = ref Global.MainColor[device]; ref DS4Color color = ref Global.LightbarSettingsInfo[device].ds4winSettings.m_Led; //ref Global.MainColor[device];
return new System.Windows.Media.Color() return new System.Windows.Media.Color()
{ {
A = 255, A = 255,
@ -70,7 +70,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
{ {
get get
{ {
ref DS4Color color = ref Global.MainColor[device]; ref DS4Color color = ref Global.LightbarSettingsInfo[device].ds4winSettings.m_Led; //ref Global.MainColor[device];
return $"#FF{color.red.ToString("X2")}{color.green.ToString("X2")}{color.blue.ToString("X2")}"; return $"#FF{color.red.ToString("X2")}{color.green.ToString("X2")}{color.blue.ToString("X2")}";
/*return new System.Windows.Media.Color() /*return new System.Windows.Media.Color()
{ {
@ -86,10 +86,10 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public int MainColorR public int MainColorR
{ {
get => Global.MainColor[device].red; get => Global.LightbarSettingsInfo[device].ds4winSettings.m_Led.red;
set set
{ {
Global.MainColor[device].red = (byte)value; Global.LightbarSettingsInfo[device].ds4winSettings.m_Led.red = (byte)value;
MainColorRChanged?.Invoke(this, EventArgs.Empty); MainColorRChanged?.Invoke(this, EventArgs.Empty);
} }
} }
@ -97,16 +97,16 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public string MainColorRString public string MainColorRString
{ {
get => $"#{ Global.MainColor[device].red.ToString("X2")}FF0000"; get => $"#{ Global.LightbarSettingsInfo[device].ds4winSettings.m_Led.red.ToString("X2")}FF0000";
} }
public event EventHandler MainColorRStringChanged; public event EventHandler MainColorRStringChanged;
public int MainColorG public int MainColorG
{ {
get => Global.MainColor[device].green; get => Global.LightbarSettingsInfo[device].ds4winSettings.m_Led.green;
set set
{ {
Global.MainColor[device].green = (byte)value; Global.LightbarSettingsInfo[device].ds4winSettings.m_Led.green = (byte)value;
MainColorGChanged?.Invoke(this, EventArgs.Empty); MainColorGChanged?.Invoke(this, EventArgs.Empty);
} }
} }
@ -114,16 +114,16 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public string MainColorGString public string MainColorGString
{ {
get => $"#{ Global.MainColor[device].green.ToString("X2")}00FF00"; get => $"#{ Global.LightbarSettingsInfo[device].ds4winSettings.m_Led.green.ToString("X2")}00FF00";
} }
public event EventHandler MainColorGStringChanged; public event EventHandler MainColorGStringChanged;
public int MainColorB public int MainColorB
{ {
get => Global.MainColor[device].blue; get => Global.LightbarSettingsInfo[device].ds4winSettings.m_Led.blue;
set set
{ {
Global.MainColor[device].blue = (byte)value; Global.LightbarSettingsInfo[device].ds4winSettings.m_Led.blue = (byte)value;
MainColorBChanged?.Invoke(this, EventArgs.Empty); MainColorBChanged?.Invoke(this, EventArgs.Empty);
} }
} }
@ -131,7 +131,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public string MainColorBString public string MainColorBString
{ {
get => $"#{ Global.MainColor[device].blue.ToString("X2")}0000FF"; get => $"#{ Global.LightbarSettingsInfo[device].ds4winSettings.m_Led.blue.ToString("X2")}0000FF";
} }
public event EventHandler MainColorBStringChanged; public event EventHandler MainColorBStringChanged;
@ -139,7 +139,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
{ {
get get
{ {
ref DS4Color color = ref Global.LowColor[device]; ref DS4Color color = ref Global.LightbarSettingsInfo[device].ds4winSettings.m_LowLed; //ref Global.LowColor[device];
return $"#FF{color.red.ToString("X2")}{color.green.ToString("X2")}{color.blue.ToString("X2")}"; return $"#FF{color.red.ToString("X2")}{color.green.ToString("X2")}{color.blue.ToString("X2")}";
} }
} }
@ -147,10 +147,10 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public int LowColorR public int LowColorR
{ {
get => Global.LowColor[device].red; get => Global.LightbarSettingsInfo[device].ds4winSettings.m_LowLed.red;
set set
{ {
Global.LowColor[device].red = (byte)value; Global.LightbarSettingsInfo[device].ds4winSettings.m_LowLed.red = (byte)value;
LowColorRChanged?.Invoke(this, EventArgs.Empty); LowColorRChanged?.Invoke(this, EventArgs.Empty);
LowColorRStringChanged?.Invoke(this, EventArgs.Empty); LowColorRStringChanged?.Invoke(this, EventArgs.Empty);
} }
@ -159,16 +159,16 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public string LowColorRString public string LowColorRString
{ {
get => $"#{ Global.LowColor[device].red.ToString("X2")}FF0000"; get => $"#{ Global.LightbarSettingsInfo[device].ds4winSettings.m_LowLed.red.ToString("X2")}FF0000";
} }
public event EventHandler LowColorRStringChanged; public event EventHandler LowColorRStringChanged;
public int LowColorG public int LowColorG
{ {
get => Global.LowColor[device].green; get => Global.LightbarSettingsInfo[device].ds4winSettings.m_LowLed.green;
set set
{ {
Global.LowColor[device].green = (byte)value; Global.LightbarSettingsInfo[device].ds4winSettings.m_LowLed.green = (byte)value;
LowColorGChanged?.Invoke(this, EventArgs.Empty); LowColorGChanged?.Invoke(this, EventArgs.Empty);
LowColorGStringChanged?.Invoke(this, EventArgs.Empty); LowColorGStringChanged?.Invoke(this, EventArgs.Empty);
} }
@ -177,16 +177,16 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public string LowColorGString public string LowColorGString
{ {
get => $"#{ Global.LowColor[device].green.ToString("X2")}00FF00"; get => $"#{ Global.LightbarSettingsInfo[device].ds4winSettings.m_LowLed.green.ToString("X2")}00FF00";
} }
public event EventHandler LowColorGStringChanged; public event EventHandler LowColorGStringChanged;
public int LowColorB public int LowColorB
{ {
get => Global.LowColor[device].blue; get => Global.LightbarSettingsInfo[device].ds4winSettings.m_LowLed.blue;
set set
{ {
Global.LowColor[device].blue = (byte)value; Global.LightbarSettingsInfo[device].ds4winSettings.m_LowLed.blue = (byte)value;
LowColorBChanged?.Invoke(this, EventArgs.Empty); LowColorBChanged?.Invoke(this, EventArgs.Empty);
LowColorBStringChanged?.Invoke(this, EventArgs.Empty); LowColorBStringChanged?.Invoke(this, EventArgs.Empty);
} }
@ -195,7 +195,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public string LowColorBString public string LowColorBString
{ {
get => $"#{ Global.LowColor[device].blue.ToString("X2")}0000FF"; get => $"#{ Global.LightbarSettingsInfo[device].ds4winSettings.m_LowLed.blue.ToString("X2")}0000FF";
} }
public event EventHandler LowColorBStringChanged; public event EventHandler LowColorBStringChanged;
@ -203,7 +203,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
{ {
get get
{ {
ref DS4Color color = ref Global.LowColor[device]; ref DS4Color color = ref Global.LightbarSettingsInfo[device].ds4winSettings.m_LowLed;
return new System.Windows.Media.Color() return new System.Windows.Media.Color()
{ {
A = 255, A = 255,
@ -216,24 +216,24 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public int FlashTypeIndex public int FlashTypeIndex
{ {
get => Global.FlashType[device]; get => Global.LightbarSettingsInfo[device].ds4winSettings.flashType; //Global.FlashType[device];
set => Global.FlashType[device] = (byte)value; set => Global.LightbarSettingsInfo[device].ds4winSettings.flashType = (byte)value;
} }
public int FlashAt public int FlashAt
{ {
get => Global.FlashAt[device]; get => Global.LightbarSettingsInfo[device].ds4winSettings.flashAt; //Global.FlashAt[device];
set => Global.FlashAt[device] = value; set => Global.LightbarSettingsInfo[device].ds4winSettings.flashAt = value;
} }
public string FlashColor public string FlashColor
{ {
get get
{ {
ref DS4Color color = ref Global.FlashColor[device]; ref DS4Color color = ref Global.LightbarSettingsInfo[device].ds4winSettings.m_FlashLed;
if (color.red == 0 && color.green == 0 && color.blue == 0) if (color.red == 0 && color.green == 0 && color.blue == 0)
{ {
color = ref Global.MainColor[device]; color = ref Global.LightbarSettingsInfo[device].ds4winSettings.m_Led;
} }
return $"#FF{color.red.ToString("X2")}{color.green.ToString("X2")}{color.blue.ToString("X2")}"; return $"#FF{color.red.ToString("X2")}{color.green.ToString("X2")}{color.blue.ToString("X2")}";
@ -245,10 +245,10 @@ namespace DS4WinWPF.DS4Forms.ViewModels
{ {
get get
{ {
ref DS4Color color = ref Global.FlashColor[device]; ref DS4Color color = ref Global.LightbarSettingsInfo[device].ds4winSettings.m_FlashLed;
if (color.red == 0 && color.green == 0 && color.blue == 0) if (color.red == 0 && color.green == 0 && color.blue == 0)
{ {
color = ref Global.MainColor[device]; color = ref Global.LightbarSettingsInfo[device].ds4winSettings.m_Led;
} }
return new System.Windows.Media.Color() return new System.Windows.Media.Color()
@ -263,20 +263,20 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public int ChargingType public int ChargingType
{ {
get => Global.ChargingType[device]; get => Global.LightbarSettingsInfo[device].ds4winSettings.chargingType;
set set
{ {
Global.ChargingType[device] = value; Global.LightbarSettingsInfo[device].ds4winSettings.chargingType = value;
ChargingColorVisibleChanged?.Invoke(this, EventArgs.Empty); ChargingColorVisibleChanged?.Invoke(this, EventArgs.Empty);
} }
} }
public bool ColorBatteryPercent public bool ColorBatteryPercent
{ {
get => Global.LedAsBatteryIndicator[device]; get => Global.LightbarSettingsInfo[device].ds4winSettings.ledAsBattery;
set set
{ {
Global.LedAsBatteryIndicator[device] = value; Global.LightbarSettingsInfo[device].ds4winSettings.ledAsBattery = value;
} }
} }
@ -284,7 +284,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
{ {
get get
{ {
ref DS4Color color = ref Global.ChargingColor[device]; ref DS4Color color = ref Global.LightbarSettingsInfo[device].ds4winSettings.m_ChargingLed;
return $"#FF{color.red.ToString("X2")}{color.green.ToString("X2")}{color.blue.ToString("X2")}"; return $"#FF{color.red.ToString("X2")}{color.green.ToString("X2")}{color.blue.ToString("X2")}";
} }
} }
@ -294,7 +294,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
{ {
get get
{ {
ref DS4Color color = ref Global.ChargingColor[device]; ref DS4Color color = ref Global.LightbarSettingsInfo[device].ds4winSettings.m_ChargingLed;
return new System.Windows.Media.Color() return new System.Windows.Media.Color()
{ {
A = 255, A = 255,
@ -307,16 +307,16 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public Visibility ChargingColorVisible public Visibility ChargingColorVisible
{ {
get => Global.ChargingType[device] == 3 ? Visibility.Visible : Visibility.Hidden; get => Global.LightbarSettingsInfo[device].ds4winSettings.chargingType == 3 ? Visibility.Visible : Visibility.Hidden;
} }
public event EventHandler ChargingColorVisibleChanged; public event EventHandler ChargingColorVisibleChanged;
public double Rainbow public double Rainbow
{ {
get => Global.Rainbow[device]; get => Global.LightbarSettingsInfo[device].ds4winSettings.rainbow;
set set
{ {
Global.Rainbow[device] = value; Global.LightbarSettingsInfo[device].ds4winSettings.rainbow = value;
RainbowChanged?.Invoke(this, EventArgs.Empty); RainbowChanged?.Invoke(this, EventArgs.Empty);
RainbowExistsChanged?.Invoke(this, EventArgs.Empty); RainbowExistsChanged?.Invoke(this, EventArgs.Empty);
} }
@ -325,15 +325,15 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public bool RainbowExists public bool RainbowExists
{ {
get => Global.Rainbow[device] != 0.0; get => Global.LightbarSettingsInfo[device].ds4winSettings.rainbow != 0.0;
} }
public event EventHandler RainbowExistsChanged; public event EventHandler RainbowExistsChanged;
public double MaxSatRainbow public double MaxSatRainbow
{ {
get => Global.MaxSatRainbow[device] * 100.0; get => Global.LightbarSettingsInfo[device].ds4winSettings.maxRainbowSat * 100.0;
set => Global.MaxSatRainbow[device] = value / 100.0; set => Global.LightbarSettingsInfo[device].ds4winSettings.maxRainbowSat = value / 100.0;
} }
public int RumbleBoost public int RumbleBoost
@ -1508,19 +1508,19 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public void UpdateFlashColor(System.Windows.Media.Color color) public void UpdateFlashColor(System.Windows.Media.Color color)
{ {
Global.FlashColor[device] = new DS4Color() { red = color.R, green = color.G, blue = color.B }; Global.LightbarSettingsInfo[device].ds4winSettings.m_FlashLed = new DS4Color() { red = color.R, green = color.G, blue = color.B };
FlashColorChanged?.Invoke(this, EventArgs.Empty); FlashColorChanged?.Invoke(this, EventArgs.Empty);
} }
public void UpdateMainColor(System.Windows.Media.Color color) public void UpdateMainColor(System.Windows.Media.Color color)
{ {
Global.MainColor[device] = new DS4Color() { red = color.R, green = color.G, blue = color.B }; Global.LightbarSettingsInfo[device].ds4winSettings.m_Led = new DS4Color() { red = color.R, green = color.G, blue = color.B };
MainColorChanged?.Invoke(this, EventArgs.Empty); MainColorChanged?.Invoke(this, EventArgs.Empty);
} }
public void UpdateLowColor(System.Windows.Media.Color color) public void UpdateLowColor(System.Windows.Media.Color color)
{ {
ref DS4Color lowColor = ref Global.LowColor[device]; ref DS4Color lowColor = ref Global.LightbarSettingsInfo[device].ds4winSettings.m_LowLed;
lowColor.red = color.R; lowColor.red = color.R;
lowColor.green = color.G; lowColor.green = color.G;
lowColor.blue = color.B; lowColor.blue = color.B;
@ -1568,7 +1568,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public void UpdateChargingColor(System.Windows.Media.Color color) public void UpdateChargingColor(System.Windows.Media.Color color)
{ {
ref DS4Color chargeColor = ref Global.ChargingColor[device]; ref DS4Color chargeColor = ref Global.LightbarSettingsInfo[device].ds4winSettings.m_ChargingLed;
chargeColor.red = color.R; chargeColor.red = color.R;
chargeColor.green = color.G; chargeColor.green = color.G;
chargeColor.blue = color.B; chargeColor.blue = color.B;