Skip to content

Commit

Permalink
Merge pull request #1918 from thingamajig0/fix/no-ducky-crash
Browse files Browse the repository at this point in the history
Fix crash if no ducky device is connected.
  • Loading branch information
diogotr7 authored Feb 23, 2020
2 parents cf168fe + e3cc87c commit 3e60355
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ private void btnToggleEnableDisable_Click(object sender, RoutedEventArgs e)
else
{
Global.Configuration.devices_disabled.Add(Device.Device.GetType());
Device.Device.Shutdown();
if(Device.Device.IsInitialized())
Device.Device.Shutdown();
}

UpdateControls();
Expand Down
10 changes: 7 additions & 3 deletions Project-Aurora/Project-Aurora/Devices/Ducky/DuckyDevice.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Aurora.Settings;
using Aurora.Settings;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand Down Expand Up @@ -87,6 +87,9 @@ public bool Initialize()

public void Shutdown()
{
if (!isInitialized)
return;

//This one is a little smaller, 81 packets. This tells the keyboard to no longer allow USB HID control of the LEDs.
//You can tell both the takeover and release work because the keyboard will flash the same as switching to profile 1. (The same lights when you push FN + 1)
foreach (byte[] controlPacket in DuckyRGBMappings.DuckyRelease)
Expand All @@ -100,8 +103,9 @@ public void Shutdown()
break;
}
}
packetStream.Dispose();
packetStream.Close();

packetStream?.Dispose();
packetStream?.Close();
isInitialized = false;
}

Expand Down

0 comments on commit 3e60355

Please sign in to comment.