soldernerd / HID_Utility

This open source (GNU GPLv3) project is aimed at simplifying the development of C# applications that communicate with USB HID (Human Interface Device) devices.
https://soldernerd.com/2017/02/14/c-usb-hid-utility/
40 stars 10 forks source link

Raw Input messages not received when app loses focus #1

Open seanstardev opened 6 years ago

seanstardev commented 6 years ago

Hi. Thank you for creating this intriguing program.

I have had some success getting your demo application to read XBox One gamepads. Unfortunately - I only receive Input buffer data when running HidDemoWindowsForms, and even then the form MUST be in focus for button presses to be registered.

I am trying to run HID Utility as a service in the background - something to quietly log buffer data changes while other applications run over the top of it.

To reproduce the loss of focus issue, simply:

  1. Run the Windows Demo application.
  2. Press some buttons on the controller to verify packets are being received in the form.
  3. Open a windowed application (such as Paint, or Notepad), and bring said application to the foreground / into focus. Ensure you can still see the form packet data stats in the Windows Demo Form behind it.
  4. Press some more buttons.

Actual Outcome: No packets are received while Windows Demo app is out of focus.

Desired Outcome: Packets continue to be received if the Windows Demo app is out of focus, or even minimised. The 'packets received' stats in the form would show this in real-time.

I would greatly appreciate your thoughts on how I can make this work.

Ideally - I would like to achieve this outcome with a console-only version of your Windows Demo app, but I don't believe a device can be registered to the console window handler. (At any rate - I imagine I would have the same issues when the console loses focus).

Thanks!

soldernerd commented 6 years ago

Thank you for your detailed and precise description of the problem. Just one more piece of information would be useful: are you using the DLL or the Nuget? If you are using the dll, please try the nuget since it is the more up-to-date one. I'm using the WPF version in several of my applications and therefore know for pretty sure that that works flawlessly. The WindowsForms and particularly console versions have received less scrutiny I must admit.