Not searching device on every character input from our vendor and product text field.
Selecting a device in our tree now triggers a search for it.
2 /// Project: GenericHid
4 /// ***********************************************************************
5 /// Software License Agreement
7 /// Licensor grants any person obtaining a copy of this software ("You")
8 /// a worldwide, royalty-free, non-exclusive license, for the duration of
9 /// the copyright, free of charge, to store and execute the Software in a
10 /// computer system and to incorporate the Software or any portion of it
11 /// in computer programs You write.
13 /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 /// ***********************************************************************
25 /// This software was written using Visual Studio Express 2012 for Windows
26 /// Desktop building for the .NET Framework v4.5.
29 /// Demonstrates USB communications with a generic HID-class device
32 /// Windows Vista or later and an attached USB generic Human Interface Device (HID).
33 /// (Does not run on Windows XP or earlier because .NET Framework 4.5 will not install on these OSes.)
36 /// Finds an attached device that matches the vendor and product IDs in the form's
39 /// Retrieves the device's capabilities.
40 /// Sends and requests HID reports.
42 /// Uses the System.Management class and Windows Management Instrumentation (WMI) to detect
43 /// when a device is attached or removed.
45 /// A list box displays the data sent and received along with error and status messages.
46 /// You can select data to send and 1-time or periodic transfers.
48 /// You can change the size of the host's Input report buffer and request to use control
49 /// transfers only to exchange Input and Output reports.
51 /// To view additional debugging messages, in the Visual Studio development environment,
52 /// from the main menu, select Build > Configuration Manager > Active Solution Configuration
53 /// and select Configuration > Debug and from the main menu, select View > Output.
55 /// The application uses asynchronous FileStreams to read Input reports and write Output
56 /// reports so the application's main thread doesn't have to wait for the device to retrieve a
57 /// report when the HID driver's buffer is empty or send a report when the device's endpoint is busy.
59 /// For code that finds a device and opens handles to it, see the FindTheHid routine in frmMain.cs.
60 /// For code that reads from the device, see GetInputReportViaInterruptTransfer,
61 /// GetInputReportViaControlTransfer, and GetFeatureReport in Hid.cs.
62 /// For code that writes to the device, see SendInputReportViaInterruptTransfer,
63 /// SendInputReportViaControlTransfer, and SendFeatureReport in Hid.cs.
65 /// This project includes the following modules:
67 /// GenericHid.cs - runs the application.
68 /// FrmMain.cs - routines specific to the form.
69 /// Hid.cs - routines specific to HID communications.
70 /// DeviceManagement.cs - routine for obtaining a handle to a device from its GUID.
71 /// Debugging.cs - contains a routine for displaying API error messages.
72 /// HidDeclarations.cs - Declarations for API functions used by Hid.cs.
73 /// FileIODeclarations.cs - Declarations for file-related API functions.
74 /// DeviceManagementDeclarations.cs - Declarations for API functions used by DeviceManagement.cs.
75 /// DebuggingDeclarations.cs - Declarations for API functions used by Debugging.cs.
77 /// Companion device firmware for several device CPUs is available from www.Lvr.com/hidpage.htm
78 /// You can use any generic HID (not a system mouse or keyboard) that sends and receives reports.
79 /// This application will not detect or communicate with non-HID-class devices.
81 /// For more information about HIDs and USB, and additional example device firmware to use
82 /// with this application, visit Lakeview Research at http://Lvr.com
83 /// Send comments, bug reports, etc. to jan@Lvr.com or post on my PORTS forum: http://www.lvr.com/forum
87 /// Disabled form buttons when a transfer is in progress.
88 /// Other minor edits for clarity and readability.
89 /// Will NOT run on Windows XP or earlier, see below.
93 /// Uses the .NET System.Management class to detect device arrival and removal with WMI instead of Win32 RegisterDeviceNotification.
94 /// Other minor edits.
95 /// Will NOT run on Windows XP or earlier, see below.
99 /// This version will NOT run on Windows XP or earlier because the code uses .NET Framework 4.5 to support asynchronous FileStreams.
100 /// The .NET Framework 4.5 redistributable is compatible with Windows 8, Windows 7 SP1, Windows Server 2008 R2 SP1,
101 /// Windows Server 2008 SP2, Windows Vista SP2, and Windows Vista SP3.
102 /// For compatibility, replaced ToInt32 with ToInt64 here:
103 /// IntPtr pDevicePathName = new IntPtr(detailDataBuffer.ToInt64() + 4);
105 /// if ((deviceNotificationHandle.ToInt64() == IntPtr.Zero.ToInt64()))
106 /// For compatibility if the charset isn't English, added System.Globalization.CultureInfo.InvariantCulture here:
107 /// if ((String.Compare(DeviceNameString, mydevicePathName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))
108 /// Replaced all Microsoft.VisualBasic namespace code with other .NET equivalents.
109 /// Revised user interface for more flexibility.
110 /// Moved interrupt-transfer and other HID-specific code to Hid.cs.
111 /// Used JetBrains ReSharper to clean up the code: http://www.jetbrains.com/resharper/
115 /// Replaced ReadFile and WriteFile with FileStreams. Thanks to Joe Dunne and John on my Ports forum for tips on this.
116 /// Simplified Hid.cs.
117 /// Replaced the form timer with a system timer.
121 /// Supports Vendor IDs and Product IDs up to FFFFh.
125 /// Changed HIDD_ATTRIBUTES to use UInt16
129 /// Moved Free_ and similar to Finally blocks to ensure they execute.
133 /// Changes to support 64-bit systems, memory management, and other corrections.
134 /// Big thanks to Peter Nielsen.