mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-12 17:48:31 +00:00
Added physical-layout to KeyboardDeviceInfo
This commit is contained in:
parent
07a6d8952c
commit
190f5df025
10
RGB.NET.Core/Devices/KeyboardLayoutType.cs
Normal file
10
RGB.NET.Core/Devices/KeyboardLayoutType.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
public enum KeyboardLayoutType
|
||||
{
|
||||
Unknown = 0,
|
||||
Ansi = 1,
|
||||
Iso = 2,
|
||||
Jis = 3
|
||||
}
|
||||
}
|
||||
@ -4,5 +4,12 @@
|
||||
/// Represents a keyboard-device
|
||||
/// </summary>
|
||||
public interface IKeyboard : IRGBDevice
|
||||
{ }
|
||||
{
|
||||
new IKeyboardDeviceInfo DeviceInfo { get; }
|
||||
}
|
||||
|
||||
public interface IKeyboardDeviceInfo : IRGBDeviceInfo
|
||||
{
|
||||
KeyboardLayoutType Layout { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ namespace RGB.NET.Devices.Asus
|
||||
case AsusDeviceType.KEYBOARD_RGB:
|
||||
case AsusDeviceType.NB_KB_RGB:
|
||||
case AsusDeviceType.NB_KB_4ZONE_RGB:
|
||||
rgbDevice = new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device, AsusPhysicalKeyboardLayout.Default));
|
||||
rgbDevice = new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device));
|
||||
break;
|
||||
|
||||
case AsusDeviceType.MOUSE_RGB:
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
// ReSharper disable UnusedMember.Global
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
namespace RGB.NET.Devices.Asus
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains list of available physical layouts for asus keyboards.
|
||||
/// </summary>
|
||||
public enum AsusPhysicalKeyboardLayout
|
||||
{
|
||||
Default
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,12 @@ namespace RGB.NET.Devices.Asus
|
||||
/// </summary>
|
||||
public class AsusKeyboardRGBDevice : AsusRGBDevice<AsusKeyboardRGBDeviceInfo>, IKeyboard
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@ -3,18 +3,15 @@ using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Asus
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Asus.AsusKeyboardRGBDevice" />.
|
||||
/// </summary>
|
||||
public class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo
|
||||
public class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the physical layout of the keyboard.
|
||||
/// </summary>
|
||||
public AsusPhysicalKeyboardLayout PhysicalLayout { get; }
|
||||
/// <inheritdoc />
|
||||
public KeyboardLayoutType Layout => KeyboardLayoutType.Unknown;
|
||||
|
||||
#endregion
|
||||
|
||||
@ -25,11 +22,9 @@ namespace RGB.NET.Devices.Asus
|
||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Asus.AsusKeyboardRGBDeviceInfo" />.
|
||||
/// </summary>
|
||||
/// <param name="device">The <see cref="IAuraSyncDevice"/> backing this RGB.NET device.</param>
|
||||
internal AsusKeyboardRGBDeviceInfo(IAuraSyncDevice device, AsusPhysicalKeyboardLayout layout)
|
||||
internal AsusKeyboardRGBDeviceInfo(IAuraSyncDevice device)
|
||||
: base(RGBDeviceType.Keyboard, device, device.Name)
|
||||
{
|
||||
this.PhysicalLayout = layout;
|
||||
}
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Asus
|
||||
/// <summary>
|
||||
/// Represents a Asus mainboard.
|
||||
/// </summary>
|
||||
public class AsusMainboardRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IKeyboard
|
||||
public class AsusMainboardRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IMainboard
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
|
||||
@ -9,6 +9,12 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
/// </summary>
|
||||
public class CoolerMasterKeyboardRGBDevice : CoolerMasterRGBDevice<CoolerMasterKeyboardRGBDeviceInfo>, IKeyboard
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@ -2,14 +2,16 @@
|
||||
|
||||
namespace RGB.NET.Devices.CoolerMaster
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.CoolerMaster.CoolerMasterKeyboardRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CoolerMasterKeyboardRGBDeviceInfo : CoolerMasterRGBDeviceInfo
|
||||
public class CoolerMasterKeyboardRGBDeviceInfo : CoolerMasterRGBDeviceInfo, IKeyboardDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <inheritdoc />
|
||||
public KeyboardLayoutType Layout { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="CoolerMasterPhysicalKeyboardLayout"/> of the <see cref="CoolerMasterKeyboardRGBDevice"/>.
|
||||
/// </summary>
|
||||
@ -29,6 +31,14 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
: base(RGBDeviceType.Keyboard, deviceIndex)
|
||||
{
|
||||
this.PhysicalLayout = physicalKeyboardLayout;
|
||||
this.Layout = physicalKeyboardLayout switch
|
||||
{
|
||||
CoolerMasterPhysicalKeyboardLayout.UNINIT => KeyboardLayoutType.Unknown,
|
||||
CoolerMasterPhysicalKeyboardLayout.US => KeyboardLayoutType.Ansi,
|
||||
CoolerMasterPhysicalKeyboardLayout.EU => KeyboardLayoutType.Iso,
|
||||
CoolerMasterPhysicalKeyboardLayout.JP => KeyboardLayoutType.Jis,
|
||||
_ => KeyboardLayoutType.Unknown
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -15,6 +15,12 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// </summary>
|
||||
public class CorsairKeyboardRGBDevice : CorsairRGBDevice<CorsairKeyboardRGBDeviceInfo>, IKeyboard
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@ -7,14 +7,16 @@ using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairKeyboardRGBDevice" />.
|
||||
/// </summary>
|
||||
public class CorsairKeyboardRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
public class CorsairKeyboardRGBDeviceInfo : CorsairRGBDeviceInfo, IKeyboardDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <inheritdoc />
|
||||
public KeyboardLayoutType Layout { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the physical layout of the keyboard.
|
||||
/// </summary>
|
||||
@ -41,6 +43,15 @@ namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout;
|
||||
this.LogicalLayout = (CorsairLogicalKeyboardLayout)nativeInfo.logicalLayout;
|
||||
this.Layout = PhysicalLayout switch
|
||||
{
|
||||
CorsairPhysicalKeyboardLayout.US => KeyboardLayoutType.Ansi,
|
||||
CorsairPhysicalKeyboardLayout.UK => KeyboardLayoutType.Iso,
|
||||
CorsairPhysicalKeyboardLayout.BR => KeyboardLayoutType.Unknown,
|
||||
CorsairPhysicalKeyboardLayout.JP => KeyboardLayoutType.Jis,
|
||||
CorsairPhysicalKeyboardLayout.KR => KeyboardLayoutType.Unknown,
|
||||
_ => KeyboardLayoutType.Unknown
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -12,6 +12,12 @@ namespace RGB.NET.Devices.Razer
|
||||
/// </summary>
|
||||
public class RazerKeyboardRGBDevice : RazerRGBDevice<RazerKeyboardRGBDeviceInfo>, IKeyboard
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@ -6,12 +6,18 @@ using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Razer
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Razer.RazerKeyboardRGBDevice" />.
|
||||
/// </summary>
|
||||
public class RazerKeyboardRGBDeviceInfo : RazerRGBDeviceInfo
|
||||
public class RazerKeyboardRGBDeviceInfo : RazerRGBDeviceInfo, IKeyboardDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <inheritdoc />
|
||||
public KeyboardLayoutType Layout => KeyboardLayoutType.Unknown;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Wooting.Enum;
|
||||
using RGB.NET.Devices.Wooting.Generic;
|
||||
|
||||
namespace RGB.NET.Devices.Wooting.Keyboard
|
||||
@ -11,6 +12,12 @@ namespace RGB.NET.Devices.Wooting.Keyboard
|
||||
/// </summary>
|
||||
public class WootingKeyboardRGBDevice : WootingRGBDevice<WootingKeyboardRGBDeviceInfo>, IKeyboard
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -29,14 +36,15 @@ namespace RGB.NET.Devices.Wooting.Keyboard
|
||||
/// <inheritdoc />
|
||||
protected override void InitializeLayout()
|
||||
{
|
||||
Dictionary<LedId, (int row, int column)> mapping = WootingKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout];
|
||||
//TODO DarthAffe 13.02.2021: Check how the mapping can work without knowing the physical layout
|
||||
Dictionary<LedId, (int row, int column)> mapping = WootingKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][WootingPhysicalKeyboardLayout.US];
|
||||
|
||||
foreach (KeyValuePair<LedId, (int row, int column)> led in mapping)
|
||||
AddLed(led.Key, new Point(led.Value.column * 19, led.Value.row * 19), new Size(19, 19));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override object GetLedCustomData(LedId ledId) => WootingKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout][ledId];
|
||||
protected override object GetLedCustomData(LedId ledId) => WootingKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][WootingPhysicalKeyboardLayout.US][ledId];
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue?.SetData(ledsToUpdate.Where(x => x.Color.A > 0));
|
||||
|
||||
@ -4,18 +4,15 @@ using RGB.NET.Devices.Wooting.Generic;
|
||||
|
||||
namespace RGB.NET.Devices.Wooting.Keyboard
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Wooting.Keyboard.WootingKeyboardRGBDevice" />.
|
||||
/// </summary>
|
||||
public class WootingKeyboardRGBDeviceInfo : WootingRGBDeviceInfo
|
||||
public class WootingKeyboardRGBDeviceInfo : WootingRGBDeviceInfo, IKeyboardDeviceInfo
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="WootingPhysicalKeyboardLayout"/> of the <see cref="WootingKeyboardRGBDevice"/>.
|
||||
/// </summary>
|
||||
public WootingPhysicalKeyboardLayout PhysicalLayout { get; }
|
||||
/// <inheritdoc />
|
||||
public KeyboardLayoutType Layout => KeyboardLayoutType.Unknown;
|
||||
|
||||
#endregion
|
||||
|
||||
@ -27,11 +24,9 @@ namespace RGB.NET.Devices.Wooting.Keyboard
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.Wooting.WootingKeyboardRGBDevice" />.</param>
|
||||
/// <param name="physicalKeyboardLayout">The <see cref="T:RGB.NET.Devices.Wooting.WootingPhysicalKeyboardLayout" /> of the <see cref="T:RGB.NET.Devices.Wooting.WootingKeyboardRGBDevice" />.</param>
|
||||
internal WootingKeyboardRGBDeviceInfo(WootingDevicesIndexes deviceIndex, WootingPhysicalKeyboardLayout physicalKeyboardLayout)
|
||||
internal WootingKeyboardRGBDeviceInfo(WootingDevicesIndexes deviceIndex)
|
||||
: base(RGBDeviceType.Keyboard, deviceIndex)
|
||||
{
|
||||
this.PhysicalLayout = physicalKeyboardLayout;
|
||||
}
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -90,9 +90,8 @@ namespace RGB.NET.Devices.Wooting
|
||||
_WootingDeviceInfo nativeDeviceInfo = (_WootingDeviceInfo)Marshal.PtrToStructure(_WootingSDK.GetDeviceInfo(), typeof(_WootingDeviceInfo))!;
|
||||
IWootingRGBDevice device = nativeDeviceInfo.Model switch
|
||||
{
|
||||
// TODO: Find an accurate way to determine physical and logical layouts
|
||||
"Wooting two" => new WootingKeyboardRGBDevice(new WootingKeyboardRGBDeviceInfo(WootingDevicesIndexes.WootingTwo, WootingPhysicalKeyboardLayout.US)),
|
||||
"Wooting one" => new WootingKeyboardRGBDevice(new WootingKeyboardRGBDeviceInfo(WootingDevicesIndexes.WootingOne, WootingPhysicalKeyboardLayout.US)),
|
||||
"Wooting two" => new WootingKeyboardRGBDevice(new WootingKeyboardRGBDeviceInfo(WootingDevicesIndexes.WootingTwo)),
|
||||
"Wooting one" => new WootingKeyboardRGBDevice(new WootingKeyboardRGBDeviceInfo(WootingDevicesIndexes.WootingOne)),
|
||||
_ => throw new RGBDeviceException("No supported Wooting keyboard connected")
|
||||
};
|
||||
|
||||
@ -113,7 +112,7 @@ namespace RGB.NET.Devices.Wooting
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user