diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index 72b2bc4d1..5f9a94ff0 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -311,7 +311,6 @@ - diff --git a/Artemis/Artemis/DeviceProviders/Logitech/G810.cs b/Artemis/Artemis/DeviceProviders/Logitech/G810.cs index 1db03fd91..73f41be21 100644 --- a/Artemis/Artemis/DeviceProviders/Logitech/G810.cs +++ b/Artemis/Artemis/DeviceProviders/Logitech/G810.cs @@ -6,6 +6,7 @@ using Artemis.DAL; using Artemis.DeviceProviders.Logitech.Utilities; using Artemis.Properties; using Artemis.Settings; +using LedCSharp; namespace Artemis.DeviceProviders.Logitech { @@ -54,17 +55,17 @@ namespace Artemis.DeviceProviders.Logitech } // Color G-logo, lets also try some other values to see what happens - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_LOGO, 0, 0); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_BADGE, 0, 0); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_1, 0, 0); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_2, 0, 0); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_3, 0, 0); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_4, 0, 0); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_5, 0, 0); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_6, 0, 0); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_7, 0, 0); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_8, 0, 0); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_9, 0, 0); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_LOGO, 0, 0); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_BADGE, 0, 0); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_1, 0, 0); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_2, 0, 0); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_3, 0, 0); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_4, 0, 0); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_5, 0, 0); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_6, 0, 0); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_7, 0, 0); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_8, 0, 0); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_9, 0, 0); } } diff --git a/Artemis/Artemis/DeviceProviders/Logitech/G910.cs b/Artemis/Artemis/DeviceProviders/Logitech/G910.cs index 26f8ba6a3..177ebdb42 100644 --- a/Artemis/Artemis/DeviceProviders/Logitech/G910.cs +++ b/Artemis/Artemis/DeviceProviders/Logitech/G910.cs @@ -7,6 +7,7 @@ using Artemis.DAL; using Artemis.DeviceProviders.Logitech.Utilities; using Artemis.Properties; using Artemis.Settings; +using LedCSharp; namespace Artemis.DeviceProviders.Logitech { @@ -75,21 +76,21 @@ namespace Artemis.DeviceProviders.Logitech } // Color the extra keys on the left side of the keyboard - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_LOGO, 0, 1); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_1, 0, 2); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_2, 0, 3); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_3, 0, 4); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_4, 0, 5); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_5, 0, 6); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_LOGO, 0, 1); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_1, 0, 2); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_2, 0, 3); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_3, 0, 4); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_4, 0, 5); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_5, 0, 6); // Color the extra keys on the top of the keyboard - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_6, 3, 0); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_7, 4, 0); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_8, 5, 0); - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_9, 6, 0); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_6, 3, 0); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_7, 4, 0); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_8, 5, 0); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_9, 6, 0); // Color the G-badge - SetLogitechColorFromCoordinates(resized, KeyboardNames.G_BADGE, 5, 6); + SetLogitechColorFromCoordinates(resized, keyboardNames.G_BADGE, 5, 6); } } diff --git a/Artemis/Artemis/DeviceProviders/Logitech/LogitechKeyboard.cs b/Artemis/Artemis/DeviceProviders/Logitech/LogitechKeyboard.cs index 72ffe9926..e9445dd36 100644 --- a/Artemis/Artemis/DeviceProviders/Logitech/LogitechKeyboard.cs +++ b/Artemis/Artemis/DeviceProviders/Logitech/LogitechKeyboard.cs @@ -1,9 +1,8 @@ using System; using System.Drawing; using System.Threading; -using Artemis.DeviceProviders.Logitech.Utilities; using Artemis.Utilities.DataReaders; -using Microsoft.Win32; +using LedCSharp; namespace Artemis.DeviceProviders.Logitech { @@ -13,22 +12,20 @@ namespace Artemis.DeviceProviders.Logitech { // Just to be sure, restore the Logitech DLL registry key DllManager.RestoreLogitechDll(); - + int majorNum = 0, minorNum = 0, buildNum = 0; LogitechGSDK.LogiLedInit(); LogitechGSDK.LogiLedGetSdkVersion(ref majorNum, ref minorNum, ref buildNum); LogitechGSDK.LogiLedShutdown(); - // Turn it into one long number... - var version = int.Parse($"{majorNum}{minorNum}{buildNum}"); CantEnableText = "Couldn't connect to your Logitech keyboard.\n" + "Please check your cables and updating the Logitech Gaming Software\n" + $"A minimum version of 8.81.15 is required (detected {majorNum}.{minorNum}.{buildNum}).\n\n" + "If the detected version differs from the version LGS is reporting, reinstall LGS or see the FAQ.\n\n" + "If needed, you can select a different keyboard in Artemis under settings."; - return version >= 88115; + return majorNum >= 9; } public override void Enable() @@ -48,14 +45,14 @@ namespace Artemis.DeviceProviders.Logitech LogitechGSDK.LogiLedShutdown(); } - protected void SetLogitechColorFromCoordinates(Bitmap bitmap, KeyboardNames key, int x, int y) + protected void SetLogitechColorFromCoordinates(Bitmap bitmap, keyboardNames key, int x, int y) { var color = bitmap.GetPixel(x, y); - var rPer = (int)Math.Round(color.R / 2.55); - var gPer = (int)Math.Round(color.G / 2.55); - var bPer = (int)Math.Round(color.B / 2.55); + var rPer = (int) Math.Round(color.R / 2.55); + var gPer = (int) Math.Round(color.G / 2.55); + var bPer = (int) Math.Round(color.B / 2.55); LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(key, rPer, gPer, bPer); } } -} +} \ No newline at end of file diff --git a/Artemis/Artemis/DeviceProviders/Logitech/Utilities/LogitechGSDK.cs b/Artemis/Artemis/DeviceProviders/Logitech/Utilities/LogitechGSDK.cs deleted file mode 100644 index a5a81a558..000000000 --- a/Artemis/Artemis/DeviceProviders/Logitech/Utilities/LogitechGSDK.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System.Runtime.InteropServices; -using System.Text; - -namespace Artemis.DeviceProviders.Logitech.Utilities -{ - public class LogitechGSDK - { - //LED SDK - private const int LOGI_DEVICETYPE_MONOCHROME_ORD = 0; - private const int LOGI_DEVICETYPE_RGB_ORD = 1; - private const int LOGI_DEVICETYPE_PERKEY_RGB_ORD = 2; - - public const int LOGI_DEVICETYPE_MONOCHROME = 1 << LOGI_DEVICETYPE_MONOCHROME_ORD; - public const int LOGI_DEVICETYPE_RGB = 1 << LOGI_DEVICETYPE_RGB_ORD; - public const int LOGI_DEVICETYPE_PERKEY_RGB = 1 << LOGI_DEVICETYPE_PERKEY_RGB_ORD; - public const int LOGI_LED_BITMAP_WIDTH = 21; - public const int LOGI_LED_BITMAP_HEIGHT = 6; - public const int LOGI_LED_BITMAP_BYTES_PER_KEY = 4; - - public const int LOGI_LED_BITMAP_SIZE = - LOGI_LED_BITMAP_WIDTH*LOGI_LED_BITMAP_HEIGHT*LOGI_LED_BITMAP_BYTES_PER_KEY; - - public const int LOGI_LED_DURATION_INFINITE = 0; - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedInit(); - - //Config option functions - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedGetConfigOptionNumber([MarshalAs(UnmanagedType.LPWStr)] string configPath, - ref double defaultNumber); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedGetConfigOptionBool([MarshalAs(UnmanagedType.LPWStr)] string configPath, - ref bool defaultRed); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedGetConfigOptionColor([MarshalAs(UnmanagedType.LPWStr)] string configPath, - ref int defaultRed, ref int defaultGreen, ref int defaultBlue); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedGetConfigOptionKeyInput([MarshalAs(UnmanagedType.LPWStr)] string configPath, - StringBuilder buffer, int bufsize); - - ///////////////////// - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedSetTargetDevice(int targetDevice); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedGetSdkVersion(ref int majorNum, ref int minorNum, ref int buildNum); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedSaveCurrentLighting(); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedSetLighting(int redPercentage, int greenPercentage, int bluePercentage); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedRestoreLighting(); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedFlashLighting(int redPercentage, int greenPercentage, int bluePercentage, - int milliSecondsDuration, int milliSecondsInterval); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedPulseLighting(int redPercentage, int greenPercentage, int bluePercentage, - int milliSecondsDuration, int milliSecondsInterval); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedStopEffects(); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedExcludeKeysFromBitmap(KeyboardNames[] keyList, int listCount); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedSetLightingFromBitmap(byte[] bitmap); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedSetLightingForKeyWithScanCode(int keyCode, int redPercentage, - int greenPercentage, int bluePercentage); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedSetLightingForKeyWithHidCode(int keyCode, int redPercentage, - int greenPercentage, int bluePercentage); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedSetLightingForKeyWithQuartzCode(int keyCode, int redPercentage, - int greenPercentage, int bluePercentage); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedSetLightingForKeyWithKeyName(KeyboardNames keyCode, int redPercentage, - int greenPercentage, int bluePercentage); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedSaveLightingForKey(KeyboardNames keyName); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedRestoreLightingForKey(KeyboardNames keyName); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedFlashSingleKey(KeyboardNames keyName, int redPercentage, int greenPercentage, - int bluePercentage, int msDuration, int msInterval); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedPulseSingleKey(KeyboardNames keyName, int startRedPercentage, - int startGreenPercentage, int startBluePercentage, int finishRedPercentage, int finishGreenPercentage, - int finishBluePercentage, int msDuration, bool isInfinite); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern bool LogiLedStopEffectsOnKey(KeyboardNames keyName); - - [DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)] - public static extern void LogiLedShutdown(); - } -} \ No newline at end of file diff --git a/Artemis/Artemis/LogitechLedEnginesWrapper.dll b/Artemis/Artemis/LogitechLedEnginesWrapper.dll index fb707e78a..71540b51a 100644 Binary files a/Artemis/Artemis/LogitechLedEnginesWrapper.dll and b/Artemis/Artemis/LogitechLedEnginesWrapper.dll differ