diff --git a/DS4Windows/DS4Control/DTOXml/ProfileDTO.cs b/DS4Windows/DS4Control/DTOXml/ProfileDTO.cs index 6e2c8da..bb4304a 100644 --- a/DS4Windows/DS4Control/DTOXml/ProfileDTO.cs +++ b/DS4Windows/DS4Control/DTOXml/ProfileDTO.cs @@ -2769,12 +2769,12 @@ public void PostProcessXml() if (!string.IsNullOrEmpty(GreenColorString)) { - byte.TryParse(RedColorString, out _ledColor.green); + byte.TryParse(GreenColorString, out _ledColor.green); } if (!string.IsNullOrEmpty(BlueColorString)) { - byte.TryParse(RedColorString, out _ledColor.blue); + byte.TryParse(BlueColorString, out _ledColor.blue); } } diff --git a/DS4WindowsTests/ProfileTests.cs b/DS4WindowsTests/ProfileTests.cs index e606de7..2dd7436 100644 --- a/DS4WindowsTests/ProfileTests.cs +++ b/DS4WindowsTests/ProfileTests.cs @@ -524,5 +524,32 @@ public void CheckWriteProfile() Assert.AreEqual(OutContType.ViiperX360, roundTripStore.outputDevType[0]); } + + [TestMethod] + public void CheckLegacyPerChannelColorRead() + { + // Old profiles store the lightbar colour as separate // + // elements rather than a combined . Each channel must be parsed + // from its own element. + string legacyColorProfileXml = @" + + 10 + 20 + 30 +"; + + XmlSerializer serializer = new XmlSerializer(typeof(ProfileDTO), + ProfileDTO.GetAttributeOverrides()); + using StringReader sr = new StringReader(legacyColorProfileXml); + ProfileDTO dto = serializer.Deserialize(sr) as ProfileDTO; + dto.DeviceIndex = 0; + BackingStore tempStore = new BackingStore(); + dto.MapTo(tempStore); + + DS4Color led = tempStore.lightbarSettingInfo[0].ds4winSettings.m_Led; + Assert.AreEqual((byte)10, led.red); + Assert.AreEqual((byte)20, led.green); + Assert.AreEqual((byte)30, led.blue); + } } }