This commit is contained in:
EonaCat 2024-07-26 19:23:39 +02:00
parent ebc1d98195
commit 13d7af79f5
28 changed files with 1675 additions and 1938 deletions

View File

@ -1,15 +1,11 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Windows.Forms; using System.Windows.Forms;
namespace EonaCat.HID.Analyzer namespace EonaCat.HID.Analyzer
{ {
partial class AboutBox : Form internal partial class AboutBox : Form
{ {
public AboutBox() public AboutBox()
{ {
@ -105,4 +101,4 @@ namespace EonaCat.HID.Analyzer
} }
} }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup> </startup>
</configuration> </configuration>

View File

@ -7,8 +7,8 @@
<ProjectGuid>{61994020-DB89-4621-BA4B-7347A2142CFF}</ProjectGuid> <ProjectGuid>{61994020-DB89-4621-BA4B-7347A2142CFF}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>USB_HID_Analyzer</RootNamespace> <RootNamespace>EonaCat.HID</RootNamespace>
<AssemblyName>USB HID Analyzer</AssemblyName> <AssemblyName>EonaCat HID Analyzer</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />

View File

@ -1,23 +1,21 @@
using System; using EonaCat.HID.Helpers;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Reflection; using System.Reflection;
using EonaCat.HID.Helpers; using System.Windows.Forms;
namespace EonaCat.HID.Analyzer namespace EonaCat.HID.Analyzer
{ {
public partial class MainForm : Form public partial class MainForm : Form
{ {
const int WriteReportTimeout = 3000; private const int WriteReportTimeout = 3000;
Device _device; private Device _device;
List<Device> _deviceList; private List<Device> _deviceList;
public MainForm() public MainForm()
{ {
@ -65,39 +63,44 @@ namespace EonaCat.HID.Analyzer
rtbEventLog.SelectionLength = 0; rtbEventLog.SelectionLength = 0;
rtbEventLog.SelectionColor = currentColor; rtbEventLog.SelectionColor = currentColor;
rtbEventLog.AppendText(result); rtbEventLog.AppendText(result);
if (!rtbEventLog.Focused) rtbEventLog.ScrollToCaret();
if (!rtbEventLog.Focused)
{
rtbEventLog.ScrollToCaret();
}
})); }));
} }
private void UpdateDeviceList() private void UpdateDeviceList()
{ {
var count = 0;
dataGridView1.SelectionChanged -= DataGridView1_SelectionChanged; dataGridView1.SelectionChanged -= DataGridView1_SelectionChanged;
dataGridView1.Rows.Clear(); dataGridView1.Rows.Clear();
foreach (var device in _deviceList)
for (int i = 0; i < _deviceList.Count; i++)
{ {
count++; Device device = _deviceList[i];
var deviceName = ""; var deviceName = "";
var deviceManufacturer = ""; var deviceManufacturer = "";
var deviceSerialNumber = ""; var deviceSerialNumber = "";
var info = device.Info; var info = device.Info;
var capabilities = device.Capabilities; var capabilities = device.Capabilities;
deviceName = device.ReadProductName(); deviceName = device.ReadProductName();
deviceManufacturer = device.ReadManufacturer(); deviceManufacturer = device.ReadManufacturer();
deviceSerialNumber = device.ReadSerialNumber(); deviceSerialNumber = device.ReadSerialNumber();
var row = new string[] var row = new string[]
{ {
count.ToString(), (i + 1).ToString(),
$"VID_{info.VendorId:X4} PID_{info.ProductId:X4} REV_{info.Version:X4}",
deviceName, deviceName,
deviceManufacturer, deviceManufacturer,
deviceSerialNumber, deviceSerialNumber,
capabilities.InputReportByteLength.ToString(), capabilities.InputReportByteLength.ToString(),
capabilities.OutputReportByteLength.ToString(), capabilities.OutputReportByteLength.ToString(),
capabilities.FeatureReportByteLength.ToString(), capabilities.FeatureReportByteLength.ToString(),
string.Format("{0:X2}", capabilities.Usage), $"Vendor:{info.VendorId:X4} Product:{info.ProductId:X4} Revision:{info.Version:X4}",
string.Format("{0:X4}", capabilities.UsagePage),
device.DevicePath device.DevicePath
}; };
dataGridView1.Rows.Add(row); dataGridView1.Rows.Add(row);
@ -180,17 +183,26 @@ namespace EonaCat.HID.Analyzer
} }
private void ToolStripButtonConnect_Click(object sender, EventArgs e) private void ToolStripButtonConnect_Click(object sender, EventArgs e)
{
ConnectToSelectedDevice();
}
private void ConnectToSelectedDevice()
{ {
try try
{ {
_device = _deviceList[dataGridView1.SelectedRows[0].Index]; _device = _deviceList[dataGridView1.SelectedRows[0].Index];
if (_device == null) throw new Exception("Could not find Hid USB Device with specified VID PID"); if (_device == null)
{
throw new Exception("Could not find Hid USB Device with specified VID PID");
}
// open as read write in parallel // Open a device for reading and writing
_device.OpenDevice(DeviceMode.Overlapped, DeviceMode.Overlapped, ShareMode.ShareRead | ShareMode.ShareWrite); _device.OpenDevice(DeviceMode.Overlapped, DeviceMode.Overlapped, ShareMode.ShareRead | ShareMode.ShareWrite);
_device.OnInserted += HidDevice_Inserted; _device.OnInserted += HidDevice_Inserted;
_device.OnRemoved += HidDevice_Removed; _device.OnRemoved += HidDevice_Removed;
_device.MonitorDeviceEvents = true; _device.MonitorDeviceEvents = true;
AppendEventLog($"Connected to device {_device.ReadProductName()}", Color.Green);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -332,9 +344,9 @@ namespace EonaCat.HID.Analyzer
{ {
try try
{ {
var str = string.Format("Inserted Hid Device --> VID {0:X4}, PID {0:X4}", _device.Info.VendorId, _device.Info.ProductId); var str = string.Format("Inserted Device --> VID {0:X4}, PID {0:X4}", _device.Info.VendorId, _device.Info.ProductId);
AppendEventLog(str); AppendEventLog(str, Color.Orange);
//_device.ReadReport(_device_InputReportReceived); _device.ReadReport(Device_InputReportReceived);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -359,7 +371,7 @@ namespace EonaCat.HID.Analyzer
{ {
try try
{ {
if (!_device.IsConnected || !_device.IsOpen) return; if (!_device.IsConnected || !_device.IsOpen || report.Data == null) return;
var str = $"Rx Input Report [{report.Data.Length + 1}] <-- ID:{report.ReportId}, {ByteHelper.ByteArrayToHexString(report.Data)}"; var str = $"Rx Input Report [{report.Data.Length + 1}] <-- ID:{report.ReportId}, {ByteHelper.ByteArrayToHexString(report.Data)}";
AppendEventLog(str, Color.Blue); AppendEventLog(str, Color.Blue);
_device.ReadReport(Device_InputReportReceived); _device.ReadReport(Device_InputReportReceived);
@ -369,5 +381,10 @@ namespace EonaCat.HID.Analyzer
PopupException(ex.Message); PopupException(ex.Message);
} }
} }
private void dataGridView1_DoubleClick(object sender, EventArgs e)
{
ConnectToSelectedDevice();
}
} }
} }

View File

@ -120,9 +120,6 @@
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column9.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Column9.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
@ -141,10 +138,7 @@
<metadata name="Column5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Column5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="Column6.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="Column8.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Column8.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
@ -154,140 +148,68 @@
<value>132, 17</value> <value>132, 17</value>
</metadata> </metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="newToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAERSURBVDhPrZDbSgJRGIXnpewd6jXsjSQvIrwoI0RQMChU
0iiDPCGiE3ZCRkvR8VzTeBhnyR5/ccaZNnPhB4t9sdf6Ln5hb8QeathNJFVFKF5C8DqL4ksDVHWGDf7j
LHyPg6NjviSaFqlu5yQYR+KpupaIkrMknCxT3Y7v/NYYb0ITK1c3BarbWWhLQ7IR0cTKReyZ6lZ0XYei
ztHpK4bAc+h1FgQijzSxMptrGIxVSO0xX3AaStFki7bUMVFmaMm/eJMGfIH/MkGzLep0AXn4h/r3CJV3
mS9gn2bY4UY/UzQ7E9TqfeTFtnuB+XAfzSHKr11kSl/uBebDiZ89ZCst3OUkdwL28sIVsE83ock+EIQV
2Mz2wxeg6/UAAAAASUVORK5CYII=
</value>
</data>
<data name="openToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJHSURBVDhPxZBdSNNhFMb/F110ZZEVhVBgeeHNICiiuggp
olAUyyxI0oSaH1QYC3N+tKnp5ubm1JUua5uuqdNKMwr7kApFItTUkWZqVhSVYmao5Nevvy7UoYR3HXh4
4XCe33nOKyy3lAY7l9RWMo0O/raWXxEyo5spVYTNvOGyfIRPfW+ptOkXqaPl6T83hcRmExSdgzAz3NVm
YWyoYla/B+1M9JtxWLPpaH22JORIjI6gKAMB0jyEimIdo4OlbuaprwVMOOMovammpDADc34qppwUrmnl
5Kni3aFlFg2j3y1z5mnRTJccnNIltQhwq0jFry+mOXNtpWZWDx1Z1NhV3C3JwGFOw25SYjVe5oYhiUKd
HKMmwQUrMWUw/CF3NnZvvYKqUh1TvUroS3fXe7HXkwidMngTS2t5KLbregSzMY2f3Wr4qKW6LJvGR1rX
0MLor8OhKYTJBn/GHvvxrliCTBrsOqXIoOBHh5K+hmSq7FqmexTQHuUytkaKxuNMNgYyVneA4Qd7GKjc
hjLaRzxH7gIU6JIZaEvgtk1D8wsxSWecCDgNzWFMvwxm/PkhRmr3Mli1nW9lvjRdWc0Jf+/5jzRmyWmv
S+GOLQu6U6BFjPvqKOP1AYw88WOoZif9DgmfLVtxaj1RSLdwNvrkPCA3M54KqxrnvRia9MKcGrUrqFOt
5H7qKsqT1mGO9+Lqhc2ELdw+U/r0i+gVZ8hMiCDx3DHORwZyKnQ/hw/uYt9uCTskPvh6e7Fp41rWr/Fg
g6eHO+A/lyD8ARfG3mk9fv1YAAAAAElFTkSuQmCC
</value>
</data>
<data name="saveToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIySURBVDhPrZLfS5NRGMfff6H7boIuuq2pMZyL1eAt11CW
DcOKsB9vpFmaLtNExco0av6CbIVLJ61Wk3BSkT/AFCkRZSpZmrmiJQ41xSaCwdfznL15XEUX0Reem5f3
8znnec4j/Zc8fxYGla91CS3eRTx0z6OpMYS7jmnU1X6B/VYA18snUVoyjsKCt8jLHcH5c36ouCQR2NUJ
1Nas4G9ZXlmFKbULh1Kf8lJxSfI+WeCCyopv6q+/h+DQ/DJ2WV5Ao1FgPegRAveDOS4oLfmq/h6dn/DH
4AJizD4UXJrCAUuzEDgbZrjgou2DiohshIcnQtgme5GTPYbkJKcQ1N8OckHW2REVi+RXuM8fxGaDG4oy
ALPZIQQ11Z+5QDk1oKJ/hjv7P2FTfCMOH3mFxMQ6IbhROYWOdrCnBI4dfwPr0V4+bRoY9UzXppMjcDdS
rC8hy3YhuFI2gTYf2A4Aza4f7N2/o/zaLB8qDYx6zszwr8P7k1thNFYIweXCMXgeAfedq2xxwjClZUeV
Jd2GtDNFETiJwfs8MBjKhMCWN8pgoLoqzE8miH1GjE7G4PsZjE7OQsm9ij2mFg7rdrug1xcJAa2l4w7W
r00Cgk/n38S7wBwC04u4UGxHrMHF4CbEJtyDLj5fCDIzhljfSxzeavRgyw4Zj9t64GvvQ0d3P3pfD2Kv
2QqNvgFxDN6urYdWmyMElJMnevh60obRktA701PRtGlg1DOdSkXwzrisaMG/RZLWAE60OMW5fNhvAAAA
AElFTkSuQmCC
</value>
</data>
<data name="printToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIpSURBVDhPtZL/T1JRGMb5p1itrVZbbRpqZbawnBENV1I0
jGlByTSyJTXJwq2oKZQb1KAv6JCYWSxvBrkkZUq4CeQEiRABFeLL072Xa0zRra31bO8v57zP5znnPYf1
X+TxhWF6O7VtGYcnwbSWijKPOLzYrPSvLPwLS3huGUMlT7o9wGD9grVUBj+icdid03S9tDmgNxNwTgVQ
J+rA8XNtWwM+uuZATMwxmQVRycuJFNyzIRitDlScugKzjSgFRGJJaIwEsrk8AsHIhnSL/Ssck37UNipQ
I5DjtuYV7uksRYhr2kebhx2eP6nrycFIEh5fBA/1Nvru8q5+PDaOovK0rABwfwugWzcErfkzHhjsePL6
E7q1VrTdNUDcrgGvSYlDZHN5XTNOnL8BVe8AJAoNDtZfLgDu9L1BPJmikzcrk81hlRwodZJwdBXziwnI
OrVoaOkiT8C8hKLHBPO7CbywOaE1jeC+bhAd6meQdvZC1KoG/5IS3MZ2HObLUHZSggvkWq3wOvbWiAqA
VpWeyStVfCUNf3AZ4zNhfHCFMEDMgye+hYr6FrDLzxQAUuVTpr0ocn74mchg5vsKRt1RcHp2Qv9+kZ78
UcE17KkWFgHNN/uQzgBkGKLJPBZiecyGchjzrmFwPIF++xJUbDbUQzEacIArLpopSRSP4CUN1Obf1Abz
uqob5KjiXwWH/GVl5HPt5zZh37GL2H1EiF1VZ7GDI6CNW5r/TSzWbwHYL0mKJ5czAAAAAElFTkSuQmCC
</value>
</data>
<data name="toolStripButtonReload.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="toolStripButtonReload.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIzSURBVDhPjZNNaBNBFMcHSknBKKkg9FKL7eIhSFtpISHG YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAI4SURBVDhPjZNPaNNQHMcfjNGBVTpB2GUOtyDYwzbZsKV2
zk4CYS/x1rsnP25CDx7THpRsAoJfhQTai3rJRVTowYObGi/tbiTWilYDJdlNtkGT3gN2fW92tqapQv/w fUkKJZd6292Tf27CDh6zHSxpCoJuDlrYLuqlF1FhBz20ox62NdU6JzotzDavzYpddy9ofL+Xl9l1CvvC
SOY/7/32vZld8j9pY2MBLRj0b0WjwxjCPpkKhAy8G7+4X7wgJSvhyK1K+MpX9OuyTHlCv9KbrYiq23cx j+R93+/3ye/3kqD/KTcy4sv5/d7tcHgQgtunUxahvrejlw/zl4R4ORi68+Ha9S/g10QRs4ReaVvNULJo
0kbjPHraxIS0Jkm+74ri+zx7dbROqWTJsa5F2XNjZmaQF3pKabtDGb3ZyBi2k9VtWdjHZFE6DRDbktkz 3YfQjPpF8HJjY8KaIHi+KYrn0/TMcA1jgYhyh2DpmTE11c8KXam5vQF9s1HXDctOFS2R2ydEMJ6kEIuI
YbmCwnlVb3Yzul1CQPtHfrnzZdHpVPNu6Nd3alu3+TkISNdi7BovRqmGvakazUe8k43WSLua044AKnec 0lNuOaKFs4mNekfftAoAaH3PLLc/z9vtSsaJ4s3d6vZddg4c0iGSdIMVg5KGtaUZjcdOJ82hg0o6dwxQ
dmXhrUgnJmVPLBpb54t7H5vn4OkHaWMvzA3QIaB80w34j57YBgANA+R3PZE4S6DlEM6e2m75xb4LEIUe vmcflOfe8HRkYmmJYHmdLR68b1xIbJi/NWM/yAyqI0DpthP0Hjy+TQE4+APjX7VY7DyiLQdgdnWn6eX7
pBfwS1HOwBiONRe/TDLlvUkEqB9+nhb7fwE9kF7ALqUBBJiMTZFsxT6FI2AnYv8oYHvp2AhwgBEcoea9 DoAXupBuQEtRztExbBKJXkV6aX8cAMl3P8/y/b+ALkg3YA9jHwBMSZpAqbJ1BkaATvj+ccDOwokR6AGG
YNBBMWM0H/MFiAO8A9x54HQ+LXAAPHkEYsiUY8twiEWRTki2bCf5NW5Y07huV/NPDwEi0DNpXDZlVuLX YISq+4HRDvK60VhkCyoGcA9w96Hd/jjHAPTJQzQGTFFeJhE5z9MRSpWsuPMaySSsW5XMkyMAD/BMHBVN
OBdL8mJP8A7k4CptD/IvIYAfHmUWdiJsVznDGYQxVrCT++WWNLu6Pqo8XPNJEMHUKwlzavH4OBSnMRqM USqw1xiR46zYlV600gmDWC7kXwIAO7yZCIFOuO0obdj9dIwV6CRRagrTq+vDyqM1j0DDr74UIKcajY7S
JXhhv+BbiOJvaPX9t9BK6cbk0uvkpcU3+/OFwgBPOKmiL0rDGMFUwT+VehkQdp8I+QMJYXp5Ef1ZOgAA T1mDqEtSjBX2iv4LYbgGVvNfAyuFW+MLr+JX5l8fzmazfSzhtAo/LwxC+NWsd0J94eN2jxD6A3Zieio6
AABJRU5ErkJggg== Qs3XAAAAAElFTkSuQmCC
</value>
</data>
<data name="toolStripButtonFilter.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEaSURBVDhPY6AKmFApJh7mrfvV1NT0PzE4zFvn67RicTGo
dgaGiZUK9h5Ohv+/7uL8//8gO178dRfXf5DaKeUKdlDtEJAfo361KlUVqyYY/neA/X9Fsur/gjiNS1Bt
CDCzXpIr0l/n04pWaayaQXhJk8z/cF+dLxNzhfig2lDBxDJ5CzdHw7/nFwhiaL60SPC/q4PhXwyno4Ou
PIUyL2eD/683c8M1v93K/R8k1p6j0AZVhh+UJakeLohThxuQF6PxvzRB9TBUmjCYUi/KY25uCjcAxAaF
EVSaMKivZ2ACxTfMABAbKkUcGFwGfNrB9d/SwoR0A0Ca9kwW/+/nZvC/LFH1CFSKeFCRpLo/xl/7Q2e+
QjlUiBaAgQEASczleY2pHPIAAAAASUVORK5CYII=
</value> </value>
</data> </data>
<data name="toolStripButtonOpen.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="toolStripButtonOpen.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIwSURBVDhPY5BuvNMjXXPjhWTpxbtiuSfeiOWceC2Re8qe YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIzSURBVDhPY5BuvNMjXXPjhWTJubsiuUffCOccfS2Re8qe
AQrEiy8oShScuSGedXw2VAgVSDfcPSBdde2/ZNml/+J5J8FYJPtEAVSaASjeDJITzTj8HSqECggZIFF2 AQrEiy8oihWcuSGeeXw2VAgVSNXfOSBdde2/ZNml/+J5J8FYJPtEAVSaASjeDJITyjj8HSqECggZIFF2
uQQkJ5Z++DNUCBUQMkC0/gqPdMaWU6K5J2KhQqiAkAEgYOTsHW/i6uNr4uytZOjoJc9QX88ElWJgkGm6 uQQkJ5Zy+DNUCBUQMkC0/gqPVPqWU6K5J2KhQqiAkAEgYOTsHW/i6uNr4uytZOjoJc9QX88ElWJgkGm8
t1+6GtUA8ZzjeVBpODBy9XUCGpAGwsbO3lOMjY1ZwRJSjXecpWtvLpXL2bFcPPfYWrHck6vEM46KgeTm u1+6GtUA8ZzjeVBpODBy9XUCGpAGwsbO3lOMjY1ZwRJSjXecpWpvLJXL2bFcPPfoWrHck6vEM46KgeTm
3/9vUH/lu0r9pe9KyNg1ubTQu3GaO9gAGDB19U0wd/dXgHIZFt3/ebj3xq//jVcwcd2Fr//TT337m3zq 3/9vUH/lu0r9pe9KyNg1ubTQu3GaO9gAGDB19U0wd/dXgHIZFt3/cbj3xq//jVcwcd2Fr/9Tjn/+m3zq
RyVUOaYBKx79fp85ddV/n8Ts/3bhySjYwMnnf9KqU//jTvzYD1UOCihfHyM3b2MoF2xAclP/f6fAiP/J RyVUOaYByx/9eJ85ddV/n8Ts/3bhySjYwMnnf9KqU/9jT/zYD1UOCihfHyM3b2MoF2xAclP/f6fAiP/J
1r7/5xv5/V9m4Pffy8Hnv5aF3f+Q3mX/4098PwBVzsBg5uHBBwyc7tDQUGYQH9mADjO//9+VAv5/VQ74 1r7/5xv5/V9m4Pffy8Hnv5aF3f+Q3mX/4098PwBVzsBg5uHBBwyc7tDQUGYQH9mADjO//9+VAv5/VQ74
H2vri90AEDBx9FM3dvFpM3Hxrurff/UTzABTF5//iwz9/leZ+/03AbJxGoAMQC5IaZv23zU4GqwJGWua H2vri90AEDBx9FM3dvFpM3Hxrurfc+kTzABTF5//iwz9/leZ+/03AbJxGoAMQC5IaZv23zU4GqwJGWua
2f6PmrmNsAENl378L9t9+3/5wccIfODR/8JtN/6XXvhJwICHv982Xv3132LSvf+xW97+d5z18H/o6pf/ 2f6PmrmNsAENl378L9t9+3/5wccIfODR/8JtN/6XXviJ34Cl9368bbz667/FpHv/Y7e8/e846+H/0NUv
vRc/A+OS8z9BsbAHqhwTzL/zs2/S7V9Pmq78uguMexTccPnXvdTTP54kn/7hBQD2VYjPDPoywwAAAABJ /3svfgbGJed//o89/mMPVDkmmH/nZ9+k27+eNF35dRcY9yi4/vKve8mnfzxJPv3DCwAg0ohxfV2WKwAA
RU5ErkJggg== AABJRU5ErkJggg==
</value> </value>
</data> </data>
<data name="toolStripButtonClear.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="toolStripButtonClear.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJKSURBVDhPY8AGbPa9SLPZ+yISysUP0upncmWU93anV/ZZ YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJSSURBVDhPY8AGbPa9SLPZ+yISysUP0upncmWU93anV/ZZ
Q4UYbPY+f2qz58UNKBc/AGpen1nR+z+jvOdzVnmPDUjMes+LLqABdWAFhEBmec8CkAHIhlgce8Q5e0ev Q4UYbPY+e2qz68UNKBc/SC/vXZ9Z0fs/taTrc1Z5jw1IzHrPiy6bPS/qwAoIgczyngUgA5ANsTj2iHP2
0Nyp1e8m9NX9OLKpxA2qHBPU19ezAF2xGmZIbG7zr9TixrypE2q/wcQ6Oxv+/TqfDvciBgAZkl7WsyY2 jl6huZOq3/V21/04sqnEDaocE9TX17MAvbAaZkhUbsOv1OLGvKkTar/BxNra6v/9Op8O9yIGABmSVta9
t+V/WHrd/5SSDrBGEC6t6/h/b2vk/z/Xi978e9SqA9WCCeLr6zmisxufpBSjar690OX/n6sF//8/av3/ Jja35X9Yet3/lJIOsEYQLq3r+H9va+T/n9eL3vx71KoD1YIJ4uvrOSKz65+kFKNqvr3Q5f+fqwX//z9q
72HLl38Pm8OhWlDBlf1ZPJMn1MGdXVrb/v/e5vD/vy/l/P93vxFsAAK3LPj3sEkbqhUCpk6s/Yps891N /f/7XuOXfw+bw6FaUMGV/Vk8kyfUwZ1dWtv+/97m8P+/L+X8/3e/EWwAArcs+PewSRuqFQIm9VV9Rbb5
of+/bnICam5A04zAQBfFQbUzMBTVdiKcvcD5/+8r+f//3qr+//d6GVwDiP/nciGSAW2I2Nm8pHx3WT3Q 7qbQ/183OQE1N6BpRuB/D1vioNoZGIpqOxHOXuD8//eV/P9/b1X//3u9DK4BxP9zuRDJgDZE7GxaXLa7
2cAA+30x+//fm5VwhXD8sOX/z8PR/7/v9v//dYfPu/9P67mg2iHg3bG0+b+vFf3D0AjEf66W/P95IhHM rB7obGCA/b6Y/f/vzUq4Qjh+2PL/5+Ho/993+///usPn3f+n9VxQ7RDw9mja/B+Xi/5haATiP1dL/v88
/vew9SvWGLHf/14A6Kx4oIK/cM0PmoDh0ARm/zqd+v/bNk+gN/IzXXc+57bf/58FqpWBwWX3O35gHnhi kQhm/77X+hVrjNjvfy8AdFY8UMFfuOYHTcBwaAKzf51O/f9tmyfQG/mZrjufc9vv/88C1crA4LL7Hb/N
v/+lBNCpCTBD/t2t//9tuxfQ/1X/gbb+/Herugyk3nrP82k2u18UgTWDgM2e5xHAHPjfas+LDBD/34Nm 3udP7Pe/lAA6NQFmyL+79f+/bfcC+r/q/+9HrT//3aouA6m33vN8ms3uF0VgzSBgs+d5BDAH/rfa8yID
J6CGs/8etfz6e7/h07dd/peBLjEEyXlsu8UOzC/vrPe+OAvig0Hoqv/MQAO22e+/zwEVAoP//+uZ/v9f xP/3oNnpz6PWs78fNf76db/+07ddfpeBLjEEyXlsu8VusfvFO6u9L86C+GAQuuo/M9CAbfb773NAhcDg
xQzlwgHQgALbfS/8AQcUyckd1FlpAAAAAElFTkSuQmCC //96pv//VzFDuXAAzHAFtvte+AMAGv7JUh+nLuoAAAAASUVORK5CYII=
</value> </value>
</data> </data>
<data name="aboutToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="toolStripButtonFilter.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEzSURBVDhPpZO9SgNBFIXHnyRWdmJtYelj5DHyDMHW1tpK YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEZSURBVDhPY6AKmFApJh7mpvHV1NT0PzE4zE3967RicTGo
38EfSMKCAcuNURtBsUonFoFFg2vWQAyyd4/3zmyy2Z0RI7lwujnfzD33jrLKT3aVT4eqQ23ViYPKRUjl dgaGiZUK9h5Ohv+/7uL8//8gO178dRfXf5DaKeUKdlDtEJAfo361KlUVqyYY/neA/X9Fsur/vFiNS1Bt
xvCt1Iq6a96omp5yFLCi/LjOGrMZU22chZnOQ6x7oyafXU1daWkzXc4bnYBU5Wb0mofIzUVjl3DcT3AV CDCzXpIrwl/n04pWaayaQXhJk8z/IF/1LxNzhfig2lDBxDJ5C0d7w7/nFwhiaL60SPC/A1AOw+nooCtP
xNhufFgQ/RJjlp7zzxZVnxL0v4D7d8L+w9gCSDsmExNYzizavCG0BsDtgLDjDW0AS4JVfJjTtgFbd0Z7 oczL2eD/683ccM1vt3L/B4m15yi0QZXhByVJKocL4tThBuTFaPwviVc5DJUmDKbUi/KYm5vCDQCxQWEE
7cjZgkimw4A4KJpL14THT8xaOOpNnAAZsRMgqvWyDP4AuFtYBGBa+CXERQAmRMcYJYMT3oEpQHbBAszG lSYM6usZmEDxDTMAxIZKEQcGlwGfdnD9t7QwId0AkKY9k8X/+7kZ/C9LVDkClSIeVCSq7o/x0frQma9Q
qHchv0gVXqKD50Tr9OVbqwjIFklq6VWWWuozzde/vrNSP7w+X7LGzKAFAAAAAElFTkSuQmCC DhWiBWBgAAClAOU+yA6HfwAAAABJRU5ErkJggg==
</value> </value>
</data> </data>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>237, 17</value>
</metadata>
<data name="newToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="newToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
@ -299,70 +221,8 @@
2Mz2wxeg6/UAAAAASUVORK5CYII= 2Mz2wxeg6/UAAAAASUVORK5CYII=
</value> </value>
</data> </data>
<data name="openToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value> <value>237, 17</value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJHSURBVDhPxZBdSNNhFMb/F110ZZEVhVBgeeHNICiiuggp
olAUyyxI0oSaH1QYC3N+tKnp5ubm1JUua5uuqdNKMwr7kApFItTUkWZqVhSVYmao5Nevvy7UoYR3HXh4
4XCe33nOKyy3lAY7l9RWMo0O/raWXxEyo5spVYTNvOGyfIRPfW+ptOkXqaPl6T83hcRmExSdgzAz3NVm
YWyoYla/B+1M9JtxWLPpaH22JORIjI6gKAMB0jyEimIdo4OlbuaprwVMOOMovammpDADc34qppwUrmnl
5Kni3aFlFg2j3y1z5mnRTJccnNIltQhwq0jFry+mOXNtpWZWDx1Z1NhV3C3JwGFOw25SYjVe5oYhiUKd
HKMmwQUrMWUw/CF3NnZvvYKqUh1TvUroS3fXe7HXkwidMngTS2t5KLbregSzMY2f3Wr4qKW6LJvGR1rX
0MLor8OhKYTJBn/GHvvxrliCTBrsOqXIoOBHh5K+hmSq7FqmexTQHuUytkaKxuNMNgYyVneA4Qd7GKjc
hjLaRzxH7gIU6JIZaEvgtk1D8wsxSWecCDgNzWFMvwxm/PkhRmr3Mli1nW9lvjRdWc0Jf+/5jzRmyWmv
S+GOLQu6U6BFjPvqKOP1AYw88WOoZif9DgmfLVtxaj1RSLdwNvrkPCA3M54KqxrnvRia9MKcGrUrqFOt
5H7qKsqT1mGO9+Lqhc2ELdw+U/r0i+gVZ8hMiCDx3DHORwZyKnQ/hw/uYt9uCTskPvh6e7Fp41rWr/Fg
g6eHO+A/lyD8ARfG3mk9fv1YAAAAAElFTkSuQmCC
</value>
</data>
<data name="saveToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIySURBVDhPrZLfS5NRGMfff6H7boIuuq2pMZyL1eAt11CW
DcOKsB9vpFmaLtNExco0av6CbIVLJ61Wk3BSkT/AFCkRZSpZmrmiJQ41xSaCwdfznL15XEUX0Reem5f3
8znnec4j/Zc8fxYGla91CS3eRTx0z6OpMYS7jmnU1X6B/VYA18snUVoyjsKCt8jLHcH5c36ouCQR2NUJ
1Nas4G9ZXlmFKbULh1Kf8lJxSfI+WeCCyopv6q+/h+DQ/DJ2WV5Ao1FgPegRAveDOS4oLfmq/h6dn/DH
4AJizD4UXJrCAUuzEDgbZrjgou2DiohshIcnQtgme5GTPYbkJKcQ1N8OckHW2REVi+RXuM8fxGaDG4oy
ALPZIQQ11Z+5QDk1oKJ/hjv7P2FTfCMOH3mFxMQ6IbhROYWOdrCnBI4dfwPr0V4+bRoY9UzXppMjcDdS
rC8hy3YhuFI2gTYf2A4Aza4f7N2/o/zaLB8qDYx6zszwr8P7k1thNFYIweXCMXgeAfedq2xxwjClZUeV
Jd2GtDNFETiJwfs8MBjKhMCWN8pgoLoqzE8miH1GjE7G4PsZjE7OQsm9ij2mFg7rdrug1xcJAa2l4w7W
r00Cgk/n38S7wBwC04u4UGxHrMHF4CbEJtyDLj5fCDIzhljfSxzeavRgyw4Zj9t64GvvQ0d3P3pfD2Kv
2QqNvgFxDN6urYdWmyMElJMnevh60obRktA701PRtGlg1DOdSkXwzrisaMG/RZLWAE60OMW5fNhvAAAA
AElFTkSuQmCC
</value>
</data>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column9.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column10.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column11.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column7.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column6.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column8.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata> </metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>

View File

@ -1,22 +1,19 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace EonaCat.HID.Analyzer namespace EonaCat.HID.Analyzer
{ {
static class Program internal static class Program
{ {
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
[STAThread] [STAThread]
static void Main() private static void Main()
{ {
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm()); Application.Run(new MainForm());
} }
} }
} }

View File

@ -1,12 +1,11 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("USB HID Analyzer")] [assembly: AssemblyTitle("USB HID Analyzer")]
[assembly: AssemblyDescription("A Windows utility tool for analyzing USB HID class devices")] [assembly: AssemblyDescription("HID Devices")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("EonaCat (Jeroen Saey)")] [assembly: AssemblyCompany("EonaCat (Jeroen Saey)")]
[assembly: AssemblyProduct("USB HID Analyzer")] [assembly: AssemblyProduct("USB HID Analyzer")]
@ -14,23 +13,23 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("EonaCat (Jeroen Saey)")] [assembly: AssemblyTrademark("EonaCat (Jeroen Saey)")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM // The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3634ad68-775e-40fb-9ef9-c064ad87a0f7")] [assembly: Guid("185412ac-91cc-4e99-9a8e-dd2af6b817ba")]
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -8,7 +8,7 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace USB_HID_Analyzer.Properties { namespace EonaCat.HID.Properties {
using System; using System;
@ -39,7 +39,7 @@ namespace USB_HID_Analyzer.Properties {
internal static global::System.Resources.ResourceManager ResourceManager { internal static global::System.Resources.ResourceManager ResourceManager {
get { get {
if (object.ReferenceEquals(resourceMan, null)) { if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("USB_HID_Analyzer.Properties.Resources", typeof(Resources).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EonaCat.HID.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;

View File

@ -8,11 +8,11 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace USB_HID_Analyzer.Properties { namespace EonaCat.HID.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));

View File

@ -31,26 +31,26 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.textBoxWriteData = new System.Windows.Forms.TextBox(); this.textBoxWriteData = new System.Windows.Forms.TextBox();
this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.newToolStripButton = new System.Windows.Forms.ToolStripButton();
this.openToolStripButton = new System.Windows.Forms.ToolStripButton();
this.saveToolStripButton = new System.Windows.Forms.ToolStripButton();
this.printToolStripButton = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator = new System.Windows.Forms.ToolStripSeparator();
this.toolStripButtonReload = new System.Windows.Forms.ToolStripButton(); this.toolStripButtonReload = new System.Windows.Forms.ToolStripButton();
this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
this.toolStripTextBoxVidPid = new System.Windows.Forms.ToolStripTextBox();
this.toolStripButtonFilter = new System.Windows.Forms.ToolStripButton();
this.toolStripButtonOpen = new System.Windows.Forms.ToolStripButton(); this.toolStripButtonOpen = new System.Windows.Forms.ToolStripButton();
this.toolStripButtonClear = new System.Windows.Forms.ToolStripButton(); this.toolStripButtonClear = new System.Windows.Forms.ToolStripButton();
this.aboutToolStripButton = new System.Windows.Forms.ToolStripButton(); this.toolStripButtonFilter = new System.Windows.Forms.ToolStripButton();
this.toolStripTextBoxVidPid = new System.Windows.Forms.ToolStripTextBox();
this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -67,17 +67,6 @@
this.rtbEventLog = new System.Windows.Forms.RichTextBox(); this.rtbEventLog = new System.Windows.Forms.RichTextBox();
this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout();
this.toolStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout();
@ -104,15 +93,13 @@
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column1, this.Column1,
this.Column2,
this.Column9, this.Column9,
this.Column10, this.Column10,
this.Column11, this.Column11,
this.Column7, this.Column7,
this.Column4, this.Column4,
this.Column5, this.Column5,
this.Column6, this.Column2,
this.Column3,
this.Column8}); this.Column8});
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.Location = new System.Drawing.Point(3, 16); this.dataGridView1.Location = new System.Drawing.Point(3, 16);
@ -120,9 +107,73 @@
this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.ReadOnly = true; this.dataGridView1.ReadOnly = true;
this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridView1.Size = new System.Drawing.Size(732, 214); this.dataGridView1.Size = new System.Drawing.Size(822, 286);
this.dataGridView1.TabIndex = 0; this.dataGridView1.TabIndex = 0;
this.dataGridView1.SelectionChanged += new System.EventHandler(this.DataGridView1_SelectionChanged); this.dataGridView1.SelectionChanged += new System.EventHandler(this.DataGridView1_SelectionChanged);
this.dataGridView1.DoubleClick += new System.EventHandler(this.dataGridView1_DoubleClick);
//
// Column1
//
this.Column1.HeaderText = "No";
this.Column1.Name = "Column1";
this.Column1.ReadOnly = true;
this.Column1.Width = 87;
//
// Column9
//
this.Column9.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Column9.HeaderText = "Name";
this.Column9.Name = "Column9";
this.Column9.ReadOnly = true;
//
// Column10
//
this.Column10.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Column10.HeaderText = "Manufacturer";
this.Column10.Name = "Column10";
this.Column10.ReadOnly = true;
//
// Column11
//
this.Column11.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Column11.HeaderText = "SerialNo";
this.Column11.Name = "Column11";
this.Column11.ReadOnly = true;
//
// Column7
//
this.Column7.HeaderText = "InputReport";
this.Column7.Name = "Column7";
this.Column7.ReadOnly = true;
this.Column7.Width = 86;
//
// Column4
//
this.Column4.HeaderText = "OutputReport";
this.Column4.Name = "Column4";
this.Column4.ReadOnly = true;
this.Column4.Width = 87;
//
// Column5
//
this.Column5.HeaderText = "FeatureReport";
this.Column5.Name = "Column5";
this.Column5.ReadOnly = true;
this.Column5.Width = 86;
//
// Column2
//
this.Column2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Column2.HeaderText = "Info";
this.Column2.Name = "Column2";
this.Column2.ReadOnly = true;
//
// Column8
//
this.Column8.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Column8.HeaderText = "DevicePath";
this.Column8.Name = "Column8";
this.Column8.ReadOnly = true;
// //
// tableLayoutPanel1 // tableLayoutPanel1
// //
@ -144,66 +195,24 @@
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 48.18182F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 48.18182F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 51.81818F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 51.81818F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(744, 661); this.tableLayoutPanel1.Size = new System.Drawing.Size(834, 811);
this.tableLayoutPanel1.TabIndex = 18; this.tableLayoutPanel1.TabIndex = 18;
// //
// toolStrip1 // toolStrip1
// //
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newToolStripButton,
this.openToolStripButton,
this.saveToolStripButton,
this.printToolStripButton,
this.toolStripSeparator, this.toolStripSeparator,
this.toolStripButtonReload, this.toolStripButtonReload,
this.toolStripLabel1,
this.toolStripTextBoxVidPid,
this.toolStripButtonFilter,
this.toolStripButtonOpen, this.toolStripButtonOpen,
this.toolStripButtonClear, this.toolStripButtonClear,
this.aboutToolStripButton}); this.toolStripButtonFilter,
this.toolStripTextBoxVidPid});
this.toolStrip1.Location = new System.Drawing.Point(0, 25); this.toolStrip1.Location = new System.Drawing.Point(0, 25);
this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(744, 25); this.toolStrip1.Size = new System.Drawing.Size(834, 25);
this.toolStrip1.TabIndex = 1; this.toolStrip1.TabIndex = 1;
this.toolStrip1.Text = "toolStrip1"; this.toolStrip1.Text = "toolStrip1";
// //
// newToolStripButton
//
this.newToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.newToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("newToolStripButton.Image")));
this.newToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.newToolStripButton.Name = "newToolStripButton";
this.newToolStripButton.Size = new System.Drawing.Size(23, 22);
this.newToolStripButton.Text = "&New";
//
// openToolStripButton
//
this.openToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.openToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("openToolStripButton.Image")));
this.openToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.openToolStripButton.Name = "openToolStripButton";
this.openToolStripButton.Size = new System.Drawing.Size(23, 22);
this.openToolStripButton.Text = "&Open";
//
// saveToolStripButton
//
this.saveToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.saveToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("saveToolStripButton.Image")));
this.saveToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.saveToolStripButton.Name = "saveToolStripButton";
this.saveToolStripButton.Size = new System.Drawing.Size(23, 22);
this.saveToolStripButton.Text = "&Save";
//
// printToolStripButton
//
this.printToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.printToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("printToolStripButton.Image")));
this.printToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.printToolStripButton.Name = "printToolStripButton";
this.printToolStripButton.Size = new System.Drawing.Size(23, 22);
this.printToolStripButton.Text = "&Print";
//
// toolStripSeparator // toolStripSeparator
// //
this.toolStripSeparator.Name = "toolStripSeparator"; this.toolStripSeparator.Name = "toolStripSeparator";
@ -218,30 +227,6 @@
this.toolStripButtonReload.Text = "Reload"; this.toolStripButtonReload.Text = "Reload";
this.toolStripButtonReload.Click += new System.EventHandler(this.ToolStripButtonReload_Click); this.toolStripButtonReload.Click += new System.EventHandler(this.ToolStripButtonReload_Click);
// //
// toolStripLabel1
//
this.toolStripLabel1.Name = "toolStripLabel1";
this.toolStripLabel1.Size = new System.Drawing.Size(33, 22);
this.toolStripLabel1.Text = "Filter";
//
// toolStripTextBoxVidPid
//
this.toolStripTextBoxVidPid.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.toolStripTextBoxVidPid.Font = new System.Drawing.Font("Segoe UI", 9F);
this.toolStripTextBoxVidPid.Name = "toolStripTextBoxVidPid";
this.toolStripTextBoxVidPid.Size = new System.Drawing.Size(100, 25);
this.toolStripTextBoxVidPid.Text = "0483:0400";
this.toolStripTextBoxVidPid.TextBoxTextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// toolStripButtonFilter
//
this.toolStripButtonFilter.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonFilter.Image")));
this.toolStripButtonFilter.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButtonFilter.Name = "toolStripButtonFilter";
this.toolStripButtonFilter.Size = new System.Drawing.Size(53, 22);
this.toolStripButtonFilter.Text = "Filter";
this.toolStripButtonFilter.Click += new System.EventHandler(this.ToolStripButtonFilter_Click);
//
// toolStripButtonOpen // toolStripButtonOpen
// //
this.toolStripButtonOpen.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonOpen.Image"))); this.toolStripButtonOpen.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonOpen.Image")));
@ -260,15 +245,25 @@
this.toolStripButtonClear.Text = "Clear"; this.toolStripButtonClear.Text = "Clear";
this.toolStripButtonClear.Click += new System.EventHandler(this.ToolStripButtonClear_Click); this.toolStripButtonClear.Click += new System.EventHandler(this.ToolStripButtonClear_Click);
// //
// aboutToolStripButton // toolStripButtonFilter
// //
this.aboutToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("aboutToolStripButton.Image"))); this.toolStripButtonFilter.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.aboutToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButtonFilter.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonFilter.Image")));
this.aboutToolStripButton.Name = "aboutToolStripButton"; this.toolStripButtonFilter.ImageTransparentColor = System.Drawing.Color.Magenta;
this.aboutToolStripButton.Size = new System.Drawing.Size(60, 22); this.toolStripButtonFilter.Name = "toolStripButtonFilter";
this.aboutToolStripButton.Text = "&About"; this.toolStripButtonFilter.Size = new System.Drawing.Size(53, 22);
this.aboutToolStripButton.ToolTipText = "About"; this.toolStripButtonFilter.Text = "Filter";
this.aboutToolStripButton.Click += new System.EventHandler(this.HelpToolStripButton_Click); this.toolStripButtonFilter.Click += new System.EventHandler(this.ToolStripButtonFilter_Click);
//
// toolStripTextBoxVidPid
//
this.toolStripTextBoxVidPid.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.toolStripTextBoxVidPid.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.toolStripTextBoxVidPid.Font = new System.Drawing.Font("Segoe UI", 9F);
this.toolStripTextBoxVidPid.Name = "toolStripTextBoxVidPid";
this.toolStripTextBoxVidPid.Size = new System.Drawing.Size(100, 25);
this.toolStripTextBoxVidPid.Text = "0483:0400";
this.toolStripTextBoxVidPid.TextBoxTextAlign = System.Windows.Forms.HorizontalAlignment.Center;
// //
// menuStrip1 // menuStrip1
// //
@ -277,7 +272,7 @@
this.helpToolStripMenuItem}); this.helpToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(744, 24); this.menuStrip1.Size = new System.Drawing.Size(834, 24);
this.menuStrip1.TabIndex = 0; this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1"; this.menuStrip1.Text = "menuStrip1";
// //
@ -285,9 +280,6 @@
// //
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newToolStripMenuItem, this.newToolStripMenuItem,
this.openToolStripMenuItem,
this.saveToolStripMenuItem,
this.toolStripSeparator2,
this.exitToolStripMenuItem}); this.exitToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
@ -299,37 +291,14 @@
this.newToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; this.newToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta;
this.newToolStripMenuItem.Name = "newToolStripMenuItem"; this.newToolStripMenuItem.Name = "newToolStripMenuItem";
this.newToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N))); this.newToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N)));
this.newToolStripMenuItem.Size = new System.Drawing.Size(146, 22); this.newToolStripMenuItem.Size = new System.Drawing.Size(141, 22);
this.newToolStripMenuItem.Text = "&New"; this.newToolStripMenuItem.Text = "&New";
this.newToolStripMenuItem.Click += new System.EventHandler(this.NewToolStripMenuItem_Click); this.newToolStripMenuItem.Click += new System.EventHandler(this.NewToolStripMenuItem_Click);
// //
// openToolStripMenuItem
//
this.openToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("openToolStripMenuItem.Image")));
this.openToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta;
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
this.openToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
this.openToolStripMenuItem.Text = "&Open";
//
// saveToolStripMenuItem
//
this.saveToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("saveToolStripMenuItem.Image")));
this.saveToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta;
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.saveToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
this.saveToolStripMenuItem.Text = "&Save";
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(143, 6);
//
// exitToolStripMenuItem // exitToolStripMenuItem
// //
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(146, 22); this.exitToolStripMenuItem.Size = new System.Drawing.Size(141, 22);
this.exitToolStripMenuItem.Text = "E&xit"; this.exitToolStripMenuItem.Text = "E&xit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.ExitToolStripMenuItem_Click); this.exitToolStripMenuItem.Click += new System.EventHandler(this.ExitToolStripMenuItem_Click);
// //
@ -361,10 +330,10 @@
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox1.Location = new System.Drawing.Point(3, 53); this.groupBox1.Location = new System.Drawing.Point(3, 53);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(738, 83); this.groupBox1.Size = new System.Drawing.Size(828, 83);
this.groupBox1.TabIndex = 2; this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "Read/Write Operation"; this.groupBox1.Text = "Read/Write Operations";
// //
// comboBoxReportId // comboBoxReportId
// //
@ -375,7 +344,22 @@
"2", "2",
"3", "3",
"4", "4",
"5"}); "5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20"});
this.comboBoxReportId.Location = new System.Drawing.Point(104, 19); this.comboBoxReportId.Location = new System.Drawing.Point(104, 19);
this.comboBoxReportId.Name = "comboBoxReportId"; this.comboBoxReportId.Name = "comboBoxReportId";
this.comboBoxReportId.Size = new System.Drawing.Size(81, 21); this.comboBoxReportId.Size = new System.Drawing.Size(81, 21);
@ -394,11 +378,11 @@
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(10, 50); this.label1.Location = new System.Drawing.Point(40, 48);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(84, 13); this.label1.Size = new System.Drawing.Size(58, 13);
this.label1.TabIndex = 7; this.label1.TabIndex = 7;
this.label1.Text = "Write Data 0x [ ]"; this.label1.Text = "Write Data";
// //
// buttonWriteFeature // buttonWriteFeature
// //
@ -446,21 +430,21 @@
this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox2.Location = new System.Drawing.Point(3, 142); this.groupBox2.Location = new System.Drawing.Point(3, 142);
this.groupBox2.Name = "groupBox2"; this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(738, 233); this.groupBox2.Size = new System.Drawing.Size(828, 305);
this.groupBox2.TabIndex = 3; this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false; this.groupBox2.TabStop = false;
this.groupBox2.Text = "Device List"; this.groupBox2.Text = "Devices";
// //
// groupBox3 // groupBox3
// //
this.groupBox3.Controls.Add(this.rtbEventLog); this.groupBox3.Controls.Add(this.rtbEventLog);
this.groupBox3.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBox3.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox3.Location = new System.Drawing.Point(3, 381); this.groupBox3.Location = new System.Drawing.Point(3, 453);
this.groupBox3.Name = "groupBox3"; this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(738, 251); this.groupBox3.Size = new System.Drawing.Size(828, 329);
this.groupBox3.TabIndex = 4; this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false; this.groupBox3.TabStop = false;
this.groupBox3.Text = "Event Log"; this.groupBox3.Text = "Log";
// //
// rtbEventLog // rtbEventLog
// //
@ -468,7 +452,7 @@
this.rtbEventLog.Location = new System.Drawing.Point(3, 16); this.rtbEventLog.Location = new System.Drawing.Point(3, 16);
this.rtbEventLog.Name = "rtbEventLog"; this.rtbEventLog.Name = "rtbEventLog";
this.rtbEventLog.ReadOnly = true; this.rtbEventLog.ReadOnly = true;
this.rtbEventLog.Size = new System.Drawing.Size(732, 232); this.rtbEventLog.Size = new System.Drawing.Size(822, 310);
this.rtbEventLog.TabIndex = 0; this.rtbEventLog.TabIndex = 0;
this.rtbEventLog.Text = ""; this.rtbEventLog.Text = "";
// //
@ -476,9 +460,9 @@
// //
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1}); this.toolStripStatusLabel1});
this.statusStrip1.Location = new System.Drawing.Point(0, 639); this.statusStrip1.Location = new System.Drawing.Point(0, 789);
this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(744, 22); this.statusStrip1.Size = new System.Drawing.Size(834, 22);
this.statusStrip1.TabIndex = 5; this.statusStrip1.TabIndex = 5;
this.statusStrip1.Text = "statusStrip1"; this.statusStrip1.Text = "statusStrip1";
// //
@ -488,88 +472,11 @@
this.toolStripStatusLabel1.Size = new System.Drawing.Size(118, 17); this.toolStripStatusLabel1.Size = new System.Drawing.Size(118, 17);
this.toolStripStatusLabel1.Text = "toolStripStatusLabel1"; this.toolStripStatusLabel1.Text = "toolStripStatusLabel1";
// //
// Column1
//
this.Column1.HeaderText = "No";
this.Column1.Name = "Column1";
this.Column1.ReadOnly = true;
this.Column1.Width = 30;
//
// Column2
//
this.Column2.HeaderText = "Info";
this.Column2.Name = "Column2";
this.Column2.ReadOnly = true;
this.Column2.Width = 180;
//
// Column9
//
this.Column9.HeaderText = "Name";
this.Column9.Name = "Column9";
this.Column9.ReadOnly = true;
this.Column9.Width = 160;
//
// Column10
//
this.Column10.HeaderText = "Manufacturer";
this.Column10.Name = "Column10";
this.Column10.ReadOnly = true;
this.Column10.Width = 110;
//
// Column11
//
this.Column11.HeaderText = "SerialNo";
this.Column11.Name = "Column11";
this.Column11.ReadOnly = true;
this.Column11.Width = 85;
//
// Column7
//
this.Column7.HeaderText = "InputReport";
this.Column7.Name = "Column7";
this.Column7.ReadOnly = true;
this.Column7.Width = 40;
//
// Column4
//
this.Column4.HeaderText = "OutputReport";
this.Column4.Name = "Column4";
this.Column4.ReadOnly = true;
this.Column4.Width = 40;
//
// Column5
//
this.Column5.HeaderText = "FeatureReport";
this.Column5.Name = "Column5";
this.Column5.ReadOnly = true;
this.Column5.Width = 40;
//
// Column6
//
this.Column6.HeaderText = "Usage";
this.Column6.Name = "Column6";
this.Column6.ReadOnly = true;
this.Column6.Width = 50;
//
// Column3
//
this.Column3.HeaderText = "UsagePage";
this.Column3.Name = "Column3";
this.Column3.ReadOnly = true;
this.Column3.Width = 55;
//
// Column8
//
this.Column8.HeaderText = "DevicePath";
this.Column8.Name = "Column8";
this.Column8.ReadOnly = true;
this.Column8.Width = 550;
//
// MainForm // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(744, 661); this.ClientSize = new System.Drawing.Size(834, 811);
this.Controls.Add(this.tableLayoutPanel1); this.Controls.Add(this.tableLayoutPanel1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip1; this.MainMenuStrip = this.menuStrip1;
@ -602,17 +509,10 @@
private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
private System.Windows.Forms.ToolStrip toolStrip1; private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripLabel toolStripLabel1;
private System.Windows.Forms.ToolStripTextBox toolStripTextBoxVidPid;
private System.Windows.Forms.ToolStripButton toolStripButtonFilter;
private System.Windows.Forms.ToolStripButton aboutToolStripButton;
private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox3; private System.Windows.Forms.GroupBox groupBox3;
@ -621,10 +521,6 @@
private System.Windows.Forms.RichTextBox rtbEventLog; private System.Windows.Forms.RichTextBox rtbEventLog;
private System.Windows.Forms.ToolStripButton toolStripButtonClear; private System.Windows.Forms.ToolStripButton toolStripButtonClear;
private System.Windows.Forms.ToolStripButton toolStripButtonOpen; private System.Windows.Forms.ToolStripButton toolStripButtonOpen;
private System.Windows.Forms.ToolStripButton newToolStripButton;
private System.Windows.Forms.ToolStripButton openToolStripButton;
private System.Windows.Forms.ToolStripButton saveToolStripButton;
private System.Windows.Forms.ToolStripButton printToolStripButton;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator; private System.Windows.Forms.ToolStripSeparator toolStripSeparator;
private System.Windows.Forms.Button buttonWriteFeature; private System.Windows.Forms.Button buttonWriteFeature;
private System.Windows.Forms.Button buttonReadFeature; private System.Windows.Forms.Button buttonReadFeature;
@ -634,16 +530,16 @@
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox comboBoxReportId; private System.Windows.Forms.ComboBox comboBoxReportId;
private System.Windows.Forms.ToolStripButton toolStripButtonReload; private System.Windows.Forms.ToolStripButton toolStripButtonReload;
private System.Windows.Forms.ToolStripTextBox toolStripTextBoxVidPid;
private System.Windows.Forms.ToolStripButton toolStripButtonFilter;
private System.Windows.Forms.DataGridViewTextBoxColumn Column1; private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
private System.Windows.Forms.DataGridViewTextBoxColumn Column9; private System.Windows.Forms.DataGridViewTextBoxColumn Column9;
private System.Windows.Forms.DataGridViewTextBoxColumn Column10; private System.Windows.Forms.DataGridViewTextBoxColumn Column10;
private System.Windows.Forms.DataGridViewTextBoxColumn Column11; private System.Windows.Forms.DataGridViewTextBoxColumn Column11;
private System.Windows.Forms.DataGridViewTextBoxColumn Column7; private System.Windows.Forms.DataGridViewTextBoxColumn Column7;
private System.Windows.Forms.DataGridViewTextBoxColumn Column4; private System.Windows.Forms.DataGridViewTextBoxColumn Column4;
private System.Windows.Forms.DataGridViewTextBoxColumn Column5; private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
private System.Windows.Forms.DataGridViewTextBoxColumn Column6; private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
private System.Windows.Forms.DataGridViewTextBoxColumn Column8; private System.Windows.Forms.DataGridViewTextBoxColumn Column8;
} }
} }

