public void Reset() { ThrowIfDisposed(); var result = Interface.ResetDevice(InterfaceRef); IOObject.ThrowIfError(result); }
public void ReturnExtraPower(PowerRequestType type, uint powerReturned) { ThrowIfDisposed(); var result = Interface.ReturnExtraPower(InterfaceRef, (uint)type, powerReturned); IOObject.ThrowIfError(result); }
public void Close(IOHIDOptionsType options = IOHIDOptionsType.None) { ThrowIfDisposed(); var result = IOHIDManagerClose(Handle, (uint)options); IOObject.ThrowIfError(result); }
public void SendReport(IOHIDReportType type, int id, byte[] data) { ThrowIfDisposed(); var result = IOHIDDeviceSetReport(Handle, type, (CFIndex)id, data, (CFIndex)data.Length); IOObject.ThrowIfError(result); }
public void Open(IOHIDOptionsType options = IOHIDOptionsType.None) { ThrowIfDisposed(); var result = IOHIDDeviceOpen(Handle, (uint)options); IOObject.ThrowIfError(result); }
public void Close() { ThrowIfDisposed(); var result = IOHIDDeviceClose(Handle, 0); IOObject.ThrowIfError(result); }
public void AbortPipeZero() { ThrowIfDisposed(); var result = Interface.USBDeviceAbortPipeZero(InterfaceRef); IOObject.ThrowIfError(result); }
public void OpenSeize() { ThrowIfDisposed(); var result = Interface.USBDeviceOpenSeize(InterfaceRef); IOObject.ThrowIfError(result); }
public void ReEnumerate(uint options) { ThrowIfDisposed(); var result = Interface.USBDeviceReEnumerate(InterfaceRef, options); IOObject.ThrowIfError(result); }
public void Suspend(bool suspend) { ThrowIfDisposed(); var result = Interface.USBDeviceSuspend(InterfaceRef, suspend); IOObject.ThrowIfError(result); }
public void RequestTimeout(ref IOUSBDevRequestTO request) { ThrowIfDisposed(); var result = Interface.DeviceRequestTO(InterfaceRef, ref request); IOObject.ThrowIfError(result); }
public IDictionary <IOHIDElement, IOHIDValue> GetValues(IOHIDElement[] elements) { ThrowIfDisposed(); if (elements == null) { throw new ArgumentNullException("elements"); } var elementArray = CFArray.FromNativeObjects(elements); IOHIDElement[] keys = new IOHIDElement[elements.Length]; IOHIDValue[] values = new IOHIDValue[elements.Length]; CFDictionary multiple = CFDictionary.FromObjectsAndKeys(values, keys); var multipleRef = multiple.Handle; var result = IOHIDDeviceCopyValueMultiple(Handle, elementArray.Handle, ref multipleRef); IOObject.ThrowIfError(result); var dict = new Dictionary <IOHIDElement, IOHIDValue> (multiple.Count); IntPtr[] keyRefs, valueRefs; multiple.GetKeysAndValues(out keyRefs, out valueRefs); for (int i = 0; i < multiple.Count; i++) { dict.Add(new IOHIDElement(keyRefs [i], true), new IOHIDValue(valueRefs [i], true)); } CFType.Release(multiple.Handle); return(dict); }
public IOReceivePort(OSMessageID msgType) : base(IntPtr.Zero) { IntPtr receivePort; var result = IOCreateReceivePort((uint)msgType, out receivePort); IOObject.ThrowIfError(result); Handle = receivePort; }
public IOUSBConfigurationDescriptor GetConfigurationDescriptor(int index) { ThrowIfDisposed(); IntPtr configDescriptorRef; var result = Interface.GetConfigurationDescriptorPtr(InterfaceRef, (byte)(index - 1), out configDescriptorRef); IOObject.ThrowIfError(result); return((IOUSBConfigurationDescriptor)Marshal.PtrToStructure(configDescriptorRef, typeof(IOUSBConfigurationDescriptor))); }
public uint RequestExtraPower(PowerRequestType type, uint requestedPower) { ThrowIfDisposed(); uint powerAvailable; var result = Interface.RequestExtraPower(InterfaceRef, (uint)type, requestedPower, out powerAvailable); IOObject.ThrowIfError(result); return(powerAvailable); }
public ulong GetBusFrameNumberWithTime(out AbsoluteTime atTime) { ThrowIfDisposed(); ulong frame; var result = Interface.GetBusFrameNumberWithTime(InterfaceRef, out frame, out atTime); IOObject.ThrowIfError(result); return((ulong)IOUSB.USBToHostOrder((long)frame)); }
public uint ExtraPowerAllocated(PowerRequestType type) { ThrowIfDisposed(); uint powerAllocated; var result = Interface.GetExtraPowerAllocated(InterfaceRef, (uint)type, out powerAllocated); IOObject.ThrowIfError(result); return(powerAllocated); }
public Port CreateAsyncPort() { ThrowIfDisposed(); IntPtr portRef; var result = Interface.CreateDeviceAsyncPort(InterfaceRef, out portRef); IOObject.ThrowIfError(result); return(new Port(portRef)); }
public IOIterator <IOUSBInterface> CreateInterfaceIterator(IOUSBFindInterfaceRequest request) { ThrowIfDisposed(); IntPtr iteratorRef; var result = Interface.CreateInterfaceIterator(InterfaceRef, request, out iteratorRef); IOObject.ThrowIfError(result); return(new IOIterator <IOUSBInterface> (iteratorRef, true)); }
public void SetValueMultiple(IDictionary <IOHIDElement, IOHIDValue> dictonary) { ThrowIfDisposed(); if (dictonary == null) { throw new ArgumentNullException("multiple"); } var multiple = CFDictionary.FromObjectsAndKeys(dictonary.Values.ToArray(), dictonary.Keys.ToArray()); var result = IOHIDDeviceSetValueMultiple(Handle, multiple.Handle); CFType.Release(multiple.Handle); IOObject.ThrowIfError(result); }
public void SetValue(IOHIDElement element, IOHIDValue value) { ThrowIfDisposed(); if (element == null) { throw new ArgumentNullException("element"); } if (value == null) { throw new ArgumentNullException("value"); } var result = IOHIDDeviceSetValue(Handle, element.Handle, value.Handle); IOObject.ThrowIfError(result); }
internal static bool WaitForPort(IntPtr masterPort, double seconds) { var integerPart = (uint)Math.Floor(seconds); var decimalPart = seconds - integerPart; var waitTime = new TimeSpec() { Seconds = integerPart, Nanoseconds = (int)(decimalPart * 1e9) }; var result = IOKitWaitQuiet(masterPort, waitTime); if (result == IOReturn.Timeout) { return(true); } IOObject.ThrowIfError(result); return(false); }
public IOHIDValue GetValue(IOHIDElement element) { ThrowIfDisposed(); if (element == null) { throw new ArgumentNullException("element"); } IntPtr valueRef; var result = IOHIDDeviceGetValue(Handle, element.Handle, out valueRef); IOObject.ThrowIfError(result); if (valueRef == IntPtr.Zero) { return(null); } return(new IOHIDValue(valueRef, true)); }
public Task <int> RequestTimeoutAsync(IOUSBDevRequestTO request) { ThrowIfDisposed(); var completionSource = new TaskCompletionSource <int> (); GCHandle callbackHandle = new GCHandle(); IOAsyncCallback1 callback = (refCon, callbackResult, arg0) => { callbackHandle.Free(); if (callbackResult == IOReturn.Success) { completionSource.TrySetResult((int)arg0); } else { completionSource.TrySetException(callbackResult.ToNSErrorException()); } }; callbackHandle = GCHandle.Alloc(callback, GCHandleType.Pinned); var result = Interface.DeviceRequestAsyncTO(InterfaceRef, request, callback, IntPtr.Zero); IOObject.ThrowIfError(result); return(completionSource.Task); }