 |
|
 |
Why is myPSP_DEVICE_INTERFACE_DETAIL_DATA.cbSize set to 5?
When I do...
Marshal.SizeOf(myPSP_DEVICE_INTERFACE_DETAIL_DATA)
I get 260, wich makes sense (I think).
I must be missing something?
“If I had asked people what they wanted, they would have said faster horses.”
― Henry Ford
modified 16 May '12.
|
|
|
|
 |
|
 |
I don't fully understand the idea of HID devices, but here is my question (sorry if it's nonsense).
The only way to make key presses indistinguishable from the real key press - is by using custom (self-made) keyboard drivers.
Lets say we are using SendInput() method (scan codes) to inject key presses into programs/games. In some games - tools such as GameGuard will be blocking our injections. How so? That's because GameGuard blocks every input type except for Drivers themselves.
As far as I understand HID is used to communicate with the USB device, so if by any chance we could simulate key press event as a hardware press - driver will proceed it as a "real" and gameguard won't notice a thing.
is such thing possible with HID (C#)?
modified 3 May '12.
|
|
|
|
 |
|
 |
clean code for a good start for me to learn about talking with USB devices
|
|
|
|
 |
|
 |
This is not an article, but a tip.
|
|
|
|
 |
|
|
 |
|
 |
HEllo!
Has no result as under admin rights, although in debug mode.
Device to connect - HID input device, VID_1106, PID_0002.
I just can see device Found/Removed.
FULL TEXT:
UsbLibrary.HIDDeviceException: Msg:UsbLibrary.HIDDeviceException: Msg:Failed to create device file WinEr:00000005
in UsbLibrary.HIDDevice.Initialise(String strPath) in C:\Users\asy\Documents\Visual Studio 2008\Projects\usb_hid\usb hid\UsbLibrary\HIDDevice.cs:string 126
in UsbLibrary.HIDDevice.FindDevice(Int32 nVid, Int32 nPid, Type oType) in C:\Users\asy\Documents\Visual Studio 2008\Projects\usb_hid\usb hid\UsbLibrary\HIDDevice.cs:string 257
in UsbLibrary.HIDDevice.FindDevice(Int32 nVid, Int32 nPid, Type oType) in C:\Users\asy\Documents\Visual Studio 2008\Projects\usb_hid\usb hid\UsbLibrary\HIDDevice.cs:string 265
in UsbLibrary.SpecifiedDevice.FindSpecifiedDevice(Int32 vendor_id, Int32 product_id) in C:\Users\asy\Documents\Visual Studio 2008\Projects\usb_hid\usb hid\UsbLibrary\SpecifiedDevice.cs:string 42
in UsbLibrary.UsbHidPort.CheckDevicePresent() in C:\Users\asy\Documents\Visual Studio 2008\Projects\usb_hid\usb hid\UsbLibrary\UsbHidPort.cs:строка 218
Great Thanks and Best Regards
|
|
|
|
 |
|
 |
Try modifying UsbLibrary.HIDDevice.Initialise (sic) to do this:
private void Initialise(string strPath)
{
m_hHandle = CreateFile(strPath, GENERIC_READ | GENERIC_WRITE, 0, IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, IntPtr.Zero);
if (m_hHandle == InvalidHandleValue)
{
m_hHandle = CreateFile(strPath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, IntPtr.Zero);
}
|
|
|
|
 |
|
 |
Change
"CreateFile(strPath, GENERIC_READ | GENERIC_WRITE, 0, IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, IntPtr.Zero)"
To
"CreateFile(strPath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, IntPtr.Zero)".
|
|
|
|
 |
|
 |
Thanks for the nice library. I had a few problems getting it working on Windows 7 (64bit). A few changes were required:
In HIDDevice.cs, GetDevicePath, oDetail.Size = 8; instead of 5.
Two changes were in Win32Usb.cs:
DeviceInterfaceData: public IntPtr Reserved;
protected static extern bool SetupDiEnumDeviceInterfaces(IntPtr lpDeviceInfoSet, UInt64 nDeviceInfoData, ref Guid gClass, uint nIndex, ref DeviceInterfaceData oInterfaceData);
I could get the program running with a Philips LFH 2330 foot control. But that required one extra change: in HIDDevice.cs, ReadCompleted, m_oFile.EndRead could cause an OperationCanceledException. Hence I packed that line into the try block, and added a catch for that type of exceptions.
I could not yet get it running with an Olympus RS 28. Here, in HIDDevice.Initialise the call to CreateFile fails with code 32. I tried with FILE_SHARE_READ and FILE_SHARE_WRITE also, same error. Some hints?
|
|
|
|
 |
|
 |
thanks thanks thanks thanks thanks
|
|
|
|
 |
|
 |
very very thank you~
|
|
|
|
 |
|
 |
Greate Lib! Thanks for creating it, your work helps to reduce a lot of our effort!
|
|
|
|
 |
|
 |
I expanded the provided source code onto my window7 system and attempted to open the Documentation.chm file to start work but nothing can be viewed. Was this chm file generated on a non Windows system? How do you view this file?
Thanks
|
|
|
|
 |
|
 |
Windows XP had a couple of security updates (896358 and 840315) a while ago that now cause this problem. The cure is easy and it worked for me:
1. View the file name using Windows Explorer
2. Right-click on the CHM file name
3. Select Properties
4. Click on the Unblock button
5. Click "Apply".
|
|
|
|
 |
|
 |
thank you really helpfull
|
|
|
|
 |
|
 |
Thank you for this article. The code helps me a lot in my own project.
|
|
|
|
 |
|
 |
i have c# visua express 2010 and when i start the application and i enter ventor and product id i press ok and nothing happends, i have windows 7 profesional 64bit
|
|
|
|
 |
|
 |
same situation here plz help...!!
|
|
|
|
 |
|
 |
There are problems in this application when it is built as a 64 bit application. I built this application on 32 bit XP, and all was well. 64 bit Win 7 does not work.
I have not fully found the 64 bit fix(es) yet, but an example of the problem is in the Win32Usb.cs file. The declaration for SetupDiEnumDeviceInterfaces looks like this:
... SetupDiEnumDeviceInterfaces(
IntPtr lpDeviceInfoSet,
uint nDeviceInfoData,
ref Guid gClass,
uint nIndex,
ref DeviceInterfaceData oInterfaceData
);
The second parameter, nDeviceINfoData, is of type uint. It should really be a pointer. The type uint is 32 bits on both size applications but the pointer size changes, so the rest of the parameters are misaligned.
Of course, a file name with '32' in it kind of says it all. Not intended for 64 bit applications! But I think it could be corrected to work for both 32 bit and 64 with a little effort.
|
|
|
|
 |
|
 |
Hey
This code doesn't really work with me and i was wondering how to implement the events on O/S Windows 7 as the writter instructed.
"In the provided sample application, there is a good demonstration on how to include the component. Moreover, the use of the component is very well demonstrated. The only thing that must be done in your own application is implementing the events."
I really appreciate your expertise.
thanks a lot
|
|
|
|
 |
|
 |
I'm running this on Windows 7X64 (Compiled for X32 systems)
I can see my device HID\VID_06A3&PID_80C1 and can see when SOME data is captured.
The problem is the LCB appears to be Wrong?
When running USBTrace, Ill get data 00 00 02 08 00 00 20
But this (And other apps) I get 00 00 02 08 00 00 00
Now I can tell most key presses but I'm missing the
keypads Mode & button 21 (both are contained in this last byte)
Also If I'm not in mode 00 00 02 08 00 00 20 (Green Mode)
I'm getting Data: 00 00 02 08 00 00 00 00
Vs Data: 00 00 02 08 01 00 00 00
When pressing one of the normally working keys (USBTrace Shows valid data being sent)
|
|
|
|
 |
|
 |
Does this component work with Windows CE 5.0? I am using something derived from it, and it is not finding hid.dll, and I was hoping you could tell me where to look for the hid functions.
Thanks
Dave Stevens
|
|
|
|
 |
|
 |
cool,let's me learn....TKS
|
|
|
|
 |
|
 |
protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);
usb.RegisterHandle(Handle);
}
protected override void WndProc(ref Messagea m)
{
usb.ParseMessages(ref m); (Here i m getting Error "Object reference not set to an object.")
base.WndProc(ref m); }
Can any body reply me with his best.....
Please I m waiting..
|
|
|
|
 |
|
 |
I've compile the hid example with Visual Studio 2010 on a vista machine. It detects my USB HID device. However, when I click on send data. I get an exception on the filestream.Write() method in
this section of the code:
try
{
m_oFile.Write(oOutRep.Buffer, 0, oOutRep.BufferLength);
}
catch (IOException ex)
{
throw new HIDDeviceException("Probbaly the device was removed");
}
catch(Exception exx)
{
Console.WriteLine(exx.ToString());
}
The IOException "The Parameter is incorrect". Which is completely vague. Does anyone else out there have this working when they compile with a later version of Visual Studio 2010. Any ideas of what is wrong? I have not modified the code, but did update the project to the VS 2010 through the automatic conversion.
Also I noticed that the build is set to use .NET 2.0. Will it work with 4.0?
Thanks in advance.
Tim
|
|
|
|
 |