Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions hid/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
import ctypes
import atexit
import enum
Expand Down Expand Up @@ -146,6 +147,13 @@ def as_dict(self):
hidapi.hid_error.argtypes = [ctypes.c_void_p]
hidapi.hid_error.restype = ctypes.c_wchar_p

if sys.platform == "darwin" and version >= (0, 12, 0):
hidapi.hid_darwin_set_open_exclusive.argtypes = [ctypes.c_int]
hidapi.hid_darwin_set_open_exclusive.restype = None
hidapi.hid_darwin_get_open_exclusive.argtypes = []
hidapi.hid_darwin_get_open_exclusive.restype = ctypes.c_int
hidapi.hid_darwin_is_device_open_exclusive.argtypes = [ctypes.c_void_p]
hidapi.hid_darwin_is_device_open_exclusive.restype = ctypes.c_int

def enumerate(vid=0, pid=0):
ret = []
Expand Down Expand Up @@ -275,3 +283,11 @@ def get_indexed_string(self, index, max_length=255):
self.__hidcall(hidapi.hid_get_indexed_string,
self.__dev, index, buf, max_length)
return buf.value

@property
def exclusive(self):
if hasattr(hidapi, "hid_darwin_is_device_open_exclusive"):
return self.__hidcall(hidapi.hid_darwin_is_device_open_exclusive,
self.__dev)
else:
return False