Update hidapi.net to properly Dispose() device

This commit is contained in:
Kamil Trzciński 2022-12-16 10:36:23 +01:00
parent d362eb41f5
commit 49f86225cb
3 changed files with 11 additions and 9 deletions

Binary file not shown.

View file

@ -1,18 +1,11 @@
using CommonHelpers;
using ExternalHelpers;
using Microsoft.VisualBasic.Logging;
using Microsoft.Win32;
using hidapi;
using PowerControl.External;
using PowerControl.Helpers;
using RTSSSharedMemoryNET;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Windows.Forms.AxHost;
namespace PowerControl
{
@ -201,7 +194,7 @@ namespace PowerControl
updateOSD();
}
private void NeptuneDevice_OnInputReceived(object? sender, hidapi.HidDeviceInputReceivedEventArgs e)
private Task NeptuneDevice_OnInputReceived(hidapi.HidDeviceInputReceivedEventArgs e)
{
var input = SDCInput.FromBuffer(e.Buffer);
@ -224,6 +217,8 @@ namespace PowerControl
// Consume only some events to avoid under-running SWICD
if (!neptuneDeviceState.buttons5.HasFlag(SDCButton5.BTN_QUICK_ACCESS))
Thread.Sleep(50);
return new Task(() => { });
}
private void dismissNeptuneInput()

View file

@ -26,8 +26,15 @@ namespace SteamController.Devices
stopwatch.Start();
}
~SteamController()
{
Dispose();
}
public void Dispose()
{
GC.SuppressFinalize(this);
using (neptuneDevice) { }
}
public bool Updated { get; private set; }