hidapi_sys/
lib.rs

1#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals)]
2
3extern crate libc;
4
5use libc::{c_void, c_ushort, wchar_t, c_int, c_uchar, size_t, c_char};
6
7pub type hid_device = c_void;
8
9#[repr(C)]
10pub struct hid_device_info {
11	pub path: *mut c_char,
12
13	pub vendor_id:  c_ushort,
14	pub product_id: c_ushort,
15
16	pub serial_number:  *mut wchar_t,
17	pub release_number: c_ushort,
18
19	pub manufacturer_string: *mut wchar_t,
20	pub product_string:      *mut wchar_t,
21
22	pub usage_page: c_ushort,
23	pub usage:      c_ushort,
24
25	pub interface_number: c_int,
26
27	pub next: *mut hid_device_info,
28}
29
30#[cfg_attr(target_os = "linux", link(name = "udev"))]
31extern "C" { }
32
33#[cfg_attr(target_os = "windows", link(name = "setupapi"))]
34extern "C" { }
35
36#[cfg_attr(all(feature = "static", target_os = "linux"), link(name = "hidapi-libusb", kind = "static"))]
37#[cfg_attr(all(not(feature = "static"), target_os = "linux"), link(name = "hidapi-libusb"))]
38#[cfg_attr(all(feature = "static", not(target_os = "linux")), link(name = "hidapi", kind = "static"))]
39#[cfg_attr(all(not(feature = "static"), not(target_os = "linux")), link(name = "hidapi"))]
40extern "C" {
41	pub fn hid_init() -> c_int;
42	pub fn hid_exit() -> c_int;
43
44	pub fn hid_enumerate(vendor_id: c_ushort, product_id: c_ushort) -> *mut hid_device_info;
45	pub fn hid_free_enumeration(devs: *mut hid_device_info);
46
47	pub fn hid_open(vendor_id: c_ushort, product_id: c_ushort, serial_number: *const wchar_t) -> *mut hid_device;
48	pub fn hid_open_path(path: *const c_char) -> *mut hid_device;
49
50	pub fn hid_write(device: *mut hid_device, data: *const c_uchar, length: size_t) -> c_int;
51
52	pub fn hid_read_timeout(device: *mut hid_device, data: *mut c_uchar, length: size_t, milleseconds: c_int) -> c_int;
53	pub fn hid_read(device: *mut hid_device, data: *mut c_uchar, length: size_t) -> c_int;
54
55	pub fn hid_set_nonblocking(device: *mut hid_device, nonblock: c_int) -> c_int;
56
57	pub fn hid_send_feature_report(device: *mut hid_device, data: *const c_uchar, length: size_t) -> c_int;
58	pub fn hid_get_feature_report(device: *mut hid_device, data: *mut c_uchar, length: size_t) -> c_int;
59
60	pub fn hid_close(device: *mut hid_device);
61
62	pub fn hid_get_manufacturer_string(device: *mut hid_device, string: *mut wchar_t, maxlen: size_t) -> c_int;
63	pub fn hid_get_product_string(device: *mut hid_device, string: *mut wchar_t, maxlen: size_t) -> c_int;
64	pub fn hid_get_serial_number_string(device: *mut hid_device, string: *mut wchar_t, maxlen: size_t) -> c_int;
65	pub fn hid_get_indexed_string(device: *mut hid_device, string_index: c_int, string: *mut wchar_t, maxlen: size_t) -> c_int;
66
67	pub fn hid_error(device: *mut hid_device) -> *const wchar_t;
68}