https://github.com/mamantoha/crystal-hidapi
A Crystal interface to HIDAPI library.
https://github.com/mamantoha/crystal-hidapi
crystal hidapi
Last synced: 4 months ago
JSON representation
A Crystal interface to HIDAPI library.
- Host: GitHub
- URL: https://github.com/mamantoha/crystal-hidapi
- Owner: mamantoha
- License: mit
- Created: 2023-03-13T10:57:15.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-09T16:38:34.000Z (over 1 year ago)
- Last Synced: 2025-02-27T14:32:28.471Z (12 months ago)
- Topics: crystal, hidapi
- Language: Crystal
- Homepage:
- Size: 27.3 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# crystal-hidapi
[](https://github.com/mamantoha/crystal-hidapi/actions/workflows/crystal.yml)
A Crystal interface to [HIDAPI](https://github.com/libusb/hidapi) library.
It works on Linux and macOS.
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
crystal-hidapi:
github: mamantoha/crystal-hidapi
```
2. Run `shards install`
### Compile time dependencies
You need to install the development package for `hidapi`
- macOS: `brew install hidapi`
- Arch Linux: `pacman -S hidapi`
- Ubuntu: `apt install libhidapi-dev`
## Usage
```crystal
require "crystal-hidapi"
```
### Sample Usage
Explore the following examples:
- [Retrieve battery level for Sony PlayStation 5 DualSense controller](samples/dualsense_battery.cr)
- [Fetch battery capacity and status for Sony DualShock4 (2nd gen) controller](samples/dualshock4_battery.cr)
## Development
```
crystal ./lib/crystal_lib/src/main.cr src/hidapi/lib_hidapi.cr.in > src/hidapi/lib_hidapi.cr
```
## External Resources Usage
- [libusb's hidapi on GitHub](https://github.com/libusb/hidapi)
- [hidapi header file](https://github.com/libusb/hidapi/blob/master/hidapi/hidapi.h)
- [hidapi test code](https://github.com/libusb/hidapi/blob/master/hidtest/test.c)
- [hidapitester code by todbot](https://github.com/todbot/hidapitester/blob/master/hidapitester.c)
## Contributing
1. Fork it ()
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
## Contributors
- [Anton Maminov](https://github.com/mamantoha) - creator and maintainer