Skip to content

Commit

Permalink
expose hid_version_str
Browse files Browse the repository at this point in the history
`hid_version_str` was added to the underlying C library in 0.10.0,
in libusb/hidapi#192

Note that the method added here returns the version of the C library,
which is different from the version of cython-hidapi, i.e. the `hid` python package.
It would be good to also make the latter available at runtime somehow.
  • Loading branch information
SomberNight authored and prusnak committed Aug 22, 2022
1 parent 3aee45c commit 13d8728
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions chid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ cdef extern from "hidapi.h":
int hid_get_serial_number_string(hid_device*, wchar_t *, size_t)
int hid_get_indexed_string(hid_device*, int, wchar_t *, size_t)
wchar_t *hid_error(hid_device *)
char* hid_version_str()
8 changes: 8 additions & 0 deletions hid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ def enumerate(int vendor_id=0, int product_id=0):
hid_free_enumeration(info)
return res

def version_str():
"""Return a runtime version string of the hidapi C library.
:return: version string of library
:rtype: str
"""
return (<bytes>hid_version_str()).decode('ascii')

cdef class _closer:
"""Wrap a hid_device *ptr and a provide a way to call hid_close() on it.
Expand Down

0 comments on commit 13d8728

Please sign in to comment.