View File

@ -21,4 +21,4 @@
public string VendorIdHex { get; set; } public string VendorIdHex { get; set; }
public string ProductIdHex { get; set; } public string ProductIdHex { get; set; }
} }
} }

View File

@ -41,4 +41,4 @@
public short NumberFeatureValueCaps { get; private set; } public short NumberFeatureValueCaps { get; private set; }
public short NumberFeatureDataIndices { get; private set; } public short NumberFeatureDataIndices { get; private set; }
} }
} }

View File

@ -11,24 +11,25 @@ namespace EonaCat.HID
public class Device : IDevice public class Device : IDevice
{ {
public event InsertedEventHandler OnInserted; public event InsertedEventHandler OnInserted;
public event RemovedEventHandler OnRemoved; public event RemovedEventHandler OnRemoved;
private const int _byteSize = 254; private const int BUFFER_SIZE = 254;
private readonly string _description; private readonly string _description;
private readonly string _path; private readonly string _path;
private readonly Attributes _attributes; private readonly Attributes _attributes;
private readonly Capabilities _capabilities; private readonly Capabilities _capabilities;
private DeviceMode _readMode = DeviceMode.NonOverlapped;
private DeviceMode _writeMode = DeviceMode.NonOverlapped;
private ShareMode _shareMode = ShareMode.ShareRead | ShareMode.ShareWrite;
private readonly DeviceEventMonitor _deviceEventMonitor; private readonly DeviceEventMonitor _deviceEventMonitor;
private bool _monitorDeviceEvents; private bool _monitorDeviceEvents;
protected delegate DeviceData ReadDelegate(int timeout); protected delegate DeviceData ReadDelegate(int timeout);
protected delegate Report ReadReportDelegate(int timeout); protected delegate Report ReadReportDelegate(int timeout);
private delegate bool WriteDelegate(byte[] data, int timeout); private delegate bool WriteDelegate(byte[] data, int timeout);
private delegate bool WriteReportDelegate(Report report, int timeout); private delegate bool WriteReportDelegate(Report report, int timeout);
internal Device(string devicePath, string description = null) internal Device(string devicePath, string description = null)
@ -42,10 +43,11 @@ namespace EonaCat.HID
try try
{ {
_deviceModeHelper = new DeviceModeHelper();
var handle = OpenDeviceIO(_path, NativeMethods.ACCESS_NONE); var handle = OpenDeviceIO(_path, NativeMethods.ACCESS_NONE);
_attributes = GetDeviceAttributes(handle); _attributes = GetDeviceAttributes(handle);
_capabilities = GetDeviceCapabilities(handle); _capabilities = GetDeviceCapabilities(handle);
CloseDeviceIO(handle); CloseDeviceIO(handle);
} }
catch (Exception exception) catch (Exception exception)
@ -54,21 +56,24 @@ namespace EonaCat.HID
} }
} }
public IntPtr ReadHandle { get; private set; }
public IntPtr WriteHandle { get; private set; }
public bool IsOpen { get; private set; } public bool IsOpen { get; private set; }
public bool IsConnected { get { return Devices.IsConnected(_path); } } public bool IsConnected
public string Description { get { return _description; } } { get { return Devices.IsConnected(_path); } }
public Capabilities Capabilities { get { return _capabilities; } } public string Description
public Attributes Info { get { return _attributes; } } { get { return _description; } }
public string DevicePath { get { return _path; } } public Capabilities Capabilities
{ get { return _capabilities; } }
public Attributes Info
{ get { return _attributes; } }
public string DevicePath
{ get { return _path; } }
public bool MonitorDeviceEvents public bool MonitorDeviceEvents
{ {
get { return _monitorDeviceEvents; } get { return _monitorDeviceEvents; }
set set
{ {
if (value & _monitorDeviceEvents == false) if (value & !_monitorDeviceEvents)
{ {
_deviceEventMonitor.Init(); _deviceEventMonitor.Init();
} }
@ -77,6 +82,8 @@ namespace EonaCat.HID
} }
} }
private DeviceModeHelper _deviceModeHelper { get; }
public override string ToString() public override string ToString()
{ {
return $"VendorID={_attributes.VendorIdHex}, ProductID={_attributes.ProductIdHex}, Version={_attributes.Version}, DevicePath={_path}"; return $"VendorID={_attributes.VendorIdHex}, ProductID={_attributes.ProductIdHex}, Version={_attributes.Version}, DevicePath={_path}";
@ -94,14 +101,14 @@ namespace EonaCat.HID
return; return;
} }
_readMode = readMode; _deviceModeHelper.ReadMode = readMode;
_writeMode = writeMode; _deviceModeHelper.WriteMode = writeMode;
_shareMode = shareMode; _deviceModeHelper.ShareMode = shareMode;
try try
{ {
ReadHandle = OpenDeviceIO(_path, readMode, NativeMethods.GENERIC_READ, shareMode); _deviceModeHelper.ReadHandle = OpenDeviceIO(_path, readMode, NativeMethods.GENERIC_READ, shareMode);
WriteHandle = OpenDeviceIO(_path, writeMode, NativeMethods.GENERIC_WRITE, shareMode); _deviceModeHelper.WriteHandle = OpenDeviceIO(_path, writeMode, NativeMethods.GENERIC_WRITE, shareMode);
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -109,10 +116,9 @@ namespace EonaCat.HID
throw new Exception("EonaCat HID: Error opening device.", exception); throw new Exception("EonaCat HID: Error opening device.", exception);
} }
IsOpen = (ReadHandle.ToInt32() != NativeMethods.INVALID_HANDLE_VALUE && WriteHandle.ToInt32() != NativeMethods.INVALID_HANDLE_VALUE); IsOpen = (_deviceModeHelper.ReadHandle.ToInt32() != NativeMethods.INVALID_HANDLE_VALUE && _deviceModeHelper.WriteHandle.ToInt32() != NativeMethods.INVALID_HANDLE_VALUE);
} }
public void CloseDevice() public void CloseDevice()
{ {
if (!IsOpen) if (!IsOpen)
@ -120,8 +126,8 @@ namespace EonaCat.HID
return; return;
} }
CloseDeviceIO(ReadHandle); CloseDeviceIO(_deviceModeHelper.ReadHandle);
CloseDeviceIO(WriteHandle); CloseDeviceIO(_deviceModeHelper.WriteHandle);
IsOpen = false; IsOpen = false;
} }
@ -134,9 +140,9 @@ namespace EonaCat.HID
{ {
if (IsConnected) if (IsConnected)
{ {
if (IsOpen == false) if (!IsOpen)
{ {
OpenDevice(_readMode, _writeMode, _shareMode); OpenDevice(_deviceModeHelper.ReadMode, _deviceModeHelper.WriteMode, _deviceModeHelper.ShareMode);
} }
try try
@ -147,7 +153,6 @@ namespace EonaCat.HID
{ {
return new DeviceData(DeviceData.ReadStatus.ReadError); return new DeviceData(DeviceData.ReadStatus.ReadError);
} }
} }
return new DeviceData(DeviceData.ReadStatus.NotConnected); return new DeviceData(DeviceData.ReadStatus.NotConnected);
} }
@ -200,7 +205,7 @@ namespace EonaCat.HID
{ {
byte[] commandBuffer = new byte[Capabilities.InputReportByteLength]; byte[] commandBuffer = new byte[Capabilities.InputReportByteLength];
commandBuffer[0] = reportId; commandBuffer[0] = reportId;
bool bSuccess = NativeMethods.HidD_GetInputReport(ReadHandle, commandBuffer, commandBuffer.Length); bool bSuccess = NativeMethods.HidD_GetInputReport(_deviceModeHelper.ReadHandle, commandBuffer, commandBuffer.Length);
DeviceData deviceData = new DeviceData(commandBuffer, bSuccess ? DeviceData.ReadStatus.Success : DeviceData.ReadStatus.NoDataRead); DeviceData deviceData = new DeviceData(commandBuffer, bSuccess ? DeviceData.ReadStatus.Success : DeviceData.ReadStatus.NoDataRead);
return new Report(Capabilities.InputReportByteLength, deviceData); return new Report(Capabilities.InputReportByteLength, deviceData);
} }
@ -224,7 +229,7 @@ namespace EonaCat.HID
{ {
if (IsOpen) if (IsOpen)
{ {
hidHandle = ReadHandle; hidHandle = _deviceModeHelper.ReadHandle;
} }
else else
{ {
@ -244,7 +249,7 @@ namespace EonaCat.HID
} }
finally finally
{ {
if (hidHandle != IntPtr.Zero && hidHandle != ReadHandle) if (hidHandle != IntPtr.Zero && hidHandle != _deviceModeHelper.ReadHandle)
{ {
CloseDeviceIO(hidHandle); CloseDeviceIO(hidHandle);
} }
@ -255,7 +260,7 @@ namespace EonaCat.HID
public string ReadProductName() public string ReadProductName()
{ {
if (ReadProductName(out byte[] bytes)) if (ReadProductName(out byte[] bytes))
{ {
return ByteHelper.GetFilledBytesString(bytes); return ByteHelper.GetFilledBytesString(bytes);
} }
@ -264,14 +269,14 @@ namespace EonaCat.HID
public bool ReadProductName(out byte[] data) public bool ReadProductName(out byte[] data)
{ {
data = new byte[_byteSize]; data = new byte[BUFFER_SIZE];
IntPtr handle = IntPtr.Zero; IntPtr handle = IntPtr.Zero;
bool success = false; bool success = false;
try try
{ {
if (IsOpen) if (IsOpen)
{ {
handle = ReadHandle; handle = _deviceModeHelper.ReadHandle;
} }
else else
{ {
@ -286,7 +291,7 @@ namespace EonaCat.HID
} }
finally finally
{ {
if (handle != IntPtr.Zero && handle != ReadHandle) if (handle != IntPtr.Zero && handle != _deviceModeHelper.ReadHandle)
{ {
CloseDeviceIO(handle); CloseDeviceIO(handle);
} }
@ -306,14 +311,14 @@ namespace EonaCat.HID
public bool ReadManufacturer(out byte[] data) public bool ReadManufacturer(out byte[] data)
{ {
data = new byte[_byteSize]; data = new byte[BUFFER_SIZE];
IntPtr handle = IntPtr.Zero; IntPtr handle = IntPtr.Zero;
bool success = false; bool success = false;
try try
{ {
if (IsOpen) if (IsOpen)
{ {
handle = ReadHandle; handle = _deviceModeHelper.ReadHandle;
} }
else else
{ {
@ -328,7 +333,7 @@ namespace EonaCat.HID
} }
finally finally
{ {
if (handle != IntPtr.Zero && handle != ReadHandle) if (handle != IntPtr.Zero && handle != _deviceModeHelper.ReadHandle)
{ {
CloseDeviceIO(handle); CloseDeviceIO(handle);
} }
@ -348,14 +353,14 @@ namespace EonaCat.HID
public bool ReadSerialNumber(out byte[] data) public bool ReadSerialNumber(out byte[] data)
{ {
data = new byte[_byteSize]; data = new byte[BUFFER_SIZE];
IntPtr hidHandle = IntPtr.Zero; IntPtr hidHandle = IntPtr.Zero;
bool success = false; bool success = false;
try try
{ {
if (IsOpen) if (IsOpen)
{ {
hidHandle = ReadHandle; hidHandle = _deviceModeHelper.ReadHandle;
} }
else else
{ {
@ -370,7 +375,7 @@ namespace EonaCat.HID
} }
finally finally
{ {
if (hidHandle != IntPtr.Zero && hidHandle != ReadHandle) if (hidHandle != IntPtr.Zero && hidHandle != _deviceModeHelper.ReadHandle)
{ {
CloseDeviceIO(hidHandle); CloseDeviceIO(hidHandle);
} }
@ -388,9 +393,9 @@ namespace EonaCat.HID
{ {
if (IsConnected) if (IsConnected)
{ {
if (IsOpen == false) if (!IsOpen)
{ {
OpenDevice(_readMode, _writeMode, _shareMode); OpenDevice(_deviceModeHelper.ReadMode, _deviceModeHelper.WriteMode, _deviceModeHelper.ShareMode);
} }
try try
@ -450,20 +455,19 @@ namespace EonaCat.HID
} }
/// <summary> /// <summary>
/// Handle data transfers on the control channel. /// Handle data transfers on the control channel.
/// This method places data on the control channel for devices /// This method places data on the control channel for devices
/// that do not support the interupt transfers /// that do not support the interupt transfers
/// </summary> /// </summary>
/// <param name="report">The outbound HID report</param> /// <param name="report">The outbound HID report</param>
/// <returns>The result of the tranfer request: true if successful otherwise false</returns> /// <returns>The result of the tranfer request: true if successful otherwise false</returns>
/// ///
public bool WriteReportSync(Report report) public bool WriteReportSync(Report report)
{ {
if (null != report) if (null != report)
{ {
byte[] buffer = report.GetBytes(); byte[] buffer = report.GetBytes();
return (NativeMethods.HidD_SetOutputReport(WriteHandle, buffer, buffer.Length)); return (NativeMethods.HidD_SetOutputReport(_deviceModeHelper.WriteHandle, buffer, buffer.Length));
} }
else else
{ {
@ -497,14 +501,13 @@ namespace EonaCat.HID
Array.Copy(data, 0, buffer, 0, Math.Min(data.Length, _capabilities.FeatureReportByteLength)); Array.Copy(data, 0, buffer, 0, Math.Min(data.Length, _capabilities.FeatureReportByteLength));
IntPtr hidHandle = IntPtr.Zero; IntPtr hidHandle = IntPtr.Zero;
bool success = false; bool success = false;
try try
{ {
if (IsOpen) if (IsOpen)
{ {
hidHandle = WriteHandle; hidHandle = _deviceModeHelper.WriteHandle;
} }
else else
{ {
@ -520,7 +523,7 @@ namespace EonaCat.HID
} }
finally finally
{ {
if (hidHandle != IntPtr.Zero && hidHandle != WriteHandle) if (hidHandle != IntPtr.Zero && hidHandle != _deviceModeHelper.WriteHandle)
{ {
CloseDeviceIO(hidHandle); CloseDeviceIO(hidHandle);
} }
@ -635,7 +638,7 @@ namespace EonaCat.HID
Array.Copy(data, 0, buffer, 0, Math.Min(data.Length, _capabilities.OutputReportByteLength)); Array.Copy(data, 0, buffer, 0, Math.Min(data.Length, _capabilities.OutputReportByteLength));
if (_writeMode == DeviceMode.Overlapped) if (_deviceModeHelper.WriteMode == DeviceMode.Overlapped)
{ {
var security = new NativeMethods.SECURITY_ATTRIBUTES(); var security = new NativeMethods.SECURITY_ATTRIBUTES();
var overlapped = new NativeOverlapped(); var overlapped = new NativeOverlapped();
@ -652,7 +655,7 @@ namespace EonaCat.HID
try try
{ {
NativeMethods.WriteFile(WriteHandle, buffer, (uint)buffer.Length, out bytesWritten, ref overlapped); NativeMethods.WriteFile(_deviceModeHelper.WriteHandle, buffer, (uint)buffer.Length, out bytesWritten, ref overlapped);
} }
catch { return false; } catch { return false; }
@ -662,10 +665,13 @@ namespace EonaCat.HID
{ {
case NativeMethods.WAIT_OBJECT_0: case NativeMethods.WAIT_OBJECT_0:
return true; return true;
case NativeMethods.WAIT_TIMEOUT: case NativeMethods.WAIT_TIMEOUT:
return false; return false;
case NativeMethods.WAIT_FAILED: case NativeMethods.WAIT_FAILED:
return false; return false;
default: default:
return false; return false;
} }
@ -675,7 +681,7 @@ namespace EonaCat.HID
try try
{ {
var overlapped = new NativeOverlapped(); var overlapped = new NativeOverlapped();
return NativeMethods.WriteFile(WriteHandle, buffer, (uint)buffer.Length, out bytesWritten, ref overlapped); return NativeMethods.WriteFile(_deviceModeHelper.WriteHandle, buffer, (uint)buffer.Length, out bytesWritten, ref overlapped);
} }
catch { return false; } catch { return false; }
} }
@ -694,7 +700,7 @@ namespace EonaCat.HID
buffer = CreateInputBuffer(); buffer = CreateInputBuffer();
nonManagedBuffer = Marshal.AllocHGlobal(buffer.Length); nonManagedBuffer = Marshal.AllocHGlobal(buffer.Length);
if (_readMode == DeviceMode.Overlapped) if (_deviceModeHelper.ReadMode == DeviceMode.Overlapped)
{ {
var security = new NativeMethods.SECURITY_ATTRIBUTES(); var security = new NativeMethods.SECURITY_ATTRIBUTES();
var overlapped = new NativeOverlapped(); var overlapped = new NativeOverlapped();
@ -710,9 +716,9 @@ namespace EonaCat.HID
try try
{ {
var success = NativeMethods.ReadFile(ReadHandle, nonManagedBuffer, (uint)buffer.Length, out bytesRead, ref overlapped); var success = NativeMethods.ReadFile(_deviceModeHelper.ReadHandle, nonManagedBuffer, (uint)buffer.Length, out bytesRead, ref overlapped);
if (success) if (success)
{ {
status = DeviceData.ReadStatus.Success; // No check here to see if bytesRead > 0 . Perhaps not necessary? status = DeviceData.ReadStatus.Success; // No check here to see if bytesRead > 0 . Perhaps not necessary?
} }
@ -720,20 +726,23 @@ namespace EonaCat.HID
{ {
var result = NativeMethods.WaitForSingleObject(overlapped.EventHandle, overlapTimeout); var result = NativeMethods.WaitForSingleObject(overlapped.EventHandle, overlapTimeout);
switch (result) switch (result)
{ {
case NativeMethods.WAIT_OBJECT_0: case NativeMethods.WAIT_OBJECT_0:
status = DeviceData.ReadStatus.Success; status = DeviceData.ReadStatus.Success;
NativeMethods.GetOverlappedResult(ReadHandle, ref overlapped, out bytesRead, false); NativeMethods.GetOverlappedResult(_deviceModeHelper.ReadHandle, ref overlapped, out bytesRead, false);
break; break;
case NativeMethods.WAIT_TIMEOUT: case NativeMethods.WAIT_TIMEOUT:
status = DeviceData.ReadStatus.WaitTimedOut; status = DeviceData.ReadStatus.WaitTimedOut;
buffer = new byte[] { }; buffer = new byte[] { };
break; break;
case NativeMethods.WAIT_FAILED:
case NativeMethods.WAIT_FAILED:
status = DeviceData.ReadStatus.WaitFail; status = DeviceData.ReadStatus.WaitFail;
buffer = new byte[] { }; buffer = new byte[] { };
break; break;
default: default:
status = DeviceData.ReadStatus.NoDataRead; status = DeviceData.ReadStatus.NoDataRead;
buffer = new byte[] { }; buffer = new byte[] { };
@ -743,7 +752,8 @@ namespace EonaCat.HID
Marshal.Copy(nonManagedBuffer, buffer, 0, (int)bytesRead); Marshal.Copy(nonManagedBuffer, buffer, 0, (int)bytesRead);
} }
catch { status = DeviceData.ReadStatus.ReadError; } catch { status = DeviceData.ReadStatus.ReadError; }
finally { finally
{
CloseDeviceIO(overlapped.EventHandle); CloseDeviceIO(overlapped.EventHandle);
Marshal.FreeHGlobal(nonManagedBuffer); Marshal.FreeHGlobal(nonManagedBuffer);
} }
@ -754,7 +764,7 @@ namespace EonaCat.HID
{ {
var overlapped = new NativeOverlapped(); var overlapped = new NativeOverlapped();
NativeMethods.ReadFile(ReadHandle, nonManagedBuffer, (uint)buffer.Length, out bytesRead, ref overlapped); NativeMethods.ReadFile(_deviceModeHelper.ReadHandle, nonManagedBuffer, (uint)buffer.Length, out bytesRead, ref overlapped);
status = DeviceData.ReadStatus.Success; status = DeviceData.ReadStatus.Success;
Marshal.Copy(nonManagedBuffer, buffer, 0, (int)bytesRead); Marshal.Copy(nonManagedBuffer, buffer, 0, (int)bytesRead);
} }
@ -800,7 +810,7 @@ namespace EonaCat.HID
{ {
if (!IsOpen) if (!IsOpen)
{ {
OpenDevice(_readMode, _writeMode, _shareMode); OpenDevice(_deviceModeHelper.ReadMode, _deviceModeHelper.WriteMode, _deviceModeHelper.ShareMode);
} }
OnInserted?.Invoke(); OnInserted?.Invoke();
@ -829,4 +839,4 @@ namespace EonaCat.HID
} }
} }
} }
} }

View File

@ -16,7 +16,7 @@
public DeviceData(ReadStatus status) public DeviceData(ReadStatus status)
{ {
Data = new byte[] {}; Data = new byte[] { };
Status = status; Status = status;
} }
@ -29,4 +29,4 @@
public byte[] Data { get; private set; } public byte[] Data { get; private set; }
public ReadStatus Status { get; private set; } public ReadStatus Status { get; private set; }
} }
} }

View File

@ -1,6 +1,4 @@
using System; using System.Threading.Tasks;
using System.Threading;
using System.Threading.Tasks;
namespace EonaCat.HID namespace EonaCat.HID
{ {
@ -9,9 +7,11 @@ namespace EonaCat.HID
internal class DeviceEventMonitor internal class DeviceEventMonitor
{ {
public event InsertedEventHandler Inserted; public event InsertedEventHandler Inserted;
public event RemovedEventHandler Removed; public event RemovedEventHandler Removed;
public delegate void InsertedEventHandler(); public delegate void InsertedEventHandler();
public delegate void RemovedEventHandler(); public delegate void RemovedEventHandler();
private readonly Device _device; private readonly Device _device;
@ -24,43 +24,31 @@ namespace EonaCat.HID
public void Init() public void Init()
{ {
#if NET20 || NET35 || NET5_0_OR_GREATER Task.Run(EventMonitor);
Task task = Task.Factory.StartNew(() => EventMonitor());
#else
var eventMonitor = new Action(EventMonitor);
eventMonitor.BeginInvoke(DisposeDeviceEventMonitor, eventMonitor);
#endif
} }
private void EventMonitor() private async Task EventMonitor()
{ {
var isConnected = _device.IsConnected; while (_device.MonitorDeviceEvents)
if (isConnected != _wasConnected)
{ {
if (isConnected && Inserted != null) var isConnected = _device.IsConnected;
if (isConnected != _wasConnected)
{ {
Inserted(); if (isConnected)
} {
else if (!isConnected && Removed != null) Inserted?.Invoke();
{ }
Removed(); else
{
Removed?.Invoke();
}
_wasConnected = isConnected;
} }
_wasConnected = isConnected; await Task.Delay(100);
} }
Thread.Sleep(500);
if (_device.MonitorDeviceEvents)
{
Init();
}
}
private static void DisposeDeviceEventMonitor(IAsyncResult ar)
{
((Action)ar.AsyncState).EndInvoke(ar);
} }
} }
} }

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -32,7 +31,7 @@ namespace EonaCat.HID
public static IEnumerable<Device> Enumerate(int vendorId, params int[] productIds) public static IEnumerable<Device> Enumerate(int vendorId, params int[] productIds)
{ {
return EnumerateDevices().Select(x => new Device(x.Path, x.Description)).Where(x => x.Info.VendorId == vendorId && return EnumerateDevices().Select(x => new Device(x.Path, x.Description)).Where(x => x.Info.VendorId == vendorId &&
productIds.Contains(x.Info.ProductId)); productIds.Contains(x.Info.ProductId));
} }
@ -41,7 +40,7 @@ namespace EonaCat.HID
return EnumerateDevices().Select(x => new Device(x.Path, x.Description)).Where(x => x.Info.VendorId == vendorId && return EnumerateDevices().Select(x => new Device(x.Path, x.Description)).Where(x => x.Info.VendorId == vendorId &&
productId == (ushort)x.Info.ProductId && (ushort)x.Capabilities.UsagePage == UsagePage); productId == (ushort)x.Info.ProductId && (ushort)x.Capabilities.UsagePage == UsagePage);
} }
public static IEnumerable<Device> Enumerate(int vendorId) public static IEnumerable<Device> Enumerate(int vendorId)
{ {
return EnumerateDevices().Select(x => new Device(x.Path, x.Description)).Where(x => x.Info.VendorId == vendorId); return EnumerateDevices().Select(x => new Device(x.Path, x.Description)).Where(x => x.Info.VendorId == vendorId);
@ -52,7 +51,8 @@ namespace EonaCat.HID
return EnumerateDevices().Select(x => new Device(x.Path, x.Description)).Where(x => (ushort)x.Capabilities.UsagePage == UsagePage); return EnumerateDevices().Select(x => new Device(x.Path, x.Description)).Where(x => (ushort)x.Capabilities.UsagePage == UsagePage);
} }
internal class DeviceInfo { public string Path { get; set; } public string Description { get; set; } } internal class DeviceInfo
{ public string Path { get; set; } public string Description { get; set; } }
internal static IEnumerable<DeviceInfo> EnumerateDevices() internal static IEnumerable<DeviceInfo> EnumerateDevices()
{ {
@ -106,7 +106,7 @@ namespace EonaCat.HID
NativeMethods.SetupDiGetDeviceInterfaceDetail(deviceInfoSet, ref deviceInterfaceData, IntPtr.Zero, 0, ref bufferSize, IntPtr.Zero); NativeMethods.SetupDiGetDeviceInterfaceDetail(deviceInfoSet, ref deviceInterfaceData, IntPtr.Zero, 0, ref bufferSize, IntPtr.Zero);
return NativeMethods.SetupDiGetDeviceInterfaceDetail(deviceInfoSet, ref deviceInterfaceData, ref interfaceDetail, bufferSize, ref bufferSize, IntPtr.Zero) ? return NativeMethods.SetupDiGetDeviceInterfaceDetail(deviceInfoSet, ref deviceInterfaceData, ref interfaceDetail, bufferSize, ref bufferSize, IntPtr.Zero) ?
interfaceDetail.DevicePath : null; interfaceDetail.DevicePath : null;
} }
@ -177,4 +177,4 @@ namespace EonaCat.HID
} }
} }
} }
} }

View File

@ -14,30 +14,27 @@ namespace EonaCat.HID
public IDevice GetDevice(string devicePath) public IDevice GetDevice(string devicePath)
{ {
return Devices.GetDevice(devicePath) as IDevice; return Devices.GetDevice(devicePath);
} }
public IEnumerable<IDevice> Enumerate() public IEnumerable<IDevice> Enumerate()
{ {
return Devices.Enumerate(). return Devices.Enumerate().Select(x => x as IDevice);
Select(d => d as IDevice);
} }
public IEnumerable<IDevice> Enumerate(string devicePath) public IEnumerable<IDevice> Enumerate(string devicePath)
{ {
return Devices.Enumerate(devicePath). return Devices.Enumerate(devicePath).Select(x => x as IDevice);
Select(d => d as IDevice);
} }
public IEnumerable<IDevice> Enumerate(int vendorId, params int[] productIds) public IEnumerable<IDevice> Enumerate(int vendorId, params int[] productIds)
{ {
return Devices.Enumerate(vendorId, productIds). return Devices.Enumerate(vendorId, productIds).Select(x => x as IDevice);
Select(d => d as IDevice);
} }
public IEnumerable<IDevice> Enumerate(int vendorId) public IEnumerable<IDevice> Enumerate(int vendorId)
{ {
return Devices.Enumerate(vendorId).Select(d => d as IDevice); return Devices.Enumerate(vendorId).Select(x => x as IDevice);
} }
} }
} }

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net20;net35;net40;net45;netstandard2</TargetFrameworks> <TargetFrameworks>net45;netstandard2</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Company>EonaCat (Jeroen Saey)</Company> <Company>EonaCat (Jeroen Saey)</Company>
<Copyright>Copyright 2024 EonaCat (Jeroen Saey)</Copyright> <Copyright>Copyright 2024 EonaCat (Jeroen Saey)</Copyright>
@ -30,11 +30,6 @@
<EVShowRevision>true</EVShowRevision> <EVShowRevision>true</EVShowRevision>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'net45' AND '$(TargetFramework)' != 'netstandard2' ">
<PackageReference Include="Theraot.Core" Version="1.0.3" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\icon.png"> <None Include="..\icon.png">
<Pack>True</Pack> <Pack>True</Pack>

View File

@ -4,6 +4,9 @@ using System.Text;
namespace EonaCat.HID.Helpers namespace EonaCat.HID.Helpers
{ {
// This file is part of the EonaCat project(s) which is released under the Apache License.
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
public static class ByteHelper public static class ByteHelper
{ {
public static string ByteArrayToHexString(byte[] bytes, string separator = "") public static string ByteArrayToHexString(byte[] bytes, string separator = "")
@ -29,4 +32,4 @@ namespace EonaCat.HID.Helpers
return new string(buffer, 0, index >= 0 ? index : buffer.Length); return new string(buffer, 0, index >= 0 ? index : buffer.Length);
} }
} }
} }

View File

@ -0,0 +1,13 @@
using System;
namespace EonaCat.HID.Helpers
{
internal class DeviceModeHelper
{
public IntPtr ReadHandle { get; set; }
public IntPtr WriteHandle { get; set; }
public DeviceMode ReadMode { get; set; } = DeviceMode.NonOverlapped;
public DeviceMode WriteMode { get; set; } = DeviceMode.NonOverlapped;
public ShareMode ShareMode = ShareMode.ShareRead | ShareMode.ShareWrite;
}
}

View File

@ -7,6 +7,7 @@ namespace EonaCat.HID
// See the LICENSE file or go to https://EonaCat.com/License for full license details. // See the LICENSE file or go to https://EonaCat.com/License for full license details.
public delegate void InsertedEventHandler(); public delegate void InsertedEventHandler();
public delegate void RemovedEventHandler(); public delegate void RemovedEventHandler();
public enum DeviceMode public enum DeviceMode
@ -24,21 +25,22 @@ namespace EonaCat.HID
} }
public delegate void ReadCallback(DeviceData data); public delegate void ReadCallback(DeviceData data);
public delegate void ReadReportCallback(Report report); public delegate void ReadReportCallback(Report report);
public delegate void WriteCallback(bool success); public delegate void WriteCallback(bool success);
public interface IDevice : IDisposable public interface IDevice : IDisposable
{ {
event InsertedEventHandler OnInserted; event InsertedEventHandler OnInserted;
event RemovedEventHandler OnRemoved; event RemovedEventHandler OnRemoved;
IntPtr ReadHandle { get; }
IntPtr WriteHandle { get; }
bool IsOpen { get; } bool IsOpen { get; }
bool IsConnected { get; } bool IsConnected { get; }
string Description { get; } string Description { get; }
Capabilities Capabilities { get; } Capabilities Capabilities { get; }
Attributes Info { get; } Attributes Info { get; }
string DevicePath { get; } string DevicePath { get; }
bool MonitorDeviceEvents { get; set; } bool MonitorDeviceEvents { get; set; }
@ -62,6 +64,7 @@ namespace EonaCat.HID
Task<Report> ReadReportAsync(int timeout = 0); Task<Report> ReadReportAsync(int timeout = 0);
Report ReadReport(int timeout = 0); Report ReadReport(int timeout = 0);
bool ReadFeatureData(out byte[] data, byte reportId = 0); bool ReadFeatureData(out byte[] data, byte reportId = 0);
bool ReadProductName(out byte[] data); bool ReadProductName(out byte[] data);
@ -94,4 +97,4 @@ namespace EonaCat.HID
bool WriteFeatureData(byte[] data); bool WriteFeatureData(byte[] data);
} }
} }

View File

@ -1,6 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
namespace EonaCat.HID namespace EonaCat.HID
{ {
@ -9,10 +7,15 @@ namespace EonaCat.HID
public interface IEnumerator public interface IEnumerator
{ {
bool IsConnected(string devicePath); bool IsConnected(string devicePath);
IDevice GetDevice(string devicePath); IDevice GetDevice(string devicePath);
IEnumerable<IDevice> Enumerate(); IEnumerable<IDevice> Enumerate();
IEnumerable<IDevice> Enumerate(string devicePath); IEnumerable<IDevice> Enumerate(string devicePath);
IEnumerable<IDevice> Enumerate(int vendorId, params int[] productIds); IEnumerable<IDevice> Enumerate(int vendorId, params int[] productIds);
IEnumerable<IDevice> Enumerate(int vendorId); IEnumerable<IDevice> Enumerate(int vendorId);
} }
} }

View File

@ -33,28 +33,28 @@ namespace EonaCat.HID
} }
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)] [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
static internal extern bool CancelIoEx(IntPtr hFile, IntPtr lpOverlapped); internal static extern bool CancelIoEx(IntPtr hFile, IntPtr lpOverlapped);
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)] [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
static internal extern bool CloseHandle(IntPtr hObject); internal static extern bool CloseHandle(IntPtr hObject);
[DllImport("kernel32.dll")] [DllImport("kernel32.dll")]
static internal extern IntPtr CreateEvent(ref SECURITY_ATTRIBUTES securityAttributes, int bManualReset, int bInitialState, string lpName); internal static extern IntPtr CreateEvent(ref SECURITY_ATTRIBUTES securityAttributes, int bManualReset, int bInitialState, string lpName);
[DllImport("kernel32.dll", SetLastError = true)] [DllImport("kernel32.dll", SetLastError = true)]
static internal extern IntPtr CreateFile(string lpFileName, uint dwDesiredAccess, int dwShareMode, ref SECURITY_ATTRIBUTES lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile); internal static extern IntPtr CreateFile(string lpFileName, uint dwDesiredAccess, int dwShareMode, ref SECURITY_ATTRIBUTES lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile);
[DllImport("kernel32.dll", SetLastError = true)] [DllImport("kernel32.dll", SetLastError = true)]
static internal extern bool ReadFile(IntPtr hFile, IntPtr lpBuffer, uint nNumberOfBytesToRead, out uint lpNumberOfBytesRead, [In] ref System.Threading.NativeOverlapped lpOverlapped); internal static extern bool ReadFile(IntPtr hFile, IntPtr lpBuffer, uint nNumberOfBytesToRead, out uint lpNumberOfBytesRead, [In] ref System.Threading.NativeOverlapped lpOverlapped);
[DllImport("kernel32.dll")] [DllImport("kernel32.dll")]
static internal extern uint WaitForSingleObject(IntPtr hHandle, int dwMilliseconds); internal static extern uint WaitForSingleObject(IntPtr hHandle, int dwMilliseconds);
[DllImport("kernel32.dll", SetLastError = true)] [DllImport("kernel32.dll", SetLastError = true)]
static internal extern bool GetOverlappedResult(IntPtr hFile, [In] ref System.Threading.NativeOverlapped lpOverlapped, out uint lpNumberOfBytesTransferred, bool bWait); internal static extern bool GetOverlappedResult(IntPtr hFile, [In] ref System.Threading.NativeOverlapped lpOverlapped, out uint lpNumberOfBytesTransferred, bool bWait);
[DllImport("kernel32.dll")] [DllImport("kernel32.dll")]
static internal extern bool WriteFile(IntPtr hFile, byte[] lpBuffer, uint nNumberOfBytesToWrite, out uint lpNumberOfBytesWritten, [In] ref System.Threading.NativeOverlapped lpOverlapped); internal static extern bool WriteFile(IntPtr hFile, byte[] lpBuffer, uint nNumberOfBytesToWrite, out uint lpNumberOfBytesWritten, [In] ref System.Threading.NativeOverlapped lpOverlapped);
internal const short DIGCF_PRESENT = 0x2; internal const short DIGCF_PRESENT = 0x2;
internal const short DIGCF_DEVICEINTERFACE = 0x10; internal const short DIGCF_DEVICEINTERFACE = 0x10;
@ -115,6 +115,7 @@ namespace EonaCat.HID
internal struct SP_DEVICE_INTERFACE_DETAIL_DATA internal struct SP_DEVICE_INTERFACE_DETAIL_DATA
{ {
internal int Size; internal int Size;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
internal string DevicePath; internal string DevicePath;
} }
@ -135,22 +136,22 @@ namespace EonaCat.HID
public static extern unsafe bool SetupDiGetDeviceProperty(IntPtr deviceInfo, ref SP_DEVINFO_DATA deviceInfoData, ref DEVPROPKEY propkey, ref uint propertyDataType, void* propertyBuffer, int propertyBufferSize, ref int requiredSize, uint flags); public static extern unsafe bool SetupDiGetDeviceProperty(IntPtr deviceInfo, ref SP_DEVINFO_DATA deviceInfoData, ref DEVPROPKEY propkey, ref uint propertyDataType, void* propertyBuffer, int propertyBufferSize, ref int requiredSize, uint flags);
[DllImport("setupapi.dll")] [DllImport("setupapi.dll")]
static internal extern bool SetupDiEnumDeviceInfo(IntPtr deviceInfoSet, int memberIndex, ref SP_DEVINFO_DATA deviceInfoData); internal static extern bool SetupDiEnumDeviceInfo(IntPtr deviceInfoSet, int memberIndex, ref SP_DEVINFO_DATA deviceInfoData);
[DllImport("setupapi.dll")] [DllImport("setupapi.dll")]
static internal extern int SetupDiDestroyDeviceInfoList(IntPtr deviceInfoSet); internal static extern int SetupDiDestroyDeviceInfoList(IntPtr deviceInfoSet);
[DllImport("setupapi.dll")] [DllImport("setupapi.dll")]
static internal extern bool SetupDiEnumDeviceInterfaces(IntPtr deviceInfoSet, ref SP_DEVINFO_DATA deviceInfoData, ref Guid interfaceClassGuid, int memberIndex, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData); internal static extern bool SetupDiEnumDeviceInterfaces(IntPtr deviceInfoSet, ref SP_DEVINFO_DATA deviceInfoData, ref Guid interfaceClassGuid, int memberIndex, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData);
[DllImport("setupapi.dll")] [DllImport("setupapi.dll")]
static internal extern IntPtr SetupDiGetClassDevs(ref System.Guid classGuid, string enumerator, IntPtr hwndParent, int flags); internal static extern IntPtr SetupDiGetClassDevs(ref System.Guid classGuid, string enumerator, IntPtr hwndParent, int flags);
[DllImport("setupapi.dll")] [DllImport("setupapi.dll")]
static internal extern bool SetupDiGetDeviceInterfaceDetail(IntPtr deviceInfoSet, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData, IntPtr deviceInterfaceDetailData, int deviceInterfaceDetailDataSize, ref int requiredSize, IntPtr deviceInfoData); internal static extern bool SetupDiGetDeviceInterfaceDetail(IntPtr deviceInfoSet, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData, IntPtr deviceInterfaceDetailData, int deviceInterfaceDetailDataSize, ref int requiredSize, IntPtr deviceInfoData);
[DllImport("setupapi.dll")] [DllImport("setupapi.dll")]
static internal extern bool SetupDiGetDeviceInterfaceDetail(IntPtr deviceInfoSet, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData, ref SP_DEVICE_INTERFACE_DETAIL_DATA deviceInterfaceDetailData, int deviceInterfaceDetailDataSize, ref int requiredSize, IntPtr deviceInfoData); internal static extern bool SetupDiGetDeviceInterfaceDetail(IntPtr deviceInfoSet, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData, ref SP_DEVICE_INTERFACE_DETAIL_DATA deviceInterfaceDetailData, int deviceInterfaceDetailDataSize, ref int requiredSize, IntPtr deviceInfoData);
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct HIDD_ATTRIBUTES internal struct HIDD_ATTRIBUTES
@ -169,8 +170,10 @@ namespace EonaCat.HID
internal short InputReportByteLength; internal short InputReportByteLength;
internal short OutputReportByteLength; internal short OutputReportByteLength;
internal short FeatureReportByteLength; internal short FeatureReportByteLength;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)]
internal short[] Reserved; internal short[] Reserved;
internal short NumberLinkCollectionNodes; internal short NumberLinkCollectionNodes;
internal short NumberInputButtonCaps; internal short NumberInputButtonCaps;
internal short NumberInputValueCaps; internal short NumberInputValueCaps;
@ -184,31 +187,31 @@ namespace EonaCat.HID
} }
[DllImport("hid.dll")] [DllImport("hid.dll")]
static internal extern bool HidD_GetAttributes(IntPtr hidDeviceObject, ref HIDD_ATTRIBUTES attributes); internal static extern bool HidD_GetAttributes(IntPtr hidDeviceObject, ref HIDD_ATTRIBUTES attributes);
[DllImport("hid.dll")] [DllImport("hid.dll")]
static internal extern bool HidD_GetFeature(IntPtr hidDeviceObject, byte[] lpReportBuffer, int reportBufferLength); internal static extern bool HidD_GetFeature(IntPtr hidDeviceObject, byte[] lpReportBuffer, int reportBufferLength);
[DllImport("hid.dll")] [DllImport("hid.dll")]
static internal extern bool HidD_GetInputReport(IntPtr hidDeviceObject, byte[] lpReportBuffer, int reportBufferLength); internal static extern bool HidD_GetInputReport(IntPtr hidDeviceObject, byte[] lpReportBuffer, int reportBufferLength);
[DllImport("hid.dll")] [DllImport("hid.dll")]
static internal extern void HidD_GetHidGuid(ref Guid hidGuid); internal static extern void HidD_GetHidGuid(ref Guid hidGuid);
[DllImport("hid.dll")] [DllImport("hid.dll")]
static internal extern bool HidD_GetPreparsedData(IntPtr hidDeviceObject, ref IntPtr preparsedData); internal static extern bool HidD_GetPreparsedData(IntPtr hidDeviceObject, ref IntPtr preparsedData);
[DllImport("hid.dll")] [DllImport("hid.dll")]
static internal extern bool HidD_FreePreparsedData(IntPtr preparsedData); internal static extern bool HidD_FreePreparsedData(IntPtr preparsedData);
[DllImport("hid.dll")] [DllImport("hid.dll")]
static internal extern bool HidD_SetFeature(IntPtr hidDeviceObject, byte[] lpReportBuffer, int reportBufferLength); internal static extern bool HidD_SetFeature(IntPtr hidDeviceObject, byte[] lpReportBuffer, int reportBufferLength);
[DllImport("hid.dll")] [DllImport("hid.dll")]
static internal extern bool HidD_SetOutputReport(IntPtr hidDeviceObject, byte[] lpReportBuffer, int reportBufferLength); internal static extern bool HidD_SetOutputReport(IntPtr hidDeviceObject, byte[] lpReportBuffer, int reportBufferLength);
[DllImport("hid.dll")] [DllImport("hid.dll")]
static internal extern int HidP_GetCaps(IntPtr preparsedData, ref Capabilities capabilities); internal static extern int HidP_GetCaps(IntPtr preparsedData, ref Capabilities capabilities);
[DllImport("hid.dll")] [DllImport("hid.dll")]
internal static extern bool HidD_GetProductString(IntPtr hidDeviceObject, byte[] lpReportBuffer, int ReportBufferLength); internal static extern bool HidD_GetProductString(IntPtr hidDeviceObject, byte[] lpReportBuffer, int ReportBufferLength);
@ -219,4 +222,4 @@ namespace EonaCat.HID
[DllImport("hid.dll")] [DllImport("hid.dll")]
internal static extern bool HidD_GetSerialNumberString(IntPtr hidDeviceObject, byte[] lpReportBuffer, int reportBufferLength); internal static extern bool HidD_GetSerialNumberString(IntPtr hidDeviceObject, byte[] lpReportBuffer, int reportBufferLength);
} }
} }

