mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 17:53:32 +00:00
Cherrypicked PR #400
This commit is contained in:
parent
42f3969c84
commit
eeab591a5b
@ -336,6 +336,8 @@
|
|||||||
<Compile Include="DeviceProviders\Logitech\G810.cs" />
|
<Compile Include="DeviceProviders\Logitech\G810.cs" />
|
||||||
<Compile Include="DeviceProviders\Logitech\LogitechGeneric.cs" />
|
<Compile Include="DeviceProviders\Logitech\LogitechGeneric.cs" />
|
||||||
<Compile Include="DeviceProviders\Logitech\LogitechKeyboard.cs" />
|
<Compile Include="DeviceProviders\Logitech\LogitechKeyboard.cs" />
|
||||||
|
<Compile Include="DeviceProviders\Razer\Firefly.cs" />
|
||||||
|
<Compile Include="DeviceProviders\Razer\Mamba.cs" />
|
||||||
<Compile Include="DeviceProviders\Logitech\Utilities\KeyMapG810.cs" />
|
<Compile Include="DeviceProviders\Logitech\Utilities\KeyMapG810.cs" />
|
||||||
<Compile Include="Dialogs\MarkdownDialog.xaml.cs">
|
<Compile Include="Dialogs\MarkdownDialog.xaml.cs">
|
||||||
<DependentUpon>MarkdownDialog.xaml</DependentUpon>
|
<DependentUpon>MarkdownDialog.xaml</DependentUpon>
|
||||||
|
|||||||
@ -57,7 +57,7 @@ namespace Artemis.DeviceProviders.Razer
|
|||||||
|
|
||||||
public override void DrawBitmap(Bitmap bitmap)
|
public override void DrawBitmap(Bitmap bitmap)
|
||||||
{
|
{
|
||||||
var razerArray = RazerUtilities.BitmapColorArray(bitmap, Height, Width);
|
var razerArray = RazerUtilities.BitmaptoKeyboardEffect(bitmap, Height, Width);
|
||||||
Chroma.Instance.Keyboard.SetCustom(razerArray);
|
Chroma.Instance.Keyboard.SetCustom(razerArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
50
Artemis/Artemis/DeviceProviders/Razer/Firefly.cs
Normal file
50
Artemis/Artemis/DeviceProviders/Razer/Firefly.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using Artemis.Settings;
|
||||||
|
using Artemis.DAL;
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using Corale.Colore.Core;
|
||||||
|
using Corale.Colore.Razer;
|
||||||
|
using Ninject.Extensions.Logging;
|
||||||
|
using Artemis.DeviceProviders.Razer.Utilities;
|
||||||
|
|
||||||
|
namespace Artemis.DeviceProviders.Razer
|
||||||
|
{
|
||||||
|
public class Firefly : DeviceProvider
|
||||||
|
{
|
||||||
|
private GeneralSettings _generalSettings;
|
||||||
|
public ILogger Logger { get; set; }
|
||||||
|
public Firefly(ILogger logger)
|
||||||
|
{
|
||||||
|
Logger = logger;
|
||||||
|
Type = DeviceType.Mousemat;
|
||||||
|
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Disable()
|
||||||
|
{
|
||||||
|
throw new NotSupportedException("Can only disable a keyboard");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool TryEnable()
|
||||||
|
{
|
||||||
|
if (!Chroma.SdkAvailable)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
// Some people have Synapse installed, but not a Chroma keyboard, deal with this
|
||||||
|
Chroma.Instance.Initialize();
|
||||||
|
CanUse = Chroma.Instance.Query(Devices.Firefly).Connected;
|
||||||
|
return CanUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void UpdateDevice(Bitmap bitmap)
|
||||||
|
{
|
||||||
|
if (Chroma.SdkAvailable && Chroma.Instance.Initialized)
|
||||||
|
{
|
||||||
|
var razerArray = RazerUtilities.BitmaptoMousePadEffect(bitmap);
|
||||||
|
Chroma.Instance.Mousepad.SetCustom(razerArray);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
50
Artemis/Artemis/DeviceProviders/Razer/Mamba.cs
Normal file
50
Artemis/Artemis/DeviceProviders/Razer/Mamba.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using Artemis.Settings;
|
||||||
|
using Artemis.DAL;
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using Corale.Colore.Core;
|
||||||
|
using Corale.Colore.Razer;
|
||||||
|
using Ninject.Extensions.Logging;
|
||||||
|
using Artemis.DeviceProviders.Razer.Utilities;
|
||||||
|
|
||||||
|
namespace Artemis.DeviceProviders.Razer
|
||||||
|
{
|
||||||
|
public class Mamba : DeviceProvider
|
||||||
|
{
|
||||||
|
private GeneralSettings _generalSettings;
|
||||||
|
public ILogger Logger { get; set; }
|
||||||
|
public Mamba(ILogger logger)
|
||||||
|
{
|
||||||
|
Logger = logger;
|
||||||
|
Type = DeviceType.Mouse;
|
||||||
|
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Disable()
|
||||||
|
{
|
||||||
|
throw new NotSupportedException("Can only disable a keyboard");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool TryEnable()
|
||||||
|
{
|
||||||
|
if (!Chroma.SdkAvailable)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
// Some people have Synapse installed, but not a Chroma keyboard, deal with this
|
||||||
|
Chroma.Instance.Initialize();
|
||||||
|
CanUse = Chroma.Instance.Query(Devices.Mamba).Connected || Chroma.Instance.Query(Devices.MambaTe).Connected;
|
||||||
|
return CanUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void UpdateDevice(Bitmap bitmap)
|
||||||
|
{
|
||||||
|
if (Chroma.SdkAvailable && Chroma.Instance.Initialized)
|
||||||
|
{
|
||||||
|
var razerArray = RazerUtilities.BitmaptoMouseEffect(bitmap);
|
||||||
|
Chroma.Instance.Mouse.SetCustom(razerArray);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,15 +1,16 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using Corale.Colore.Razer.Keyboard.Effects;
|
|
||||||
using Color = Corale.Colore.Core.Color;
|
using Color = Corale.Colore.Core.Color;
|
||||||
|
using Corale.Colore;
|
||||||
|
|
||||||
namespace Artemis.DeviceProviders.Razer.Utilities
|
namespace Artemis.DeviceProviders.Razer.Utilities
|
||||||
{
|
{
|
||||||
public static class RazerUtilities
|
public static class RazerUtilities
|
||||||
{
|
{
|
||||||
public static Custom BitmapColorArray(Bitmap b, int height, int width)
|
public static Corale.Colore.Razer.Keyboard.Effects.Custom BitmaptoKeyboardEffect(Bitmap b, int height, int width)
|
||||||
{
|
{
|
||||||
var keyboardGrid = Custom.Create();
|
|
||||||
|
var keyboardGrid = Corale.Colore.Razer.Keyboard.Effects.Custom.Create();
|
||||||
// Resize the bitmap
|
// Resize the bitmap
|
||||||
using (b = ImageUtilities.ResizeImage(b, width, height))
|
using (b = ImageUtilities.ResizeImage(b, width, height))
|
||||||
{
|
{
|
||||||
@ -26,5 +27,60 @@ namespace Artemis.DeviceProviders.Razer.Utilities
|
|||||||
return keyboardGrid;
|
return keyboardGrid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Corale.Colore.Razer.Mousepad.Effects.Custom BitmaptoMousePadEffect(Bitmap b)
|
||||||
|
{
|
||||||
|
var mousePadGrid = Corale.Colore.Razer.Mousepad.Effects.Custom.Create();
|
||||||
|
int pos = 0;
|
||||||
|
using (b = ImageUtilities.ResizeImage(b, 5, 5))
|
||||||
|
{
|
||||||
|
b.RotateFlip(RotateFlipType.RotateNoneFlipX);
|
||||||
|
for (var x = 0; x < 5; x++)
|
||||||
|
{
|
||||||
|
var c = b.GetPixel(4, x);
|
||||||
|
mousePadGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||||
|
}
|
||||||
|
for (var x = 0; x < 5; x++)
|
||||||
|
{
|
||||||
|
var c = b.GetPixel(x , 4);
|
||||||
|
mousePadGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||||
|
}
|
||||||
|
for (var x = 0; x < 5; x++)
|
||||||
|
{
|
||||||
|
var c = b.GetPixel(0, x);
|
||||||
|
mousePadGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mousePadGrid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Corale.Colore.Razer.Mouse.Effects.Custom BitmaptoMouseEffect(Bitmap b)
|
||||||
|
{
|
||||||
|
var mouseGrid = Corale.Colore.Razer.Mouse.Effects.Custom.Create();
|
||||||
|
using (b = ImageUtilities.ResizeImage(b, 3, 7))
|
||||||
|
{
|
||||||
|
var c = b.GetPixel(1, 0);
|
||||||
|
int pos = 0;
|
||||||
|
mouseGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||||
|
mouseGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||||
|
mouseGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||||
|
mouseGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||||
|
|
||||||
|
for (var x = 0; x < 7; x++)
|
||||||
|
{
|
||||||
|
c = b.GetPixel(0, x);
|
||||||
|
mouseGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||||
|
}
|
||||||
|
b.RotateFlip(RotateFlipType.RotateNoneFlipX);
|
||||||
|
for (var x = 0; x < 7; x++)
|
||||||
|
{
|
||||||
|
c = b.GetPixel(2, x);
|
||||||
|
mouseGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return mouseGrid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user