Skip to content
This repository was archived by the owner on Feb 26, 2020. It is now read-only.

Commit c4b24af

Browse files
authored
Merge pull request #4 from newpavlov/master
Rustfmt, link to docs and minor improvements
2 parents 6ce21d3 + b0083cd commit c4b24af

File tree

6 files changed

+182
-134
lines changed

6 files changed

+182
-134
lines changed

Cargo.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
[package]
22
name = "hidapi"
3-
version = "0.3.0"
4-
authors = ["Roland Ruckerbauer <[email protected]>", "Osspial <[email protected]", "Artyom Pavlov <[email protected]>"]
3+
version = "0.3.1"
4+
authors = [
5+
"Roland Ruckerbauer <[email protected]>",
6+
"Osspial <[email protected]>",
7+
"Artyom Pavlov <[email protected]>"]
58
repository = "https://github.com/Osspial/hidapi-rs"
69
description = "Rust-y wrapper around hidapi"
710
license = "LGPL-3.0+"
8-
keywords = ["hid", "api", "binding"]
11+
keywords = ["hid", "api", "usb","binding", "wrapper"]
912
build = "build.rs"
1013
links = "hidapi"
14+
documentation = "https://beta.docs.rs/hidapi"
1115

1216
[dependencies]
1317
libc = "0.2.15"
File renamed without changes.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# hidapi
1+
# hidapi [![Build Status](https://travis-ci.org/Osspial/hidapi-rs.svg?branch=master)](https://travis-ci.org/Osspial/hidapi-rs) [![Version](https://img.shields.io/crates/v/hidapi.svg)](https://crates.io/crates/hidapi) [![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://github.com/Osspial/hidapi-rs/blob/master/LICENSE.txt) [![Documentation](https://docs.rs/hidapi/badge.svg)](https://docs.rs/hidapi)
22

