Skip to content

Commit

Permalink
Added DeviceClassIds class
Browse files Browse the repository at this point in the history
  • Loading branch information
nefarius committed Dec 19, 2022
1 parent 7785c39 commit e7c87b7
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 36 deletions.
24 changes: 24 additions & 0 deletions PnP/DeviceClassIds.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;

namespace Nefarius.Utilities.DeviceManagement.PnP;

/// <summary>
/// Provides common device class <see cref="Guid" />s.
/// </summary>
public static class DeviceClassIds
{
/// <summary>
/// USB devices.
/// </summary>
public static Guid Usb => Guid.Parse("{36FC9E60-C465-11CF-8056-444553540000}");

/// <summary>
/// Xbox 360 Peripherals.
/// </summary>
public static Guid XnaComposite => Guid.Parse("{d61ca365-5af4-4486-998b-9db4734c6ca3}");

/// <summary>
/// Xbox Peripherals.
/// </summary>
public static Guid XboxComposite => Guid.Parse("{05f5cfe2-4733-4950-a6bb-07aad01a3a84}");
}
71 changes: 35 additions & 36 deletions PnP/DeviceInterfaceIds.cs
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
using System;
using System.Runtime.InteropServices;

namespace Nefarius.Utilities.DeviceManagement.PnP
namespace Nefarius.Utilities.DeviceManagement.PnP;

/// <summary>
/// Provides common device interface <see cref="Guid" />s.
/// </summary>
public static class DeviceInterfaceIds
{
/// <summary>
/// Provides common device interface <see cref="Guid" />s.
/// An interface exposed on USB host controllers.
/// </summary>
public static Guid UsbHostController => Guid.Parse("{3abf6f2d-71c4-462a-8a92-1e6861e6af27}");

/// <summary>
/// An interface exposed on USB hubs.
/// </summary>
public static class DeviceInterfaceIds
public static Guid UsbHub => Guid.Parse("{f18a0e88-c30c-11d0-8815-00a0c906bed8}");

/// <summary>
/// An interface exposed on USB devices.
/// </summary>
public static Guid UsbDevice => Guid.Parse("{a5dcbf10-6530-11d2-901f-00c04fb951ed}");

/// <summary>
/// An interface exposed on XUSB (Xbox 360) or XGIP (Xbox One) compatible (XInput) devices.
/// </summary>
public static Guid XUsbDevice => Guid.Parse("{EC87F1E3-C13B-4100-B5F7-8B84D54260CB}");

/// <summary>
/// An interface exposed on HID devices.
/// </summary>
public static Guid HidDevice
{
/// <summary>
/// An interface exposed on USB host controllers.
/// </summary>
public static Guid UsbHostController => Guid.Parse("{3abf6f2d-71c4-462a-8a92-1e6861e6af27}");

/// <summary>
/// An interface exposed on USB hubs.
/// </summary>
public static Guid UsbHub => Guid.Parse("{f18a0e88-c30c-11d0-8815-00a0c906bed8}");

/// <summary>
/// An interface exposed on USB devices.
/// </summary>
public static Guid UsbDevice => Guid.Parse("{a5dcbf10-6530-11d2-901f-00c04fb951ed}");

/// <summary>
/// An interface exposed on XUSB (Xbox 360) or XGIP (Xbox One) compatible (XInput) devices.
/// </summary>
public static Guid XUsbDevice => Guid.Parse("{EC87F1E3-C13B-4100-B5F7-8B84D54260CB}");

/// <summary>
/// An interface exposed on HID devices.
/// </summary>
public static Guid HidDevice
get
{
get
{
// GUID_DEVINTERFACE_HID exists but this is considered best practice
HidD_GetHidGuid(out var guid);
// GUID_DEVINTERFACE_HID exists but this is considered best practice
HidD_GetHidGuid(out Guid guid);

return guid;
}
return guid;
}

[DllImport("hid.dll", EntryPoint = "HidD_GetHidGuid", SetLastError = true)]
private static extern void HidD_GetHidGuid(out Guid guid);
}

[DllImport("hid.dll", EntryPoint = "HidD_GetHidGuid", SetLastError = true)]
private static extern void HidD_GetHidGuid(out Guid guid);
}

0 comments on commit e7c87b7

Please sign in to comment.