View File

@ -9,12 +9,7 @@ namespace EonaCat.HID
internal ReadDevice(string devicePath, string description = null) internal ReadDevice(string devicePath, string description = null)
: base(devicePath, description) { } : base(devicePath, description) { }
public DeviceData FastRead() public DeviceData FastRead(int timeout = 0)
{
return FastRead(0);
}
public DeviceData FastRead(int timeout)
{ {
try try
{ {
@ -26,58 +21,19 @@ namespace EonaCat.HID
} }
} }
public void FastRead(ReadCallback callback)
{
FastRead(callback, 0);
}
public void FastRead(ReadCallback callback, int timeout)
{
var readDelegate = new ReadDelegate(FastRead);
var asyncState = new StateAsync(readDelegate, callback);
readDelegate.BeginInvoke(timeout, EndRead, asyncState);
}
public async Task<DeviceData> FastReadAsync(int timeout = 0) public async Task<DeviceData> FastReadAsync(int timeout = 0)
{ {
var readDelegate = new ReadDelegate(FastRead); return await Task.Run(() => FastRead(timeout));
#if NET20 || NET35 || NET5_0_OR_GREATER
return await Task<DeviceData>.Factory.StartNew(() => readDelegate.Invoke(timeout));
#else
return await Task<DeviceData>.Factory.FromAsync(readDelegate.BeginInvoke, readDelegate.EndInvoke, timeout, null);
#endif
} }
public Report FastReadReport() public Report FastReadReport(int timeout = 0)
{
return FastReadReport(0);
}
public Report FastReadReport(int timeout)
{ {
return new Report(Capabilities.InputReportByteLength, FastRead(timeout)); return new Report(Capabilities.InputReportByteLength, FastRead(timeout));
} }
public void FastReadReport(ReadReportCallback callback)
{
FastReadReport(callback, 0);
}
public void FastReadReport(ReadReportCallback callback, int timeout)
{
var readReportDelegate = new ReadReportDelegate(FastReadReport);
var asyncState = new StateAsync(readReportDelegate, callback);
readReportDelegate.BeginInvoke(timeout, EndReadReport, asyncState);
}
public async Task<Report> FastReadReportAsync(int timeout = 0) public async Task<Report> FastReadReportAsync(int timeout = 0)
{ {
var readReportDelegate = new ReadReportDelegate(FastReadReport); return await Task.Run(() => FastReadReport(timeout));
#if NET20 || NET35 || NET5_0_OR_GREATER
return await Task<Report>.Factory.StartNew(() => readReportDelegate.Invoke(timeout));
#else
return await Task<Report>.Factory.FromAsync(readReportDelegate.BeginInvoke, readReportDelegate.EndInvoke, timeout, null);
#endif
} }
} }
} }

