1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Core - Updated RGB.NET

Plugins - Allow device providers to override the device layout name
This commit is contained in:
Robert 2022-01-07 12:03:40 +01:00
parent 8b1ce4e0ec
commit 3c827d1a0a
10 changed files with 75 additions and 75 deletions

View File

@ -206,23 +206,23 @@
}, },
"RGB.NET.Core": { "RGB.NET.Core": {
"type": "Transitive", "type": "Transitive",
"resolved": "1.0.0-prerelease1", "resolved": "1.0.0-prerelease7",
"contentHash": "aaCPk++kr1TaV/qWYeol5975IN3XifDuuQ9wrCD+nw1cy05BMdGVhuQ72ITb0YRBedssd/btkM51ZABsBd8CEQ==" "contentHash": "IIja5sC4QZ5pbSNckRCG7TlY4U6j/dRbrl4e2FZqsTGgsevaVB3IqonUQLFY1GGst4xNSl2oh0A23coXQxXGbQ=="
}, },
"RGB.NET.Layout": { "RGB.NET.Layout": {
"type": "Transitive", "type": "Transitive",
"resolved": "1.0.0-prerelease1", "resolved": "1.0.0-prerelease7",
"contentHash": "nbaHbcY59tzFSeTDbImhrcR1ZyJpoC0x6WawXdtGXO7x3F91ajM7kM5SJwi/5jHdD61vGV0ARuznmR8ErAWegQ==", "contentHash": "S0kfWVa8EfMOAl2WPHsq98dwaO+SNz9TWr1AtMkdo8aZuYIVhaJ1c+mSAMMnH1V+mSbxDWPHWkNzi9ITszJucA==",
"dependencies": { "dependencies": {
"RGB.NET.Core": "1.0.0-prerelease1" "RGB.NET.Core": "1.0.0-prerelease7"
} }
}, },
"RGB.NET.Presets": { "RGB.NET.Presets": {
"type": "Transitive", "type": "Transitive",
"resolved": "1.0.0-prerelease1", "resolved": "1.0.0-prerelease7",
"contentHash": "XU8XeI0fQF26fd0pQHgoe9RaROuvENmZlX/1QyyaN9P3j0LtYmy6ycWZbsXp8byLT0UcGbS+odMiQQAnK+kxgg==", "contentHash": "NgShvOPQM0miOsdqMKjkNunngJUZMwr8KR8ME2/Ksir7wgIQfgJj1YwZy8aIj+ar7fDo6VZJZenAshs/Ul+04A==",
"dependencies": { "dependencies": {
"RGB.NET.Core": "1.0.0-prerelease1" "RGB.NET.Core": "1.0.0-prerelease7"
} }
}, },
"runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl": { "runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl": {
@ -1244,9 +1244,9 @@
"Ninject": "3.3.4", "Ninject": "3.3.4",
"Ninject.Extensions.ChildKernel": "3.3.0", "Ninject.Extensions.ChildKernel": "3.3.0",
"Ninject.Extensions.Conventions": "3.3.0", "Ninject.Extensions.Conventions": "3.3.0",
"RGB.NET.Core": "1.0.0-prerelease1", "RGB.NET.Core": "1.0.0-prerelease7",
"RGB.NET.Layout": "1.0.0-prerelease1", "RGB.NET.Layout": "1.0.0-prerelease7",
"RGB.NET.Presets": "1.0.0-prerelease1", "RGB.NET.Presets": "1.0.0-prerelease7",
"Serilog": "2.10.0", "Serilog": "2.10.0",
"Serilog.Sinks.Console": "4.0.0", "Serilog.Sinks.Console": "4.0.0",
"Serilog.Sinks.Debug": "2.0.0", "Serilog.Sinks.Debug": "2.0.0",

View File

@ -47,9 +47,9 @@
<PackageReference Include="Ninject" Version="3.3.4" /> <PackageReference Include="Ninject" Version="3.3.4" />
<PackageReference Include="Ninject.Extensions.ChildKernel" Version="3.3.0" /> <PackageReference Include="Ninject.Extensions.ChildKernel" Version="3.3.0" />
<PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" /> <PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" />
<PackageReference Include="RGB.NET.Core" Version="1.0.0-prerelease1" /> <PackageReference Include="RGB.NET.Core" Version="1.0.0-prerelease7" />
<PackageReference Include="RGB.NET.Layout" Version="1.0.0-prerelease1" /> <PackageReference Include="RGB.NET.Layout" Version="1.0.0-prerelease7" />
<PackageReference Include="RGB.NET.Presets" Version="1.0.0-prerelease1" /> <PackageReference Include="RGB.NET.Presets" Version="1.0.0-prerelease7" />
<PackageReference Include="Serilog" Version="2.10.0" /> <PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0" /> <PackageReference Include="Serilog.Sinks.Console" Version="4.0.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" /> <PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />

View File

@ -350,23 +350,6 @@ namespace Artemis.Core
return artemisLed; return artemisLed;
} }
/// <summary>
/// Generates the default layout file name of the device
/// </summary>
/// <param name="includeExtension">If true, the .xml extension is added to the file name</param>
/// <returns>The resulting file name e.g. CORSAIR GLAIVE.xml or K95 RGB-ISO.xml</returns>
public string GetLayoutFileName(bool includeExtension = true)
{
// Take out invalid file name chars, may not be perfect but neither are you
string fileName = System.IO.Path.GetInvalidFileNameChars().Aggregate(RgbDevice.DeviceInfo.Model, (current, c) => current.Replace(c, '-'));
if (RgbDevice.DeviceInfo.DeviceType == RGBDeviceType.Keyboard)
fileName = $"{fileName}-{PhysicalLayout.ToString().ToUpper()}";
if (includeExtension)
fileName = $"{fileName}.xml";
return fileName;
}
/// <summary> /// <summary>
/// Occurs when the underlying RGB.NET device was updated /// Occurs when the underlying RGB.NET device was updated
/// </summary> /// </summary>

