Permalink
Browse files

get/expose ProductString - will be Buzz for wired and Wbuzz for wireless

  • Loading branch information...
1 parent 5d5aff1 commit bce8be2b0a016a492b755dd422a1e3808636d5b3 @bbeardsley committed Oct 26, 2011
Showing with 21 additions and 3 deletions.
  1. +1 −1 AssemblyInfo.cs
  2. +9 −0 HIDDevice.cs
  3. +1 −1 IBuzzHandsetDevice.cs
  4. +10 −1 Win32USB.cs
View
@@ -26,7 +26,7 @@
// You can specify all the values or you can default the Revision and Build Numbers
// 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
View
@@ -27,6 +27,11 @@ public abstract class HIDDevice : Win32Usb, IDisposable
/// </summary>
public int InputReportLength { get; private set; }
+ /// <summary>
+ /// Product name
+ /// </summary>
+ public string ProductString { get; private set; }
+
#endregion Properties
#region IDisposable Members
@@ -74,6 +79,10 @@ private void Initialise(string strPath)
{
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;
HidP_GetCaps(lpData, out oCaps); // extract the device capabilities from the internal buffer
InputReportLength = oCaps.InputReportByteLength; // get the input...
View
@@ -23,6 +23,6 @@ public interface IBuzzHandsetDevice
/// </summary>
event EventHandler DeviceRemoved;
-
+ string ProductString { get; }
}
}
View
@@ -216,6 +216,7 @@ public class DeviceBroadcastInterface
/// <returns>True if successful</returns>
[DllImport("hid.dll", SetLastError = true)]
protected static extern int HidP_GetCaps(IntPtr lpData, out HidCaps oCaps);
+
/// <summary>
/// Creates/opens a file, serial port, USB device... etc
/// </summary>
@@ -229,14 +230,22 @@ public class DeviceBroadcastInterface
/// <returns></returns>
[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);
+
/// <summary>
/// Closes a window handle. File handles, event handles, mutex handles... etc
/// </summary>
/// <param name="hFile">Handle to close</param>
/// <returns>True if successful.</returns>
[DllImport("kernel32.dll", SetLastError = true)]
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
/// <summary>

0 comments on commit bce8be2

Please sign in to comment.