mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-13 00:58:31 +00:00
Merge pull request #64 from darosultan/GlaiveSupport
Glaive support: Switched from HidSharp to HidLibrary
This commit is contained in:
commit
2c957ea576
@ -36,8 +36,8 @@
|
|||||||
<DocumentationFile>bin\CUE.NET.XML</DocumentationFile>
|
<DocumentationFile>bin\CUE.NET.XML</DocumentationFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="HidSharp, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="HidLibrary, Version=3.2.46.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\HidSharp.1.5\lib\net35\HidSharp.dll</HintPath>
|
<HintPath>packages\hidlibrary.3.2.46.0\lib\HidLibrary.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
|||||||
@ -2,9 +2,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using HidSharp;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
|
using HidLibrary;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Mouse
|
namespace CUE.NET.Devices.Mouse
|
||||||
{
|
{
|
||||||
@ -14,7 +14,6 @@ namespace CUE.NET.Devices.Mouse
|
|||||||
private const int pid = 0x1b34;
|
private const int pid = 0x1b34;
|
||||||
|
|
||||||
private HidDevice dev;
|
private HidDevice dev;
|
||||||
private HidStream stream;
|
|
||||||
|
|
||||||
private Color bars;
|
private Color bars;
|
||||||
private Color front;
|
private Color front;
|
||||||
@ -32,9 +31,7 @@ namespace CUE.NET.Devices.Mouse
|
|||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
var loader = new HidDeviceLoader();
|
dev = HidDevices.Enumerate(vid, pid).Where(s=>s.DevicePath.Contains(@"&mi_02#")).Single();
|
||||||
dev = loader.GetDeviceOrDefault(vid, pid);
|
|
||||||
if (!dev.TryOpen(out stream)) throw new Exception("Glaive mouse init error!");
|
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
@ -47,27 +44,8 @@ namespace CUE.NET.Devices.Mouse
|
|||||||
|
|
||||||
OnLedsUpdating(updateRequests);
|
OnLedsUpdating(updateRequests);
|
||||||
|
|
||||||
if (updateRequests.Any()) // CUE seems to crash if 'CorsairSetLedsColors' is called with a zero length array
|
if (updateRequests.Any())
|
||||||
{
|
{
|
||||||
//int structSize = Marshal.SizeOf(typeof(_CorsairLedColor));
|
|
||||||
//IntPtr ptr = Marshal.AllocHGlobal(structSize * updateRequests.Count);
|
|
||||||
//IntPtr addPtr = new IntPtr(ptr.ToInt64());
|
|
||||||
//foreach (LedUpateRequest ledUpdateRequest in updateRequests)
|
|
||||||
//{
|
|
||||||
// _CorsairLedColor color = new _CorsairLedColor
|
|
||||||
// {
|
|
||||||
// ledId = (int)ledUpdateRequest.LedId,
|
|
||||||
// r = ledUpdateRequest.Color.R,
|
|
||||||
// g = ledUpdateRequest.Color.G,
|
|
||||||
// b = ledUpdateRequest.Color.B
|
|
||||||
// };
|
|
||||||
|
|
||||||
// Marshal.StructureToPtr(color, addPtr, false);
|
|
||||||
// addPtr = new IntPtr(addPtr.ToInt64() + structSize);
|
|
||||||
//}
|
|
||||||
//_CUESDK.CorsairSetLedsColors(updateRequests.Count, ptr);
|
|
||||||
//Marshal.FreeHGlobal(ptr);
|
|
||||||
|
|
||||||
foreach (LedUpateRequest ledUpdateRequest in updateRequests)
|
foreach (LedUpateRequest ledUpdateRequest in updateRequests)
|
||||||
{
|
{
|
||||||
switch(ledUpdateRequest.LedId)
|
switch(ledUpdateRequest.LedId)
|
||||||
@ -101,16 +79,8 @@ namespace CUE.NET.Devices.Mouse
|
|||||||
buff[2] = 34;
|
buff[2] = 34;
|
||||||
buff[3] = 4;
|
buff[3] = 4;
|
||||||
buff[4] = 1;
|
buff[4] = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//dpi indicator (no idea why but this crap doesnt work)
|
|
||||||
buff[5] = 3;
|
buff[5] = 3;
|
||||||
//if (dpiIndicator == 1 || dpiIndicator == 2 || dpiIndicator == 4)
|
|
||||||
//buff[6] = 255;
|
|
||||||
//if (dpiIndicator >= 2)
|
|
||||||
buff[7] = 255;
|
buff[7] = 255;
|
||||||
//if (dpiIndicator == 2 || dpiIndicator == 5)
|
|
||||||
buff[8] = 255;
|
buff[8] = 255;
|
||||||
|
|
||||||
//bars rgb
|
//bars rgb
|
||||||
@ -131,7 +101,7 @@ namespace CUE.NET.Devices.Mouse
|
|||||||
buff[19] = logo.G;
|
buff[19] = logo.G;
|
||||||
buff[20] = logo.B;
|
buff[20] = logo.B;
|
||||||
|
|
||||||
stream.Write(buff);
|
dev.Write(buff);
|
||||||
}
|
}
|
||||||
else throw new Exception("not initialized");
|
else throw new Exception("not initialized");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
|
<package id="hidlibrary" version="3.2.46.0" targetFramework="net45" />
|
||||||
<package id="HidSharp" version="1.5" targetFramework="net45" />
|
<package id="HidSharp" version="1.5" targetFramework="net45" />
|
||||||
</packages>
|
</packages>
|
||||||
Loading…
x
Reference in New Issue
Block a user