View File

@ -1,5 +1,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq;
using Ninject; using Ninject;
using RGB.NET.Core; using RGB.NET.Core;
using Serilog; using Serilog;
@ -75,7 +76,7 @@ namespace Artemis.Core.DeviceProviders
layoutDir, layoutDir,
device.RgbDevice.DeviceInfo.Manufacturer, device.RgbDevice.DeviceInfo.Manufacturer,
device.DeviceType.ToString(), device.DeviceType.ToString(),
device.GetLayoutFileName() GetDeviceLayoutName(device)
); );
return new ArtemisLayout(filePath, LayoutSource.Plugin); return new ArtemisLayout(filePath, LayoutSource.Plugin);
} }
@ -92,7 +93,7 @@ namespace Artemis.Core.DeviceProviders
layoutDir, layoutDir,
device.RgbDevice.DeviceInfo.Manufacturer, device.RgbDevice.DeviceInfo.Manufacturer,
device.DeviceType.ToString(), device.DeviceType.ToString(),
device.GetLayoutFileName() GetDeviceLayoutName(device)
); );
return new ArtemisLayout(filePath, LayoutSource.User); return new ArtemisLayout(filePath, LayoutSource.User);
} }
@ -108,5 +109,20 @@ namespace Artemis.Core.DeviceProviders
{ {
throw new NotImplementedException("Device provider does not support detecting logical layouts (don't call base.GetLogicalLayout())"); throw new NotImplementedException("Device provider does not support detecting logical layouts (don't call base.GetLogicalLayout())");
} }
/// <summary>
/// Called when determining which file name to use when loading the layout of the specified <paramref name="device"></paramref>.
/// </summary>
/// <param name="device">The device to determine the layout file name for.</param>
/// <returns>A file name, including an extension</returns>
public virtual string GetDeviceLayoutName(ArtemisDevice device)
{
// Take out invalid file name chars, may not be perfect but neither are you
string fileName = Path.GetInvalidFileNameChars().Aggregate(device.RgbDevice.DeviceInfo.Model, (current, c) => current.Replace(c, '-'));
if (device.RgbDevice.DeviceInfo.DeviceType == RGBDeviceType.Keyboard)
fileName = $"{fileName}-{device.PhysicalLayout.ToString().ToUpper()}";
return fileName + ".xml";
}
} }
} }

View File

