diff --git a/docs/reference/master Button layout for RIOvJoy2.xlsx b/docs/reference/master Button layout for RIOvJoy2.xlsx new file mode 100644 index 0000000..caaf012 Binary files /dev/null and b/docs/reference/master Button layout for RIOvJoy2.xlsx differ diff --git a/src/RioJoy.Core/Profiles/RioIniImporter.cs b/src/RioJoy.Core/Profiles/RioIniImporter.cs index c11a5ae..b6b88aa 100644 --- a/src/RioJoy.Core/Profiles/RioIniImporter.cs +++ b/src/RioJoy.Core/Profiles/RioIniImporter.cs @@ -21,7 +21,7 @@ public static class RioIniImporter var profile = new RioProfile { Name = name, - PlasmaGreeting = ini.GetString("Plasma", "Greeting"), + PlasmaGreeting = StripQuotes(ini.GetString("Plasma", "Greeting")), WallpaperPath = ini.GetString("Desktop", "File"), Calibration = new AxisCalibrationConfig { @@ -48,6 +48,16 @@ public static class RioIniImporter return profile; } + // The gsheet writes the greeting as a quoted string (e.g. Greeting="Hello,"); + // strip a single pair of surrounding double quotes so it displays cleanly. + private static string? StripQuotes(string? value) + { + if (value is null) + return null; + string v = value.Trim(); + return v.Length >= 2 && v[0] == '"' && v[^1] == '"' ? v[1..^1] : v; + } + // Keys look like "RIO00".."RIO6F": "RIO" + a hex address into the iRIO table. private static bool TryParseButtonAddress(string key, out int address) { diff --git a/tests/RioJoy.Core.Tests/Profiles/RioIniImporterTests.cs b/tests/RioJoy.Core.Tests/Profiles/RioIniImporterTests.cs index 22c6255..221d84f 100644 --- a/tests/RioJoy.Core.Tests/Profiles/RioIniImporterTests.cs +++ b/tests/RioJoy.Core.Tests/Profiles/RioIniImporterTests.cs @@ -55,4 +55,37 @@ public class RioIniImporterTests RioProfile p = RioIniImporter.Import("[JoyStick]\ninvertX = true"); Assert.True(p.Calibration.EnableZR); } + + // The real gsheet "INI_V2" output: modifier-stacked words (0x8F26 = + // lit+shift+ctrl+alt+ext + VK 0x26), keypad VK words (0x30), and RIO + // command words (0x7000) must all survive import verbatim. + private const string SheetSample = """ + ;RIO INI V2 built useing gsheet configurator's final value + [Desktop] + File=C:\games\RIO\defalt.bmp + [Plasma] + Greeting="Hello," + [JoyStick] + invertX=0 + enableZR=1 + + [Buttons] + RIO04=0x8F26 + RIO50=0x30 + RIO60=0x7000 + RIO6F=0x700F + """; + + [Fact] + public void Imports_RealSheetOutput_PreservesRawWords() + { + RioProfile p = RioIniImporter.Import(SheetSample, "Sheet"); + + Assert.Equal(0x8F26, p.Buttons[0x04]); // lit + all modifiers + extended + Assert.Equal(0x30, p.Buttons[0x50]); // keypad '0' + Assert.Equal(0x7000, p.Buttons[0x60]); // RIO command word + Assert.Equal(0x700F, p.Buttons[0x6F]); // last address in the table + Assert.Equal(@"C:\games\RIO\defalt.bmp", p.WallpaperPath); + Assert.Equal("Hello,", p.PlasmaGreeting); // surrounding quotes stripped + } }