예제 #1
0
        public bool SetOutputReport(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");
                }

                outBuffer[0] = reportId;

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

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

                gch.Free();

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

                return(ret);
            }
        }
예제 #2
0
        public bool SetOutputReport(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_SetOutputReport(reference, gch.AddrOfPinnedObject(), (uint)rawBuffer.Length);

                gch.Free();

                return(ret);
            }
        }