1 stable release

Uses old Rust 2015

1.2.1 Apr 27, 2020

#1883 in Hardware support

MIT license

220KB
5.5K SLoC

C 3K SLoC // 0.2% comments Rust 669 SLoC // 0.1% comments C++ 632 SLoC // 0.1% comments Visual Studio Project 614 SLoC M4 268 SLoC // 0.4% comments Automake 158 SLoC // 0.0% comments Objective-C 64 SLoC // 0.2% comments Shell 56 SLoC // 0.3% comments Visual Studio Solution 49 SLoC HICAD 36 SLoC

Contains (obscure autoconf code, 7KB) etc/hidapi/configure.ac

Notice

This is fork of hidapi-rs. hidapi-rs is wrapper of hidapi. Due to the effect of hidapi's Issue, latest hidapi-rs can't open multiple JoyCons on macOS. The pull request for bug fixes has not yet been merged. This repository provides hidapi-rs with its modified hidapi fork.

hidapi Build Status Version License: MIT Documentation Chat

This crate provides a rust abstraction over the features of the C library hidapi. Based off of hidapi-rs by Osspial.

Usage

This crate is on crates.io and can be used by adding hidapi to the dependencies in your project's Cargo.toml.

Example

extern crate hidapi;

let api = hidapi::HidApi::new().unwrap();
// Print out information about all connected devices
for device in api.devices() {
    println!("{:#?}", device);
}

// Connect to device using its VID and PID
let (VID, PID) = (0x0123, 0x3456);
let device = api.open(VID, PID).unwrap();

// Read data from device
let mut buf = [0u8; 8];
let res = device.read(&mut buf[..]).unwrap();
println!("Read: {:?}", &buf[..res]);

// Write data to device
let buf = [0u8, 1, 2, 3, 4];
let res = device.write(&buf).unwrap();
println!("Wrote: {:?} byte(s)", res);

Documentation

Available at docs.rs.

Dependencies