mikeobrien/HidLibrary — Issue #14: logitech gamepad sample
Author: deepnote
Created: 2011-11-20 18:15:59+00:00
State: open

Hi,
sample cant detect product ID. I`ve done this to get it work:

```C
_device = HidDevices.Enumerate(VendorId, 0xC21E).FirstOrDefault();
```
And then it throw exception:

```C
public PrecisionMessage(byte[] message)
{
if (message != null && message.Length == 4)
{
Array.Reverse(message);
_message = BitConverter.ToUInt32(message, 0);
}
else throw new InvalidCastException("Cannot convert gamepad message to 32 bit integer.");
_buttonsPressed = GetButtonsPressed(this);
}
```

```C
System.InvalidCastException was unhandled
Message=Cannot convert gamepad message to 32 bit integer.
Source=LogitechGamepad
StackTrace:
v LogitechGamepad.PrecisionMessage..ctor(Byte[] message) v C:\Users\Ivo\Desktop\mikeobrien-HidLibrary-d682227\src\Samples\LogitechGamepad\PrecisionMessage.cs:řádek 40
v LogitechGamepad.MessageFactory.CreateMessage(Int32 productId, Byte[] messageData) v C:\Users\Ivo\Desktop\mikeobrien-HidLibrary-d682227\src\Samples\LogitechGamepad\MessageFactory.cs:řádek 12
v LogitechGamepad.Program.OnReport(HidReport report) v C:\Users\Ivo\Desktop\mikeobrien-HidLibrary-d682227\src\Samples\LogitechGamepad\Program.cs:řádek 55
v HidLibrary.HidDevice.EndReadReport(IAsyncResult ar) v C:\Users\Ivo\Desktop\mikeobrien-HidLibrary-d682227\src\Current\HidLibrary\HidDevice.cs:řádek 242
v System.Runtime.Remoting.Messaging.AsyncResult.SyncProcessMessage(IMessage msg)
v System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
v System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.DoAsyncCall()
v System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)
v System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
v System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
v System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
v System.Threading.ThreadPoolWorkQueue.Dispatch()
v System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
InnerException:

```
Windows 7, x64. Sorry if this is useless observation.