mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Started work on Corsair mouse support
This commit is contained in:
parent
a9373012a8
commit
3a18ce4a5a
@ -278,22 +278,23 @@
|
||||
</Compile>
|
||||
<Compile Include="ArtemisBootstrapper.cs" />
|
||||
<Compile Include="DAL\ProfileProvider.cs" />
|
||||
<Compile Include="DeviceProviders\Corsair\CorsairMice.cs" />
|
||||
<Compile Include="DeviceProviders\DeviceProvider.cs" />
|
||||
<Compile Include="Events\ActiveKeyboardChanged.cs" />
|
||||
<Compile Include="Events\ToggleEnabled.cs" />
|
||||
<Compile Include="Events\ActiveEffectChanged.cs" />
|
||||
<Compile Include="Events\ChangeBitmap.cs" />
|
||||
<Compile Include="InjectionFactories\IProfileEditorViewModelFactory.cs" />
|
||||
<Compile Include="ItemBehaviours\BindableSelectedItemBehavior.cs" />
|
||||
<Compile Include="KeyboardProviders\Corsair\CorsairRGB.cs" />
|
||||
<Compile Include="KeyboardProviders\KeyboardProvider.cs" />
|
||||
<Compile Include="KeyboardProviders\KeyboardRegion.cs" />
|
||||
<Compile Include="KeyboardProviders\Logitech\Orion.cs" />
|
||||
<Compile Include="KeyboardProviders\Logitech\Utilities\KeyboardNames.cs" />
|
||||
<Compile Include="KeyboardProviders\Logitech\Utilities\KeyMap.cs" />
|
||||
<Compile Include="KeyboardProviders\Logitech\Utilities\LogitechGSDK.cs" />
|
||||
<Compile Include="KeyboardProviders\Logitech\Utilities\OrionUtilities.cs" />
|
||||
<Compile Include="KeyboardProviders\Razer\BlackWidow.cs" />
|
||||
<Compile Include="KeyboardProviders\Razer\Utilities\RazerUtilities.cs" />
|
||||
<Compile Include="DeviceProviders\Corsair\CorsairRGB.cs" />
|
||||
<Compile Include="DeviceProviders\KeyboardProvider.cs" />
|
||||
<Compile Include="DeviceProviders\Logitech\Orion.cs" />
|
||||
<Compile Include="DeviceProviders\Logitech\Utilities\KeyboardNames.cs" />
|
||||
<Compile Include="DeviceProviders\Logitech\Utilities\KeyMap.cs" />
|
||||
<Compile Include="DeviceProviders\Logitech\Utilities\LogitechGSDK.cs" />
|
||||
<Compile Include="DeviceProviders\Logitech\Utilities\OrionUtilities.cs" />
|
||||
<Compile Include="DeviceProviders\Razer\BlackWidow.cs" />
|
||||
<Compile Include="DeviceProviders\Razer\Utilities\RazerUtilities.cs" />
|
||||
<Compile Include="Managers\EffectManager.cs" />
|
||||
<Compile Include="Managers\KeyboardManager.cs" />
|
||||
<Compile Include="Managers\LoopManager.cs" />
|
||||
|
||||
@ -4,7 +4,7 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Serialization;
|
||||
using Artemis.KeyboardProviders;
|
||||
using Artemis.DeviceProviders;
|
||||
using Artemis.Models;
|
||||
using Artemis.Models.Profiles;
|
||||
|
||||
|
||||
74
Artemis/Artemis/DeviceProviders/Corsair/CorsairMice.cs
Normal file
74
Artemis/Artemis/DeviceProviders/Corsair/CorsairMice.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using System.Threading;
|
||||
using System.Windows.Media;
|
||||
using CUE.NET;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
using CUE.NET.Devices.Mouse;
|
||||
using CUE.NET.Exceptions;
|
||||
|
||||
namespace Artemis.DeviceProviders.Corsair
|
||||
{
|
||||
internal class CorsairMice : DeviceProvider
|
||||
{
|
||||
private readonly CorsairRGB _corsairRgb;
|
||||
private CorsairMouse _mouse;
|
||||
|
||||
public CorsairMice(CorsairRGB corsairRgb)
|
||||
{
|
||||
_corsairRgb = corsairRgb;
|
||||
UpdateCanUse();
|
||||
}
|
||||
|
||||
private void UpdateCanUse()
|
||||
{
|
||||
if (!CanInitializeSdk())
|
||||
{
|
||||
CanUse = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (CueSDK.ProtocolDetails == null)
|
||||
CueSDK.Initialize(true);
|
||||
|
||||
_mouse = CueSDK.MouseSDK;
|
||||
|
||||
}
|
||||
|
||||
private static bool CanInitializeSdk()
|
||||
{
|
||||
// Try for about 10 seconds, in case CUE isn't started yet
|
||||
var tries = 0;
|
||||
while (tries < 9)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (CueSDK.ProtocolDetails == null)
|
||||
CueSDK.Initialize();
|
||||
}
|
||||
catch (CUEException e)
|
||||
{
|
||||
if (e.Error == CorsairError.ServerNotFound)
|
||||
{
|
||||
tries++;
|
||||
Thread.Sleep(1000);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (WrapperException)
|
||||
{
|
||||
CueSDK.Reinitialize();
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void UpdateDevice(Brush brush)
|
||||
{
|
||||
if (!CanUse)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9,7 +9,7 @@ using CUE.NET.Devices.Generic.Enums;
|
||||
using CUE.NET.Devices.Keyboard;
|
||||
using CUE.NET.Exceptions;
|
||||
|
||||
namespace Artemis.KeyboardProviders.Corsair
|
||||
namespace Artemis.DeviceProviders.Corsair
|
||||
{
|
||||
public class CorsairRGB : KeyboardProvider
|
||||
{
|
||||
30
Artemis/Artemis/DeviceProviders/DeviceProvider.cs
Normal file
30
Artemis/Artemis/DeviceProviders/DeviceProvider.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Artemis.DeviceProviders
|
||||
{
|
||||
public abstract class DeviceProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the device type
|
||||
/// </summary>
|
||||
public DeviceType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether or not the device can be updated
|
||||
/// </summary>
|
||||
public bool CanUse { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Updates a non-keyboard to take the colours of the provided brush
|
||||
/// </summary>
|
||||
/// <param name="brush"></param>
|
||||
public abstract void UpdateDevice(Brush brush);
|
||||
}
|
||||
|
||||
public enum DeviceType
|
||||
{
|
||||
Keyboard,
|
||||
Mouse,
|
||||
Headset
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,10 @@
|
||||
using System.Drawing;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows;
|
||||
using Brush = System.Windows.Media.Brush;
|
||||
using Size = System.Windows.Size;
|
||||
|
||||
namespace Artemis.KeyboardProviders
|
||||
namespace Artemis.DeviceProviders
|
||||
{
|
||||
public abstract class KeyboardProvider : DeviceProvider
|
||||
{
|
||||
@ -37,18 +39,11 @@ namespace Artemis.KeyboardProviders
|
||||
public Bitmap KeyboardBitmap(int scale) => new Bitmap(Width*scale, Height*scale);
|
||||
|
||||
public Rect KeyboardRectangle(int scale) => new Rect(new Size(Width*scale, Height*scale));
|
||||
}
|
||||
|
||||
public class DeviceProvider
|
||||
{
|
||||
public DeviceType Type { get; set; }
|
||||
}
|
||||
|
||||
public enum DeviceType
|
||||
{
|
||||
Keyboard,
|
||||
Mouse,
|
||||
Headset
|
||||
public override void UpdateDevice(Brush brush)
|
||||
{
|
||||
throw new NotImplementedException("KeyboardProvider doesn't implement UpdateDevice, use DrawBitmap instead.");
|
||||
}
|
||||
}
|
||||
|
||||
public struct PreviewSettings
|
||||
@ -1,13 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using Artemis.KeyboardProviders.Logitech.Utilities;
|
||||
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using Point = System.Drawing.Point;
|
||||
|
||||
namespace Artemis.KeyboardProviders.Logitech
|
||||
namespace Artemis.DeviceProviders.Logitech
|
||||
{
|
||||
internal class Orion : KeyboardProvider
|
||||
{
|
||||
@ -2,7 +2,7 @@
|
||||
using System.Windows.Forms;
|
||||
using Artemis.Utilities.Keyboard;
|
||||
|
||||
namespace Artemis.KeyboardProviders.Logitech.Utilities
|
||||
namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
{
|
||||
public static class KeyMap
|
||||
{
|
||||
@ -1,4 +1,4 @@
|
||||
namespace Artemis.KeyboardProviders.Logitech.Utilities
|
||||
namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
{
|
||||
public enum KeyboardNames
|
||||
{
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace Artemis.KeyboardProviders.Logitech.Utilities
|
||||
namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
{
|
||||
public class LogitechGSDK
|
||||
{
|
||||
@ -3,7 +3,7 @@ using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Artemis.KeyboardProviders.Logitech.Utilities
|
||||
namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
{
|
||||
public static class OrionUtilities
|
||||
{
|
||||
@ -1,10 +1,10 @@
|
||||
using System.Drawing;
|
||||
using Artemis.KeyboardProviders.Razer.Utilities;
|
||||
using Artemis.DeviceProviders.Razer.Utilities;
|
||||
using Corale.Colore.Core;
|
||||
using Corale.Colore.Razer;
|
||||
using Constants = Corale.Colore.Razer.Keyboard.Constants;
|
||||
|
||||
namespace Artemis.KeyboardProviders.Razer
|
||||
namespace Artemis.DeviceProviders.Razer
|
||||
{
|
||||
public class BlackWidow : KeyboardProvider
|
||||
{
|
||||
@ -2,7 +2,7 @@
|
||||
using Artemis.Utilities;
|
||||
using Corale.Colore.Razer.Keyboard.Effects;
|
||||
|
||||
namespace Artemis.KeyboardProviders.Razer.Utilities
|
||||
namespace Artemis.DeviceProviders.Razer.Utilities
|
||||
{
|
||||
public static class RazerUtilities
|
||||
{
|
||||
@ -1,4 +1,4 @@
|
||||
using Artemis.KeyboardProviders;
|
||||
using Artemis.DeviceProviders;
|
||||
|
||||
namespace Artemis.Events
|
||||
{
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using Artemis.KeyboardProviders;
|
||||
using Artemis.KeyboardProviders.Corsair;
|
||||
using Artemis.KeyboardProviders.Logitech;
|
||||
using Artemis.KeyboardProviders.Razer;
|
||||
using Artemis.DeviceProviders;
|
||||
using Artemis.DeviceProviders.Corsair;
|
||||
using Artemis.DeviceProviders.Logitech;
|
||||
using Artemis.DeviceProviders.Razer;
|
||||
using Artemis.Modules.Effects.AudioVisualizer;
|
||||
using Artemis.Modules.Effects.Debug;
|
||||
using Artemis.Modules.Effects.TypeWave;
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace Artemis.KeyboardProviders
|
||||
{
|
||||
public class KeyboardRegion
|
||||
{
|
||||
public KeyboardRegion(string regionName, Point topLeft, Point bottomRight)
|
||||
{
|
||||
RegionName = regionName;
|
||||
TopLeft = topLeft;
|
||||
BottomRight = bottomRight;
|
||||
}
|
||||
|
||||
public string RegionName { get; set; }
|
||||
public Point TopLeft { get; set; }
|
||||
public Point BottomRight { get; set; }
|
||||
|
||||
public Rectangle GetRectangle()
|
||||
=> new Rectangle(TopLeft.X, TopLeft.Y, BottomRight.X - TopLeft.X, BottomRight.Y - TopLeft.Y);
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.DeviceProviders;
|
||||
using Artemis.Events;
|
||||
using Artemis.KeyboardProviders;
|
||||
using Artemis.Services;
|
||||
using Artemis.Settings;
|
||||
using Caliburn.Micro;
|
||||
|
||||
@ -3,8 +3,8 @@ using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.KeyboardProviders.Corsair;
|
||||
using Artemis.KeyboardProviders.Logitech.Utilities;
|
||||
using Artemis.DeviceProviders.Corsair;
|
||||
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models;
|
||||
using Artemis.Utilities;
|
||||
|
||||
@ -5,7 +5,7 @@ using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.KeyboardProviders;
|
||||
using Artemis.DeviceProviders;
|
||||
|
||||
namespace Artemis.Utilities.Keyboard
|
||||
{
|
||||
|
||||
@ -9,8 +9,8 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using Artemis.DAL;
|
||||
using Artemis.DeviceProviders;
|
||||
using Artemis.Events;
|
||||
using Artemis.KeyboardProviders;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models;
|
||||
using Artemis.Models.Profiles;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user