Exemplo n.º 1
0
        public bool GetInputReport(byte reportId, byte[] data, int offset, int count)
        {
            lock (lockObject)
            {
                if (reference == null)
                {
                    throw new InvalidOperationException("The HID reference is null.");
                }
                else if (reference.IsInvalid)
                {
                    throw new InvalidOperationException("The HID reference is invalid");
                }

                inBuffer[0] = reportId;

                GCHandle gch = GCHandle.Alloc(inBuffer, GCHandleType.Pinned);

                bool ret = Hid.HidD_GetInputReport(reference, gch.AddrOfPinnedObject(), (uint)(count + 1));

                gch.Free();

                if (ret)
                {
                    Buffer.BlockCopy(inBuffer, 1, data, offset, count);
                }

                return(ret);
            }
        }
Exemplo n.º 2
0
        public bool GetInputReport(byte[] rawBuffer)
        {
            lock (lockObject)
            {
                if (reference == null)
                {
                    throw new InvalidOperationException("The HID reference is null.");
                }
                else if (reference.IsInvalid)
                {
                    throw new InvalidOperationException("The HID reference is invalid");
                }

                GCHandle gch = GCHandle.Alloc(rawBuffer, GCHandleType.Pinned);

                bool ret = Hid.HidD_GetInputReport(reference, gch.AddrOfPinnedObject(), (uint)rawBuffer.Length);

                gch.Free();

                return(ret);
            }
        }