I building a WPF application and I know how to detect individual key presses but I also want to do the same with a USB device, specifically a Windows Media Center remote control. I have the remote control and a USB infrared receiver.
I'm a bit unsure how to do this but I have tried a few things, all of which haven't worked. For keyboard input I had the following code.
public MainWindow()
{
//Other code
this.KeyDown += new KeyEventHandler(OnButtonKeyDown);
}
private void OnButtonKeyDown(object sender, KeyEventArgs e)
{
var keypressed = e.Key.ToString();
//Do something based on the value of keypress
}
Which worked so I figured I could do a similar thing with the USB device input.
Public MainWindow()
{
//Other code
var inputDown = new InputEventHandler(OnInputDown);
}
private void OnInputDown(object sender, InputEventArgs e)
{
var inputpressed = e.RoutedEvent.ToString();
}
But this didn't work, the input event was never trigger. I'm aware that I may need to register the USB device with the app to be able to access input from it but I'm unsure how to do this. Could anyone point me in the right direction?
I did manage to right a script to print out all the USB devices connected to the computer and these are the details I got back about the USB remote receiver.
- Device ID: USB\VID_0471 & PID_0815\PH00QO9E
- PNP Device ID: USB\VID_0471 & PID_0815\PH00QO9E
- Description: eHome Infrared Receiver(USBCIR)