33
This crate provides a rust abstraction over the features of the C library
44
[hidapi](https://github.com/signal11/hidapi) by signal11. Based off of
55
[hidapi_rust](https://github.com/ruabmbua/hidapi_rust) by ruabmbua.
66

77
# Usage
88

9-
This crate is [on crates.io](https://crates.io/crates/hidapi) and can be
9+
This crate is on [crates.io](https://crates.io/crates/hidapi) and can be
1010
used by adding `hidapi` to the dependencies in your project's `Cargo.toml`.
1111

1212
```toml
1313
[dependencies]
1414
hidapi = "0.3"
1515
```
16-
Example:
16+
# Example
1717

1818
```rust
1919
extern crate hidapi;
@@ -40,4 +40,4 @@ println!("Wrote: {:?} byte(s)", res);
4040
```
4141

4242
# Documentation
43-
You can generate documentation by running `cargo doc` for this crate.
43+
Available at [docs.rs](https://docs.rs/hidapi).

build.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
/****************************************************************************
2-
Copyright (c) 2015 Roland Ruckerbauer All Rights Reserved.
3-
4-
This file is part of hidapi_rust.
5-
6-
hidapi_rust is free software: you can redistribute it and/or modify
7-
it under the terms of the GNU General Public License as published by
8-
the Free Software Foundation, either version 3 of the License, or
9-
(at your option) any later version.
10-
11-
hidapi_rust is distributed in the hope that it will be useful,
12-
but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
GNU General Public License for more details.
15-
16-
You should have received a copy of the GNU General Public License
17-
along with hidapi_rust. If not, see <http://www.gnu.org/licenses/>.
18-
****************************************************************************/
1+
// **************************************************************************
2+
// Copyright (c) 2015 Roland Ruckerbauer All Rights Reserved.
3+
//
4+
// This file is part of hidapi_rust.
5+
//
6+
// hidapi_rust is free software: you can redistribute it and/or modify
7+
// it under the terms of the GNU General Public License as published by
8+
// the Free Software Foundation, either version 3 of the License, or
9+
// (at your option) any later version.
10+
//
11+
// hidapi_rust is distributed in the hope that it will be useful,
12+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
// GNU General Public License for more details.
15+
//
16+
// You should have received a copy of the GNU General Public License
17+
// along with hidapi_rust. If not, see <http://www.gnu.org/licenses/>.
18+
// *************************************************************************
1919

2020
extern crate gcc;
2121
extern crate pkg_config;
@@ -28,28 +28,28 @@ fn main() {
2828
fn compile() {
2929
let mut config = gcc::Config::new();
3030
config.file("etc/hidapi/libusb/hid.c").include("etc/hidapi/hidapi");
31-
let lib = pkg_config::find_library("libusb-1.0").unwrap();
31+
let lib = pkg_config::find_library("libusb-1.0").expect("Unable to find libusb-1.0");
3232
for path in lib.include_paths {
33-
config.include(path.to_str().unwrap());
33+
config.include(path.to_str().expect("Failed to convert include path to str"));
3434
}
3535
config.compile("libhidapi.a");
3636
}
3737

3838
#[cfg(target_os = "windows")]
3939
fn compile() {
4040
gcc::Config::new()
41-
.file("etc/hidapi/windows/hid.c")
42-
.include("etc/hidapi/hidapi")
43-
.compile("libhidapi.a");
41+
.file("etc/hidapi/windows/hid.c")
42+
.include("etc/hidapi/hidapi")
43+
.compile("libhidapi.a");
4444
println!("cargo:rustc-link-lib=setupapi");
4545
}
4646

4747
#[cfg(target_os = "macos")]
4848
fn compile() {
4949
gcc::Config::new()
50-
.file("etc/hidapi/mac/hid.c")
51-
.include("etc/hidapi/hidapi")
52-
.compile("libhidapi.a");
50+
.file("etc/hidapi/mac/hid.c")
51+
.include("etc/hidapi/hidapi")
52+
.compile("libhidapi.a");
5353
println!("cargo:rustc-link-lib=framework=IOKit");
5454
println!("cargo:rustc-link-lib=framework=CoreFoundation");
5555
}

src/ffi.rs

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
/****************************************************************************
2-
Copyright (c) 2015 Osspial All Rights Reserved.
3-
4-
This file is part of hidapi-rs, based on hidapi_rust by Roland Ruckerbauer.
5-
6-
hidapi-rs is free software: you can redistribute it and/or modify
7-
it under the terms of the GNU General Public License as published by
8-
the Free Software Foundation, either version 3 of the License, or
9-
(at your option) any later version.
10-
11-
hidapi-rs is distributed in the hope that it will be useful,
12-
but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
GNU General Public License for more details.
15-
16-
You should have received a copy of the GNU General Public License
17-
along with hidapi-rs. If not, see <http://www.gnu.org/licenses/>.
18-
****************************************************************************/
1+
/// **************************************************************************
2+
/// Copyright (c) 2015 Osspial All Rights Reserved.
3+
///
4+
/// This file is part of hidapi-rs, based on hidapi_rust by Roland Ruckerbauer.
5+
///
6+
/// hidapi-rs is free software: you can redistribute it and/or modify
7+
/// it under the terms of the GNU General Public License as published by
8+
/// the Free Software Foundation, either version 3 of the License, or
9+
/// (at your option) any later version.
10+
///
11+
/// hidapi-rs is distributed in the hope that it will be useful,
12+
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
/// GNU General Public License for more details.
15+
///
16+
/// You should have received a copy of the GNU General Public License
17+
/// along with hidapi-rs. If not, see <http://www.gnu.org/licenses/>.
18+
/// *************************************************************************
1919
2020
// For documentation look at the corresponding C header file hidapi.h
2121

@@ -44,26 +44,44 @@ extern "C" {
4444
pub fn hid_exit() -> c_int;
4545
pub fn hid_enumerate(vendor_id: c_ushort, product_id: c_ushort) -> *mut HidDeviceInfo;
4646
pub fn hid_free_enumeration(hid_device_info: *mut HidDeviceInfo);
47-
pub fn hid_open(vendor_id: c_ushort, product_id: c_ushort, serial_number: *const wchar_t)
48-
-> *mut HidDevice;
47+
pub fn hid_open(vendor_id: c_ushort,
48+
product_id: c_ushort,
49+
serial_number: *const wchar_t)
50+
-> *mut HidDevice;
4951
pub fn hid_open_path(path: *const c_char) -> *mut HidDevice;
5052
pub fn hid_write(device: *mut HidDevice, data: *const c_uchar, length: size_t) -> c_int;
51-
pub fn hid_read_timeout(device: *mut HidDevice, data: *mut c_uchar, length: size_t,
52-
milleseconds: c_int) -> c_int;
53+
pub fn hid_read_timeout(device: *mut HidDevice,
54+
data: *mut c_uchar,
55+
length: size_t,
56+
milleseconds: c_int)
57+
-> c_int;
5358
pub fn hid_read(device: *mut HidDevice, data: *mut c_uchar, length: size_t) -> c_int;
5459
pub fn hid_set_nonblocking(device: *mut HidDevice, nonblock: c_int) -> c_int;
55-
pub fn hid_send_feature_report(device: *mut HidDevice, data: *const c_uchar, length: size_t)
56-
-> c_int;
57-
pub fn hid_get_feature_report(device: *mut HidDevice, data: *mut c_uchar, length: size_t)
58-
-> c_int;
60+
pub fn hid_send_feature_report(device: *mut HidDevice,
61+
data: *const c_uchar,
62+
length: size_t)
63+
-> c_int;
64+
pub fn hid_get_feature_report(device: *mut HidDevice,
65+
data: *mut c_uchar,
66+
length: size_t)
67+
-> c_int;
5968
pub fn hid_close(device: *mut HidDevice);
60-
pub fn hid_get_manufacturer_string(device: *mut HidDevice, string: *mut wchar_t,
61-
maxlen: size_t) -> c_int;
62-
pub fn hid_get_product_string(device: *mut HidDevice, string: *mut wchar_t, maxlen: size_t)
63-
-> c_int;
64-
pub fn hid_get_serial_number_string(device: *mut HidDevice, string: *mut wchar_t,
65-
maxlen: size_t) -> c_int;
66-
pub fn hid_get_indexed_string(device: *mut HidDevice, string_index: c_int,
67-
string: *mut wchar_t, maxlen: size_t) -> c_int;
69+
pub fn hid_get_manufacturer_string(device: *mut HidDevice,
70+
string: *mut wchar_t,
71+
maxlen: size_t)
72+
-> c_int;
73+
pub fn hid_get_product_string(device: *mut HidDevice,
74+
string: *mut wchar_t,
75+
maxlen: size_t)
76+
-> c_int;
77+
pub fn hid_get_serial_number_string(device: *mut HidDevice,
78+
string: *mut wchar_t,
79+
maxlen: size_t)
80+
-> c_int;
81+
pub fn hid_get_indexed_string(device: *mut HidDevice,
82+
string_index: c_int,
83+
string: *mut wchar_t,
84+
maxlen: size_t)
85+
-> c_int;
6886
pub fn hid_error(device: *mut HidDevice) -> *const wchar_t;
6987
}

0 commit comments

Comments
 (0)