Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DS4Windows/DS4Control/DTOXml/ProfileDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2668,12 +2668,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);
}
}

Expand Down
27 changes: 27 additions & 0 deletions DS4WindowsTests/ProfileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,5 +378,32 @@ public void CheckWriteProfile()
Assert.AreEqual(true, !string.IsNullOrEmpty(testStr));
Assert.AreEqual(defaultProfileXml, testStr);
}

[TestMethod]
public void CheckLegacyPerChannelColorRead()
{
// Old profiles store the lightbar colour as separate <Red>/<Green>/<Blue>
// elements rather than a combined <Color>. Each channel must be parsed
// from its own element.
string legacyColorProfileXml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<DS4Windows config_version=""5"">
<Red>10</Red>
<Green>20</Green>
<Blue>30</Blue>
</DS4Windows>";

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);
}
}
}
Loading