diff --git a/RGB.NET.Core/Devices/KeyboardLayoutType.cs b/RGB.NET.Core/Devices/KeyboardLayoutType.cs new file mode 100644 index 0000000..f3c38b2 --- /dev/null +++ b/RGB.NET.Core/Devices/KeyboardLayoutType.cs @@ -0,0 +1,10 @@ +namespace RGB.NET.Core +{ + public enum KeyboardLayoutType + { + Unknown = 0, + Ansi = 1, + Iso = 2, + Jis = 3 + } +} diff --git a/RGB.NET.Core/Devices/TypeInterfaces/IKeyboard.cs b/RGB.NET.Core/Devices/TypeInterfaces/IKeyboard.cs index 7e32e96..dd28694 100644 --- a/RGB.NET.Core/Devices/TypeInterfaces/IKeyboard.cs +++ b/RGB.NET.Core/Devices/TypeInterfaces/IKeyboard.cs @@ -4,5 +4,12 @@ /// Represents a keyboard-device /// public interface IKeyboard : IRGBDevice - { } + { + new IKeyboardDeviceInfo DeviceInfo { get; } + } + + public interface IKeyboardDeviceInfo : IRGBDeviceInfo + { + KeyboardLayoutType Layout { get; } + } } diff --git a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs index 7372b20..00f22f4 100644 --- a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs +++ b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs @@ -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: diff --git a/RGB.NET.Devices.Asus/Enum/AsusPhysicalKeyboardLayout.cs b/RGB.NET.Devices.Asus/Enum/AsusPhysicalKeyboardLayout.cs deleted file mode 100644 index fcc1082..0000000 --- a/RGB.NET.Devices.Asus/Enum/AsusPhysicalKeyboardLayout.cs +++ /dev/null @@ -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 -{ - /// - /// Contains list of available physical layouts for asus keyboards. - /// - public enum AsusPhysicalKeyboardLayout - { - Default - } -} diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs index 9a00a24..b10eb60 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs @@ -11,6 +11,12 @@ namespace RGB.NET.Devices.Asus /// public class AsusKeyboardRGBDevice : AsusRGBDevice, IKeyboard { + #region Properties & Fields + + IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo; + + #endregion + #region Constructors /// diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs index 122c0a9..a74ab1b 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs @@ -3,18 +3,15 @@ using RGB.NET.Core; namespace RGB.NET.Devices.Asus { - /// /// /// Represents a generic information for a . /// - public class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo + public class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDeviceInfo { #region Properties & Fields - /// - /// Gets the physical layout of the keyboard. - /// - public AsusPhysicalKeyboardLayout PhysicalLayout { get; } + /// + public KeyboardLayoutType Layout => KeyboardLayoutType.Unknown; #endregion @@ -25,11 +22,9 @@ namespace RGB.NET.Devices.Asus /// Internal constructor of managed . /// /// The backing this RGB.NET device. - internal AsusKeyboardRGBDeviceInfo(IAuraSyncDevice device, AsusPhysicalKeyboardLayout layout) + internal AsusKeyboardRGBDeviceInfo(IAuraSyncDevice device) : base(RGBDeviceType.Keyboard, device, device.Name) - { - this.PhysicalLayout = layout; - } + { } #endregion } diff --git a/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs b/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs index 71ee547..e4b25a5 100644 --- a/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Asus /// /// Represents a Asus mainboard. /// - public class AsusMainboardRGBDevice : AsusRGBDevice, IKeyboard + public class AsusMainboardRGBDevice : AsusRGBDevice, IMainboard { #region Constructors diff --git a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs index cf67d76..29df3be 100644 --- a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs @@ -9,6 +9,12 @@ namespace RGB.NET.Devices.CoolerMaster /// public class CoolerMasterKeyboardRGBDevice : CoolerMasterRGBDevice, IKeyboard { + #region Properties & Fields + + IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo; + + #endregion + #region Constructors /// diff --git a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDeviceInfo.cs index baa3c1b..4275369 100644 --- a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDeviceInfo.cs @@ -2,14 +2,16 @@ namespace RGB.NET.Devices.CoolerMaster { - /// /// /// Represents a generic information for a . /// - public class CoolerMasterKeyboardRGBDeviceInfo : CoolerMasterRGBDeviceInfo + public class CoolerMasterKeyboardRGBDeviceInfo : CoolerMasterRGBDeviceInfo, IKeyboardDeviceInfo { #region Properties & Fields + /// + public KeyboardLayoutType Layout { get; } + /// /// Gets the of the . /// @@ -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 diff --git a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs index 60febaa..1d950dd 100644 --- a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs @@ -15,6 +15,12 @@ namespace RGB.NET.Devices.Corsair /// public class CorsairKeyboardRGBDevice : CorsairRGBDevice, IKeyboard { + #region Properties & Fields + + IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo; + + #endregion + #region Constructors /// diff --git a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDeviceInfo.cs index fe6d699..2d60d65 100644 --- a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDeviceInfo.cs @@ -7,14 +7,16 @@ using RGB.NET.Devices.Corsair.Native; namespace RGB.NET.Devices.Corsair { - /// /// /// Represents a generic information for a . /// - public class CorsairKeyboardRGBDeviceInfo : CorsairRGBDeviceInfo + public class CorsairKeyboardRGBDeviceInfo : CorsairRGBDeviceInfo, IKeyboardDeviceInfo { #region Properties & Fields + /// + public KeyboardLayoutType Layout { get; } + /// /// Gets the physical layout of the keyboard. /// @@ -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 diff --git a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDevice.cs b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDevice.cs index 2ca30a0..f55ea9a 100644 --- a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDevice.cs @@ -12,6 +12,12 @@ namespace RGB.NET.Devices.Razer /// public class RazerKeyboardRGBDevice : RazerRGBDevice, IKeyboard { + #region Properties & Fields + + IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo; + + #endregion + #region Constructors /// diff --git a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDeviceInfo.cs index b65676a..f37a6a4 100644 --- a/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Razer/Keyboard/RazerKeyboardRGBDeviceInfo.cs @@ -6,12 +6,18 @@ using RGB.NET.Core; namespace RGB.NET.Devices.Razer { - /// /// /// Represents a generic information for a . /// - public class RazerKeyboardRGBDeviceInfo : RazerRGBDeviceInfo + public class RazerKeyboardRGBDeviceInfo : RazerRGBDeviceInfo, IKeyboardDeviceInfo { + #region Properties & Fields + + /// + public KeyboardLayoutType Layout => KeyboardLayoutType.Unknown; + + #endregion + #region Constructors /// diff --git a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs b/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs index a3e8e0c..7994145 100644 --- a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs @@ -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 /// public class WootingKeyboardRGBDevice : WootingRGBDevice, IKeyboard { + #region Properties & Fields + + IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo; + + #endregion + #region Constructors /// @@ -29,14 +36,15 @@ namespace RGB.NET.Devices.Wooting.Keyboard /// protected override void InitializeLayout() { - Dictionary mapping = WootingKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout]; + //TODO DarthAffe 13.02.2021: Check how the mapping can work without knowing the physical layout + Dictionary mapping = WootingKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][WootingPhysicalKeyboardLayout.US]; foreach (KeyValuePair led in mapping) AddLed(led.Key, new Point(led.Value.column * 19, led.Value.row * 19), new Size(19, 19)); } /// - 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]; /// protected override void UpdateLeds(IEnumerable ledsToUpdate) => UpdateQueue?.SetData(ledsToUpdate.Where(x => x.Color.A > 0)); diff --git a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDeviceInfo.cs index 7d53a92..69368be 100644 --- a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDeviceInfo.cs @@ -4,18 +4,15 @@ using RGB.NET.Devices.Wooting.Generic; namespace RGB.NET.Devices.Wooting.Keyboard { - /// /// /// Represents a generic information for a . /// - public class WootingKeyboardRGBDeviceInfo : WootingRGBDeviceInfo + public class WootingKeyboardRGBDeviceInfo : WootingRGBDeviceInfo, IKeyboardDeviceInfo { #region Properties & Fields - /// - /// Gets the of the . - /// - public WootingPhysicalKeyboardLayout PhysicalLayout { get; } + /// + public KeyboardLayoutType Layout => KeyboardLayoutType.Unknown; #endregion @@ -27,11 +24,9 @@ namespace RGB.NET.Devices.Wooting.Keyboard /// /// The index of the . /// The of the . - internal WootingKeyboardRGBDeviceInfo(WootingDevicesIndexes deviceIndex, WootingPhysicalKeyboardLayout physicalKeyboardLayout) + internal WootingKeyboardRGBDeviceInfo(WootingDevicesIndexes deviceIndex) : base(RGBDeviceType.Keyboard, deviceIndex) - { - this.PhysicalLayout = physicalKeyboardLayout; - } + { } #endregion } diff --git a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs index 9f779c2..e0dc3e5 100644 --- a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs +++ b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs @@ -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; } - + /// public void Dispose() {