View File

@ -14,7 +14,7 @@ namespace EonaCat.HID
public IDevice GetDevice(string devicePath) public IDevice GetDevice(string devicePath)
{ {
return Enumerate(devicePath).FirstOrDefault() as IDevice; return Enumerate(devicePath).FirstOrDefault();
} }
public IEnumerable<IDevice> Enumerate() public IEnumerable<IDevice> Enumerate()

View File

@ -7,57 +7,57 @@ namespace EonaCat.HID
public class Report public class Report
{ {
private byte _reportId; private byte _reportId;
private byte[] _data = new byte[] {}; private byte[] _data;
private readonly DeviceData.ReadStatus _status; private readonly DeviceData.ReadStatus _status;
public Report(int reportSize) public Report(int reportSize)
{ {
Array.Resize(ref _data, reportSize - 1); if (reportSize > 0)
{
_data = new byte[reportSize - 1];
}
else
{
Exists = false;
return;
}
} }
public Report(int reportSize, DeviceData deviceData) public Report(int reportSize, DeviceData deviceData)
{ {
_status = deviceData.Status; _status = deviceData.Status;
if (reportSize > 0)
Array.Resize(ref _data, reportSize - 1);
if ((deviceData.Data != null))
{ {
_data = new byte[reportSize - 1];
if (deviceData.Data.Length > 0)
{
_reportId = deviceData.Data[0];
Exists = true;
if (deviceData.Data.Length > 1)
{
var dataLength = reportSize - 1;
if (deviceData.Data.Length < reportSize - 1)
{
dataLength = deviceData.Data.Length;
}
Array.Copy(deviceData.Data, 1, _data, 0, dataLength);
}
}
else
{
Exists = false;
}
} }
else else
{ {
Exists = false; Exists = false;
return;
}
if (deviceData?.Data == null || deviceData.Data.Length == 0)
{
Exists = false;
return;
}
_reportId = deviceData.Data[0];
Exists = true;
var dataLength = Math.Min(deviceData.Data.Length - 1, reportSize - 1);
if (dataLength > 0)
{
Array.Copy(deviceData.Data, 1, _data, 0, dataLength);
} }
} }
public bool Exists { get; private set; } public bool Exists { get; private set; }
public DeviceData.ReadStatus ReadStatus { get { return _status; } } public DeviceData.ReadStatus ReadStatus => _status;
public byte ReportId public byte ReportId
{ {
get { return _reportId; } get => _reportId;
set set
{ {
_reportId = value; _reportId = value;
@ -67,7 +67,7 @@ namespace EonaCat.HID
public byte[] Data public byte[] Data
{ {
get { return _data; } get => _data;
set set
{ {
_data = value; _data = value;
@ -77,11 +77,10 @@ namespace EonaCat.HID
public byte[] GetBytes() public byte[] GetBytes()
{ {
byte[] data = null; var data = new byte[_data.Length + 1];
Array.Resize(ref data, _data.Length + 1);
data[0] = _reportId; data[0] = _reportId;
Array.Copy(_data, 0, data, 1, _data.Length); Array.Copy(_data, 0, data, 1, _data.Length);
return data; return data;
} }
} }
} }

View File

@ -13,7 +13,9 @@
_callbackDelegate = callbackDelegate; _callbackDelegate = callbackDelegate;
} }
public object CallerDelegate { get { return _callerDelegate; } } public object CallerDelegate
public object CallbackDelegate { get { return _callbackDelegate; } } { get { return _callerDelegate; } }
public object CallbackDelegate
{ get { return _callbackDelegate; } }
} }
} }