INI import: strip greeting quotes; add gsheet reference
Strip a surrounding pair of double quotes from the [Plasma] Greeting on import (the gsheet "INI_V2" output writes Greeting="..."), and add the master button-layout spreadsheet that documents the RIO.ini format and the 16-bit map-word encoding. Test covers the real sheet output (modifier-stacked words, keypad VK words, RIO command words) round-tripping verbatim. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Binary file not shown.
@@ -21,7 +21,7 @@ public static class RioIniImporter
|
|||||||
var profile = new RioProfile
|
var profile = new RioProfile
|
||||||
{
|
{
|
||||||
Name = name,
|
Name = name,
|
||||||
PlasmaGreeting = ini.GetString("Plasma", "Greeting"),
|
PlasmaGreeting = StripQuotes(ini.GetString("Plasma", "Greeting")),
|
||||||
WallpaperPath = ini.GetString("Desktop", "File"),
|
WallpaperPath = ini.GetString("Desktop", "File"),
|
||||||
Calibration = new AxisCalibrationConfig
|
Calibration = new AxisCalibrationConfig
|
||||||
{
|
{
|
||||||
@@ -48,6 +48,16 @@ public static class RioIniImporter
|
|||||||
return profile;
|
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.
|
// Keys look like "RIO00".."RIO6F": "RIO" + a hex address into the iRIO table.
|
||||||
private static bool TryParseButtonAddress(string key, out int address)
|
private static bool TryParseButtonAddress(string key, out int address)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,4 +55,37 @@ public class RioIniImporterTests
|
|||||||
RioProfile p = RioIniImporter.Import("[JoyStick]\ninvertX = true");
|
RioProfile p = RioIniImporter.Import("[JoyStick]\ninvertX = true");
|
||||||
Assert.True(p.Calibration.EnableZR);
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user