summaryrefslogtreecommitdiff
path: root/hidapi.py
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2016-08-19 01:54:24 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2016-08-19 01:54:24 +0200
commit16289c720a0f63d636faaaf4d4432496a8aa4231 (patch)
tree6d71538883d173e5185aae25234be0a3d23eab77 /hidapi.py
parent2eb61cda770ca48068daeeee83917f023d8a6110 (diff)
Ported bootloader from arcin.
Diffstat (limited to 'hidapi.py')
-rw-r--r--hidapi.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/hidapi.py b/hidapi.py
new file mode 100644
index 0000000..06ee90c
--- /dev/null
+++ b/hidapi.py
@@ -0,0 +1,19 @@
+import ctypes, ctypes.util
+
+path = ctypes.util.find_library('hidapi')
+
+if not path:
+ raise ImportError('Cannot find hidapi library')
+
+hidapi = ctypes.CDLL(path)
+
+hidapi.hid_open.argtypes = [ctypes.c_ushort, ctypes.c_ushort, ctypes.c_wchar_p]
+hidapi.hid_open.restype = ctypes.c_void_p
+
+hidapi.hid_close.argtypes = [ctypes.c_void_p]
+
+hidapi.hid_read_timeout.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t, ctypes.c_int]
+hidapi.hid_read.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t]
+hidapi.hid_write.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t]
+hidapi.hid_send_feature_report.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t]
+hidapi.hid_get_feature_report.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t]