mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Input - Added basic input stuff
This commit is contained in:
1 parent
0c8e200f53
commit
810db36191
16 files changed
+962
-6
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Artemis.Core.DeviceProviders;
|
||||
@@ -22,6 +23,7 @@ namespace Artemis.Core
|
||||
RgbDevice = rgbDevice;
|
||||
DeviceProvider = deviceProvider;
|
||||
Surface = surface;
|
||||
InputIdentifiers = new List<ArtemisDeviceInputIdentifier>();
|
||||
DeviceEntity = new DeviceEntity();
|
||||
_leds = rgbDevice.Select(l => new ArtemisLed(l, this)).ToList().AsReadOnly();
|
||||
|
||||
@@ -38,6 +40,7 @@ namespace Artemis.Core
|
||||
RgbDevice = rgbDevice;
|
||||
DeviceProvider = deviceProvider;
|
||||
Surface = surface;
|
||||
InputIdentifiers = new List<ArtemisDeviceInputIdentifier>();
|
||||
DeviceEntity = deviceEntity;
|
||||
_leds = rgbDevice.Select(l => new ArtemisLed(l, this)).ToList().AsReadOnly();
|
||||
}
|
||||
@@ -84,6 +87,11 @@ namespace Artemis.Core
|
||||
private set => SetAndNotify(ref _leds, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of input identifiers associated with this device
|
||||
/// </summary>
|
||||
public List<ArtemisDeviceInputIdentifier> InputIdentifiers { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the X-position of the device
|
||||
/// </summary>
|
||||
@@ -174,6 +182,16 @@ namespace Artemis.Core
|
||||
{
|
||||
// Other properties are computed
|
||||
DeviceEntity.DeviceIdentifier = RgbDevice.GetDeviceIdentifier();
|
||||
|
||||
DeviceEntity.InputIdentifier.Clear();
|
||||
foreach (ArtemisDeviceInputIdentifier identifier in InputIdentifiers)
|
||||
{
|
||||
DeviceEntity.InputIdentifier.Add(new DeviceInputIdentifierEntity
|
||||
{
|
||||
InputProvider = identifier.InputProvider,
|
||||
Identifier = identifier.Identifier
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
internal void ApplyToRgbDevice()
|
||||
@@ -186,6 +204,10 @@ namespace Artemis.Core
|
||||
RgbDevice.Location = new Point(1, 1);
|
||||
RgbDevice.Location = new Point(DeviceEntity.X, DeviceEntity.Y);
|
||||
|
||||
InputIdentifiers.Clear();
|
||||
foreach (DeviceInputIdentifierEntity identifierEntity in DeviceEntity.InputIdentifier)
|
||||
InputIdentifiers.Add(new ArtemisDeviceInputIdentifier(identifierEntity.InputProvider, identifierEntity.Identifier));
|
||||
|
||||
CalculateRenderProperties();
|
||||
OnDeviceUpdated();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
using Artemis.Core.Services;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a device input identifier used by a specific <see cref="Services.InputProvider" /> to identify the device
|
||||
/// </summary>
|
||||
public class ArtemisDeviceInputIdentifier
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="ArtemisDeviceInputIdentifier" /> class
|
||||
/// </summary>
|
||||
/// <param name="inputProvider">The full type and namespace of the <see cref="Services.InputProvider" /> this identifier is used by</param>
|
||||
/// <param name="identifier">A value used to identify the device</param>
|
||||
public ArtemisDeviceInputIdentifier(string inputProvider, object identifier)
|
||||
{
|
||||
InputProvider = inputProvider;
|
||||
Identifier = identifier;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the full type and namespace of the <see cref="Services.InputProvider" /> this identifier is used by
|
||||
/// </summary>
|
||||
public string InputProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value used to identify the device
|
||||
/// </summary>
|
||||
public object Identifier { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user