@ -75,26 +75,26 @@
}, },
"RGB.NET.Core": { "RGB.NET.Core": {
"type": "Direct", "type": "Direct",
"requested": "[1.0.0-prerelease1, )", "requested": "[1.0.0-prerelease7, )",
"resolved": "1.0.0-prerelease1", "resolved": "1.0.0-prerelease7",
"contentHash": "aaCPk++kr1TaV/qWYeol5975IN3XifDuuQ9wrCD+nw1cy05BMdGVhuQ72ITb0YRBedssd/btkM51ZABsBd8CEQ==" "contentHash": "IIja5sC4QZ5pbSNckRCG7TlY4U6j/dRbrl4e2FZqsTGgsevaVB3IqonUQLFY1GGst4xNSl2oh0A23coXQxXGbQ=="
}, },
"RGB.NET.Layout": { "RGB.NET.Layout": {
"type": "Direct", "type": "Direct",
"requested": "[1.0.0-prerelease1, )", "requested": "[1.0.0-prerelease7, )",
"resolved": "1.0.0-prerelease1", "resolved": "1.0.0-prerelease7",
"contentHash": "nbaHbcY59tzFSeTDbImhrcR1ZyJpoC0x6WawXdtGXO7x3F91ajM7kM5SJwi/5jHdD61vGV0ARuznmR8ErAWegQ==", "contentHash": "S0kfWVa8EfMOAl2WPHsq98dwaO+SNz9TWr1AtMkdo8aZuYIVhaJ1c+mSAMMnH1V+mSbxDWPHWkNzi9ITszJucA==",
"dependencies": { "dependencies": {
"RGB.NET.Core": "1.0.0-prerelease1" "RGB.NET.Core": "1.0.0-prerelease7"
} }
}, },
"RGB.NET.Presets": { "RGB.NET.Presets": {
"type": "Direct", "type": "Direct",
"requested": "[1.0.0-prerelease1, )", "requested": "[1.0.0-prerelease7, )",
"resolved": "1.0.0-prerelease1", "resolved": "1.0.0-prerelease7",
"contentHash": "XU8XeI0fQF26fd0pQHgoe9RaROuvENmZlX/1QyyaN9P3j0LtYmy6ycWZbsXp8byLT0UcGbS+odMiQQAnK+kxgg==", "contentHash": "NgShvOPQM0miOsdqMKjkNunngJUZMwr8KR8ME2/Ksir7wgIQfgJj1YwZy8aIj+ar7fDo6VZJZenAshs/Ul+04A==",
"dependencies": { "dependencies": {
"RGB.NET.Core": "1.0.0-prerelease1" "RGB.NET.Core": "1.0.0-prerelease7"
} }
}, },
"Serilog": { "Serilog": {

View File

@ -39,7 +39,7 @@
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" /> <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" />
<PackageReference Include="Ninject" Version="3.3.4" /> <PackageReference Include="Ninject" Version="3.3.4" />
<PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" /> <PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" />
<PackageReference Include="RGB.NET.Core" Version="1.0.0-prerelease1" /> <PackageReference Include="RGB.NET.Core" Version="1.0.0-prerelease7" />
<PackageReference Include="SharpVectors.Reloaded" Version="1.7.5" /> <PackageReference Include="SharpVectors.Reloaded" Version="1.7.5" />
<PackageReference Include="SkiaSharp" Version="2.80.3" /> <PackageReference Include="SkiaSharp" Version="2.80.3" />
<PackageReference Include="SkiaSharp.Views.WPF" Version="2.80.3" /> <PackageReference Include="SkiaSharp.Views.WPF" Version="2.80.3" />

View File

@ -54,9 +54,9 @@
}, },
"RGB.NET.Core": { "RGB.NET.Core": {
"type": "Direct", "type": "Direct",
"requested": "[1.0.0-prerelease1, )", "requested": "[1.0.0-prerelease7, )",
"resolved": "1.0.0-prerelease1", "resolved": "1.0.0-prerelease7",
"contentHash": "aaCPk++kr1TaV/qWYeol5975IN3XifDuuQ9wrCD+nw1cy05BMdGVhuQ72ITb0YRBedssd/btkM51ZABsBd8CEQ==" "contentHash": "IIja5sC4QZ5pbSNckRCG7TlY4U6j/dRbrl4e2FZqsTGgsevaVB3IqonUQLFY1GGst4xNSl2oh0A23coXQxXGbQ=="
}, },
"SharpVectors.Reloaded": { "SharpVectors.Reloaded": {
"type": "Direct", "type": "Direct",
@ -272,18 +272,18 @@
}, },
"RGB.NET.Layout": { "RGB.NET.Layout": {
"type": "Transitive", "type": "Transitive",
"resolved": "1.0.0-prerelease1", "resolved": "1.0.0-prerelease7",
"contentHash": "nbaHbcY59tzFSeTDbImhrcR1ZyJpoC0x6WawXdtGXO7x3F91ajM7kM5SJwi/5jHdD61vGV0ARuznmR8ErAWegQ==", "contentHash": "S0kfWVa8EfMOAl2WPHsq98dwaO+SNz9TWr1AtMkdo8aZuYIVhaJ1c+mSAMMnH1V+mSbxDWPHWkNzi9ITszJucA==",
"dependencies": { "dependencies": {
"RGB.NET.Core": "1.0.0-prerelease1" "RGB.NET.Core": "1.0.0-prerelease7"
} }
}, },
"RGB.NET.Presets": { "RGB.NET.Presets": {
"type": "Transitive", "type": "Transitive",
"resolved": "1.0.0-prerelease1", "resolved": "1.0.0-prerelease7",
"contentHash": "XU8XeI0fQF26fd0pQHgoe9RaROuvENmZlX/1QyyaN9P3j0LtYmy6ycWZbsXp8byLT0UcGbS+odMiQQAnK+kxgg==", "contentHash": "NgShvOPQM0miOsdqMKjkNunngJUZMwr8KR8ME2/Ksir7wgIQfgJj1YwZy8aIj+ar7fDo6VZJZenAshs/Ul+04A==",
"dependencies": { "dependencies": {
"RGB.NET.Core": "1.0.0-prerelease1" "RGB.NET.Core": "1.0.0-prerelease7"
} }
}, },
"runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl": { "runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl": {
@ -1325,9 +1325,9 @@
"Ninject": "3.3.4", "Ninject": "3.3.4",
"Ninject.Extensions.ChildKernel": "3.3.0", "Ninject.Extensions.ChildKernel": "3.3.0",
"Ninject.Extensions.Conventions": "3.3.0", "Ninject.Extensions.Conventions": "3.3.0",
"RGB.NET.Core": "1.0.0-prerelease1", "RGB.NET.Core": "1.0.0-prerelease7",
"RGB.NET.Layout": "1.0.0-prerelease1", "RGB.NET.Layout": "1.0.0-prerelease7",
"RGB.NET.Presets": "1.0.0-prerelease1", "RGB.NET.Presets": "1.0.0-prerelease7",
"Serilog": "2.10.0", "Serilog": "2.10.0",
"Serilog.Sinks.Console": "4.0.0", "Serilog.Sinks.Console": "4.0.0",
"Serilog.Sinks.Debug": "2.0.0", "Serilog.Sinks.Debug": "2.0.0",

View File

@ -145,8 +145,8 @@
<PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" /> <PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" />
<PackageReference Include="Ookii.Dialogs.Wpf" Version="3.1.0" /> <PackageReference Include="Ookii.Dialogs.Wpf" Version="3.1.0" />
<PackageReference Include="RawInput.Sharp" Version="0.0.4" /> <PackageReference Include="RawInput.Sharp" Version="0.0.4" />
<PackageReference Include="RGB.NET.Core" Version="1.0.0-prerelease1" /> <PackageReference Include="RGB.NET.Core" Version="1.0.0-prerelease7" />
<PackageReference Include="RGB.NET.Layout" Version="1.0.0-prerelease1" /> <PackageReference Include="RGB.NET.Layout" Version="1.0.0-prerelease7" />
<PackageReference Include="Serilog" Version="2.10.0" /> <PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="SkiaSharp.Views.WPF" Version="2.80.3" /> <PackageReference Include="SkiaSharp.Views.WPF" Version="2.80.3" />
<PackageReference Include="SkiaSharp.Vulkan.SharpVk" Version="2.80.3" /> <PackageReference Include="SkiaSharp.Vulkan.SharpVk" Version="2.80.3" />

View File

@ -213,7 +213,8 @@ namespace Artemis.UI.Screens.Settings.Device
Device.RgbDevice.DeviceInfo.Manufacturer, Device.RgbDevice.DeviceInfo.Manufacturer,
Device.DeviceType.ToString() Device.DeviceType.ToString()
); );
string filePath = Path.Combine(directory, Device.GetLayoutFileName());
string filePath = Path.Combine(directory, Device.DeviceProvider.GetDeviceLayoutName(Device));
Core.Utilities.CreateAccessibleDirectory(directory); Core.Utilities.CreateAccessibleDirectory(directory);
// XML // XML

