Skip to content

Commit

Permalink
get/expose ProductString - will be Buzz for wired and Wbuzz for wireless
Browse files Browse the repository at this point in the history
  • Loading branch information
bbeardsley committed Oct 26, 2011
1 parent 5d5aff1 commit bce8be2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion AssemblyInfo.cs
Expand Up @@ -26,7 +26,7 @@
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:


[assembly: AssemblyVersion("1.0.1.1")] [assembly: AssemblyVersion("1.0.1.2")]


// //
// In order to sign your assembly you must specify a key to use. Refer to the // In order to sign your assembly you must specify a key to use. Refer to the
Expand Down
9 changes: 9 additions & 0 deletions HIDDevice.cs
Expand Up @@ -27,6 +27,11 @@ public abstract class HIDDevice : Win32Usb, IDisposable
/// </summary> /// </summary>
public int InputReportLength { get; private set; } public int InputReportLength { get; private set; }


/// <summary>
/// Product name
/// </summary>
public string ProductString { get; private set; }

#endregion Properties #endregion Properties


#region IDisposable Members #region IDisposable Members
Expand Down Expand Up @@ -74,6 +79,10 @@ private void Initialise(string strPath)
{ {
try try
{ {
var buffer = Marshal.AllocHGlobal(126);//max alloc for string;
ProductString = HidD_GetProductString(_handle, buffer, 126) ? Marshal.PtrToStringAuto(buffer) : string.Empty;
Marshal.FreeHGlobal(buffer);

HidCaps oCaps; HidCaps oCaps;
HidP_GetCaps(lpData, out oCaps); // extract the device capabilities from the internal buffer HidP_GetCaps(lpData, out oCaps); // extract the device capabilities from the internal buffer
InputReportLength = oCaps.InputReportByteLength; // get the input... InputReportLength = oCaps.InputReportByteLength; // get the input...
Expand Down
2 changes: 1 addition & 1 deletion IBuzzHandsetDevice.cs
Expand Up @@ -23,6 +23,6 @@ public interface IBuzzHandsetDevice
/// </summary> /// </summary>
event EventHandler DeviceRemoved; event EventHandler DeviceRemoved;



string ProductString { get; }
} }
} }
11 changes: 10 additions & 1 deletion Win32USB.cs
Expand Up @@ -216,6 +216,7 @@ public class DeviceBroadcastInterface
/// <returns>True if successful</returns> /// <returns>True if successful</returns>
[DllImport("hid.dll", SetLastError = true)] [DllImport("hid.dll", SetLastError = true)]
protected static extern int HidP_GetCaps(IntPtr lpData, out HidCaps oCaps); protected static extern int HidP_GetCaps(IntPtr lpData, out HidCaps oCaps);

/// <summary> /// <summary>
/// Creates/opens a file, serial port, USB device... etc /// Creates/opens a file, serial port, USB device... etc
/// </summary> /// </summary>
Expand All @@ -229,14 +230,22 @@ public class DeviceBroadcastInterface
/// <returns></returns> /// <returns></returns>
[DllImport("kernel32.dll", SetLastError = true)] [DllImport("kernel32.dll", SetLastError = true)]
protected static extern IntPtr CreateFile([MarshalAs(UnmanagedType.LPStr)] string strName, uint nAccess, uint nShareMode, IntPtr lpSecurity, uint nCreationFlags, uint nAttributes, IntPtr lpTemplate); protected static extern IntPtr CreateFile([MarshalAs(UnmanagedType.LPStr)] string strName, uint nAccess, uint nShareMode, IntPtr lpSecurity, uint nCreationFlags, uint nAttributes, IntPtr lpTemplate);

/// <summary> /// <summary>
/// Closes a window handle. File handles, event handles, mutex handles... etc /// Closes a window handle. File handles, event handles, mutex handles... etc
/// </summary> /// </summary>
/// <param name="hFile">Handle to close</param> /// <param name="hFile">Handle to close</param>
/// <returns>True if successful.</returns> /// <returns>True if successful.</returns>
[DllImport("kernel32.dll", SetLastError = true)] [DllImport("kernel32.dll", SetLastError = true)]
protected static extern int CloseHandle(IntPtr hFile); protected static extern int CloseHandle(IntPtr hFile);
#endregion
[DllImport("hid.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
internal static extern bool HidD_GetProductString(
IntPtr hDevice,
IntPtr buffer,
uint bufferLength);

#endregion P/Invoke


#region Public methods #region Public methods
/// <summary> /// <summary>
Expand Down

0 comments on commit bce8be2

Please sign in to comment.