public bool SetFeature(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"); } featureBuffer[0] = reportId; Buffer.BlockCopy(featureBuffer, 1, data, offset, count); GCHandle gch = GCHandle.Alloc(featureBuffer, GCHandleType.Pinned); bool ret = Hid.HidD_SetFeature(reference, gch.AddrOfPinnedObject(), (uint)(count + 1)); gch.Free(); return(ret); } }
public bool SetFeature <T>(byte reportId, T buffer) where T : struct { 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"); } featureBuffer[0] = reportId; int size; GCHandle gch = CopyStructToBuffer(featureBuffer, buffer, out size); bool ret = Hid.HidD_SetFeature(reference, gch.AddrOfPinnedObject(), (uint)(size + 1)); gch.Free(); return(ret); } }
public bool SetFeature(int reportNumber, byte[] data) { if (data.Length > 64) { throw new ArgumentException("Array too large!", "data"); } data[0] = Convert.ToByte(reportNumber); return(Hid.HidD_SetFeature(this._handle, ref data[0], data.Length)); }
public bool SetFeature(byte[] rawBuffer, 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"); } GCHandle gch = GCHandle.Alloc(rawBuffer, GCHandleType.Pinned); bool ret = Hid.HidD_SetFeature(reference, gch.AddrOfPinnedObject(), (uint)count); gch.Free(); return(ret); } }