View File

@ -124,17 +124,17 @@
}, },
"RGB.NET.Core": { "RGB.NET.Core": {
"type": "Direct", "type": "Direct",
"requested": "[1.0.0-prerelease1, )", "requested": "[1.0.0-prerelease7, )",
"resolved": "1.0.0-prerelease1", "resolved": "1.0.0-prerelease7",
"contentHash": "aaCPk++kr1TaV/qWYeol5975IN3XifDuuQ9wrCD+nw1cy05BMdGVhuQ72ITb0YRBedssd/btkM51ZABsBd8CEQ==" "contentHash": "IIja5sC4QZ5pbSNckRCG7TlY4U6j/dRbrl4e2FZqsTGgsevaVB3IqonUQLFY1GGst4xNSl2oh0A23coXQxXGbQ=="
}, },
"RGB.NET.Layout": { "RGB.NET.Layout": {
"type": "Direct", "type": "Direct",
"requested": "[1.0.0-prerelease1, )", "requested": "[1.0.0-prerelease7, )",
"resolved": "1.0.0-prerelease1", "resolved": "1.0.0-prerelease7",
"contentHash": "nbaHbcY59tzFSeTDbImhrcR1ZyJpoC0x6WawXdtGXO7x3F91ajM7kM5SJwi/5jHdD61vGV0ARuznmR8ErAWegQ==", "contentHash": "S0kfWVa8EfMOAl2WPHsq98dwaO+SNz9TWr1AtMkdo8aZuYIVhaJ1c+mSAMMnH1V+mSbxDWPHWkNzi9ITszJucA==",
"dependencies": { "dependencies": {
"RGB.NET.Core": "1.0.0-prerelease1" "RGB.NET.Core": "1.0.0-prerelease7"
} }
}, },
"Serilog": { "Serilog": {
@ -394,10 +394,10 @@
}, },
"RGB.NET.Presets": { "RGB.NET.Presets": {
"type": "Transitive", "type": "Transitive",
"resolved": "1.0.0-prerelease1", "resolved": "1.0.0-prerelease7",
"contentHash": "XU8XeI0fQF26fd0pQHgoe9RaROuvENmZlX/1QyyaN9P3j0LtYmy6ycWZbsXp8byLT0UcGbS+odMiQQAnK+kxgg==", "contentHash": "NgShvOPQM0miOsdqMKjkNunngJUZMwr8KR8ME2/Ksir7wgIQfgJj1YwZy8aIj+ar7fDo6VZJZenAshs/Ul+04A==",
"dependencies": { "dependencies": {
"RGB.NET.Core": "1.0.0-prerelease1" "RGB.NET.Core": "1.0.0-prerelease7"
} }
}, },
"runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl": { "runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl": {
@ -1454,9 +1454,9 @@
"Ninject": "3.3.4", "Ninject": "3.3.4",
"Ninject.Extensions.ChildKernel": "3.3.0", "Ninject.Extensions.ChildKernel": "3.3.0",
"Ninject.Extensions.Conventions": "3.3.0", "Ninject.Extensions.Conventions": "3.3.0",
"RGB.NET.Core": "1.0.0-prerelease1", "RGB.NET.Core": "1.0.0-prerelease7",
"RGB.NET.Layout": "1.0.0-prerelease1", "RGB.NET.Layout": "1.0.0-prerelease7",
"RGB.NET.Presets": "1.0.0-prerelease1", "RGB.NET.Presets": "1.0.0-prerelease7",
"Serilog": "2.10.0", "Serilog": "2.10.0",
"Serilog.Sinks.Console": "4.0.0", "Serilog.Sinks.Console": "4.0.0",
"Serilog.Sinks.Debug": "2.0.0", "Serilog.Sinks.Debug": "2.0.0",
@ -1486,7 +1486,7 @@
"Microsoft.Xaml.Behaviors.Wpf": "1.1.31", "Microsoft.Xaml.Behaviors.Wpf": "1.1.31",
"Ninject": "3.3.4", "Ninject": "3.3.4",
"Ninject.Extensions.Conventions": "3.3.0", "Ninject.Extensions.Conventions": "3.3.0",
"RGB.NET.Core": "1.0.0-prerelease1", "RGB.NET.Core": "1.0.0-prerelease7",
"SharpVectors.Reloaded": "1.7.5", "SharpVectors.Reloaded": "1.7.5",
"SkiaSharp": "2.80.3", "SkiaSharp": "2.80.3",
"SkiaSharp.Views.WPF": "2.80.3", "SkiaSharp.Views.WPF": "2.80.3",