1
0
mirror of https://github.com/DarthAffe/CUE.NET.git synced 2025-12-12 16:58:29 +00:00

Switched from HidSharp to HidLibrary

This commit is contained in:
Daro 2017-11-06 18:50:39 +01:00
parent c364d4b253
commit e05e740bd2
3 changed files with 7 additions and 36 deletions

View File

@ -36,8 +36,8 @@
<DocumentationFile>bin\CUE.NET.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="HidSharp, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\HidSharp.1.5\lib\net35\HidSharp.dll</HintPath>
<Reference Include="HidLibrary, Version=3.2.46.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\hidlibrary.3.2.46.0\lib\HidLibrary.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@ -2,9 +2,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using HidSharp;
using System.Drawing;
using CUE.NET.Devices.Generic.Enums;
using HidLibrary;
namespace CUE.NET.Devices.Mouse
{
@ -14,7 +14,6 @@ namespace CUE.NET.Devices.Mouse
private const int pid = 0x1b34;
private HidDevice dev;
private HidStream stream;
private Color bars;
private Color front;
@ -32,9 +31,7 @@ namespace CUE.NET.Devices.Mouse
public override void Initialize()
{
var loader = new HidDeviceLoader();
dev = loader.GetDeviceOrDefault(vid, pid);
if (!dev.TryOpen(out stream)) throw new Exception("Glaive mouse init error!");
dev = HidDevices.Enumerate(vid, pid).Where(s=>s.DevicePath.Contains(@"&mi_02#")).Single();
initialized = true;
@ -47,27 +44,8 @@ namespace CUE.NET.Devices.Mouse
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)
{
switch(ledUpdateRequest.LedId)
@ -101,16 +79,8 @@ namespace CUE.NET.Devices.Mouse
buff[2] = 34;
buff[3] = 4;
buff[4] = 1;
//dpi indicator (no idea why but this crap doesnt work)
buff[5] = 3;
//if (dpiIndicator == 1 || dpiIndicator == 2 || dpiIndicator == 4)
//buff[6] = 255;
//if (dpiIndicator >= 2)
buff[7] = 255;
//if (dpiIndicator == 2 || dpiIndicator == 5)
buff[8] = 255;
//bars rgb
@ -131,7 +101,7 @@ namespace CUE.NET.Devices.Mouse
buff[19] = logo.G;
buff[20] = logo.B;
stream.Write(buff);
dev.Write(buff);
}
else throw new Exception("not initialized");
}

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="hidlibrary" version="3.2.46.0" targetFramework="net45" />
<package id="HidSharp" version="1.5" targetFramework="net45" />
</packages>