Profiles - Only set imports as changed if they actually had real changes

Default layouts - Added default keyboard and headset layouts
This commit is contained in:
Robert committed 2021-05-18 16:59:58 +02:00
1 parent 9168ac2823
commit f1eefe0761
145 files changed
+5874 -92

No files matched your search

@@ -48,7 +48,7 @@ namespace Artemis.Core
public void Apply(Layer layer, List<ArtemisDevice> devices)
{
IEnumerable<ArtemisDevice> matches = devices
.Where(d => DeviceType == RGBDeviceType.All || d.RgbDevice.DeviceInfo.DeviceType == DeviceType)
.Where(d => DeviceType == RGBDeviceType.All || d.DeviceType == DeviceType)
.OrderBy(d => d.Rectangle.Top)
.ThenBy(d => d.Rectangle.Left)
.Skip(Skip);
@@ -38,7 +38,7 @@ namespace Artemis.Core
public void Apply(Layer layer, List<ArtemisDevice> devices)
{
// Only keyboards should have the LEDs we care about
foreach (ArtemisDevice keyboard in devices.Where(d => d.RgbDevice.DeviceInfo.DeviceType == RGBDeviceType.Keyboard))
foreach (ArtemisDevice keyboard in devices.Where(d => d.DeviceType == RGBDeviceType.Keyboard))
{
List<LedId> ledIds = RegionLedIds[Section];
layer.AddLeds(keyboard.Leds.Where(l => ledIds.Contains(l.RgbLed.Id)));
+1 -1
View File
@@ -272,7 +272,7 @@ namespace Artemis.Core
{
DeviceIdentifier = artemisLed.Device.Identifier,
LedName = artemisLed.RgbLed.Id.ToString(),
PhysicalLayout = artemisLed.Device.RgbDevice.DeviceInfo.DeviceType == RGBDeviceType.Keyboard ? (int) artemisLed.Device.PhysicalLayout : null
PhysicalLayout = artemisLed.Device.DeviceType == RGBDeviceType.Keyboard ? (int) artemisLed.Device.PhysicalLayout : null
};
LayerEntity.Leds.Add(ledEntity);
}
@@ -83,11 +83,11 @@ namespace Artemis.Core
{
ArtemisDevice device = deviceLeds.Key;
// If there is already an adaption hint for this type, don't add another
if (AdaptionHints.Any(h => h is DeviceAdaptionHint d && d.DeviceType == device.RgbDevice.DeviceInfo.DeviceType))
if (AdaptionHints.Any(h => h is DeviceAdaptionHint d && d.DeviceType == device.DeviceType))
continue;
if (DoesLayerCoverDevice(device))
{
DeviceAdaptionHint hint = new() {DeviceType = device.RgbDevice.DeviceInfo.DeviceType};
DeviceAdaptionHint hint = new() {DeviceType = device.DeviceType};
AdaptionHints.Add(hint);
newHints.Add(hint);
}
@@ -6,7 +6,6 @@ using Artemis.Core.DeviceProviders;
using Artemis.Core.Services;
using Artemis.Storage.Entities.Surface;
using RGB.NET.Core;
using RGB.NET.Layout;
using SkiaSharp;
namespace Artemis.Core
@@ -91,6 +90,11 @@ namespace Artemis.Core
/// </summary>
public IRGBDevice RgbDevice { get; }
/// <summary>
/// Gets the device type of the ArtemisDevice
/// </summary>
public RGBDeviceType DeviceType => RgbDevice.DeviceInfo.DeviceType;
/// <summary>
/// Gets the device provider that provided this device
/// </summary>
@@ -351,6 +355,46 @@ namespace Artemis.Core
/// </summary>
public event EventHandler? DeviceUpdated;
/// <summary>
/// Applies the default categories for this device to the <see cref="Categories" /> list
/// </summary>
public void ApplyDefaultCategories()
{
switch (RgbDevice.DeviceInfo.DeviceType)
{
case RGBDeviceType.Keyboard:
case RGBDeviceType.Mouse:
case RGBDeviceType.Headset:
case RGBDeviceType.Mousepad:
case RGBDeviceType.HeadsetStand:
case RGBDeviceType.Keypad:
if (!Categories.Contains(DeviceCategory.Peripherals))
Categories.Add(DeviceCategory.Peripherals);
break;
case RGBDeviceType.Mainboard:
case RGBDeviceType.GraphicsCard:
case RGBDeviceType.DRAM:
case RGBDeviceType.Fan:
case RGBDeviceType.LedStripe:
case RGBDeviceType.Cooler:
if (!Categories.Contains(DeviceCategory.Case))
Categories.Add(DeviceCategory.Case);
break;
case RGBDeviceType.Speaker:
if (!Categories.Contains(DeviceCategory.Desk))
Categories.Add(DeviceCategory.Desk);
break;
case RGBDeviceType.Monitor:
if (!Categories.Contains(DeviceCategory.Monitor))
Categories.Add(DeviceCategory.Monitor);
break;
case RGBDeviceType.LedMatrix:
if (!Categories.Contains(DeviceCategory.Room))
Categories.Add(DeviceCategory.Room);
break;
}
}
/// <summary>
/// Invokes the <see cref="DeviceUpdated" /> event
/// </summary>
@@ -392,46 +436,6 @@ namespace Artemis.Core
OnDeviceUpdated();
}
/// <summary>
/// Applies the default categories for this device to the <see cref="Categories"/> list
/// </summary>
public void ApplyDefaultCategories()
{
switch (RgbDevice.DeviceInfo.DeviceType)
{
case RGBDeviceType.Keyboard:
case RGBDeviceType.Mouse:
case RGBDeviceType.Headset:
case RGBDeviceType.Mousepad:
case RGBDeviceType.HeadsetStand:
case RGBDeviceType.Keypad:
if (!Categories.Contains(DeviceCategory.Peripherals))
Categories.Add(DeviceCategory.Peripherals);
break;
case RGBDeviceType.Mainboard:
case RGBDeviceType.GraphicsCard:
case RGBDeviceType.DRAM:
case RGBDeviceType.Fan:
case RGBDeviceType.LedStripe:
case RGBDeviceType.Cooler:
if (!Categories.Contains(DeviceCategory.Case))
Categories.Add(DeviceCategory.Case);
break;
case RGBDeviceType.Speaker:
if (!Categories.Contains(DeviceCategory.Desk))
Categories.Add(DeviceCategory.Desk);
break;
case RGBDeviceType.Monitor:
if (!Categories.Contains(DeviceCategory.Monitor))
Categories.Add(DeviceCategory.Monitor);
break;
case RGBDeviceType.LedMatrix:
if (!Categories.Contains(DeviceCategory.Room))
Categories.Add(DeviceCategory.Room);
break;
}
}
internal void ApplyToEntity()
{
// Other properties are computed
@@ -439,13 +443,11 @@ namespace Artemis.Core
DeviceEntity.InputIdentifiers.Clear();
foreach (ArtemisDeviceInputIdentifier identifier in InputIdentifiers)
{
DeviceEntity.InputIdentifiers.Add(new DeviceInputIdentifierEntity
{
InputProvider = identifier.InputProvider,
Identifier = identifier.Identifier
});
}
DeviceEntity.InputMappings.Clear();
foreach (var (original, mapped) in InputMappings)
@@ -472,9 +474,9 @@ namespace Artemis.Core
if (!RgbDevice.ColorCorrections.Any())
RgbDevice.ColorCorrections.Add(new ScaleColorCorrection(this));
Categories.Clear();
foreach (int deviceEntityCategory in DeviceEntity.Categories)
foreach (int deviceEntityCategory in DeviceEntity.Categories)
Categories.Add((DeviceCategory) deviceEntityCategory);
if (!Categories.Any())
ApplyDefaultCategories();
@@ -532,12 +534,34 @@ namespace Artemis.Core
}
}
/// <summary>
/// Represents a device category
/// </summary>
public enum DeviceCategory
{
/// <summary>
/// A device used to light up (part of) the desk
/// </summary>
Desk,
/// <summary>
/// A device attached or embedded into the monitor
/// </summary>
Monitor,
/// <summary>
/// A device placed or embedded into the case
/// </summary>
Case,
/// <summary>
/// A device used to light up (part of) the room
/// </summary>
Room,
/// <summary>
/// A peripheral
/// </summary>
Peripherals
}
}
@@ -146,6 +146,58 @@ namespace Artemis.Core
else
Image = null;
}
internal static ArtemisLayout? GetDefaultLayout(ArtemisDevice device)
{
string layoutFolder = Path.Combine(Constants.ApplicationFolder, "DefaultLayouts\\Artemis");
if (device.DeviceType == RGBDeviceType.Keyboard)
{
// XL layout is defined by its programmable macro keys
if (device.Leds.Any(l => l.RgbLed.Id >= LedId.Keyboard_Programmable1 && l.RgbLed.Id <= LedId.Keyboard_Programmable32))
{
if (device.PhysicalLayout == KeyboardLayoutType.ANSI)
return new ArtemisLayout(layoutFolder + "\\Keyboard\\Artemis XL keyboard-ANSI.xml", LayoutSource.Default);
return new ArtemisLayout(layoutFolder + "\\Keyboard\\Artemis XL keyboard-ISO.xml", LayoutSource.Default);
}
// L layout is defined by its numpad
if (device.Leds.Any(l => l.RgbLed.Id >= LedId.Keyboard_NumLock && l.RgbLed.Id <= LedId.Keyboard_NumPeriodAndDelete))
{
if (device.PhysicalLayout == KeyboardLayoutType.ANSI)
return new ArtemisLayout(layoutFolder + "\\Keyboard\\Artemis L keyboard-ANSI.xml", LayoutSource.Default);
return new ArtemisLayout(layoutFolder + "\\Keyboard\\Artemis L keyboard-ISO.xml", LayoutSource.Default);
}
// No numpad will result in TKL
if (device.PhysicalLayout == KeyboardLayoutType.ANSI)
return new ArtemisLayout(layoutFolder + "\\Keyboard\\Artemis TKL keyboard-ANSI.xml", LayoutSource.Default);
return new ArtemisLayout(layoutFolder + "\\Keyboard\\Artemis TKL keyboard-ISO.xml", LayoutSource.Default);
}
// if (device.DeviceType == RGBDeviceType.Mouse)
// {
// if (device.Leds.Count == 1)
// {
// if (device.Leds.Any(l => l.RgbLed.Id == LedId.Logo))
// return new ArtemisLayout(layoutFolder + "\\Mouse\\1 LED mouse logo.xml", LayoutSource.Default);
// return new ArtemisLayout(layoutFolder + "\\Mouse\\1 LED mouse.xml", LayoutSource.Default);
// }
// if (device.Leds.Any(l => l.RgbLed.Id == LedId.Logo))
// return new ArtemisLayout(layoutFolder + "\\Mouse\\4 LED mouse logo.xml", LayoutSource.Default);
// return new ArtemisLayout(layoutFolder + "\\Mouse\\4 LED mouse.xml", LayoutSource.Default);
// }
if (device.DeviceType == RGBDeviceType.Headset)
{
if (device.Leds.Count == 1)
return new ArtemisLayout(layoutFolder + "\\Headset\\Artemis 1 LED headset.xml", LayoutSource.Default);
if (device.Leds.Count == 2)
return new ArtemisLayout(layoutFolder + "\\Headset\\Artemis 2 LED headset.xml", LayoutSource.Default);
return new ArtemisLayout(layoutFolder + "\\Headset\\Artemis 4 LED headset.xml", LayoutSource.Default);
}
return null;
}
}
/// <summary>