Skip to content

Commit

Permalink
fix razer update lock not releasing at launch
Browse files Browse the repository at this point in the history
  • Loading branch information
Aytackydln committed Oct 30, 2024
1 parent 1f2acc7 commit 4f31502
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions Project-Aurora/Project-Aurora/Nodes/Razer/RazerFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ protected RazerFetcher()
{
try
{
if (!_mutex.WaitOne(TimeSpan.FromMilliseconds(2000), true))
if (!_mutex.WaitOne(TimeSpan.FromMilliseconds(2000), false))
{
_mutex.ReleaseMutex();
return null;
}
}
Expand All @@ -54,23 +55,37 @@ protected RazerFetcher()
//continue
}

var usbDevice = GetUsbDevice();
if (usbDevice == null)
{
_mutex.ReleaseMutex();
return null;
}

var productKeyString = GetDeviceProductKeyString(usbDevice);
var mouseHidInfo = OnlineConfiguration.RazerDeviceInfo.MouseHidInfos[productKeyString];
var message = GetMessage(mouseHidInfo);

var report = GetReport(usbDevice, message);
var report = UpdateLocked();
_mutex.ReleaseMutex();

return report;
}

private byte[]? UpdateLocked()
{
try
{
var usbDevice = GetUsbDevice();
if (usbDevice == null)
{
return null;
}

var productKeyString = GetDeviceProductKeyString(usbDevice);
var mouseHidInfo = OnlineConfiguration.RazerDeviceInfo.MouseHidInfos[productKeyString];
var message = GetMessage(mouseHidInfo);

var report = GetReport(usbDevice, message);

return report;
}
catch(Exception e)
{
Global.logger.Error(e, "Failed to update Razer device status");
return null;
}
}

protected abstract byte[] GetMessage(RazerMouseHidInfo mouseHidInfo);

private static UsbDevice? GetUsbDevice()
Expand Down

0 comments on commit 4f31502

Please sign in to comment.