libatk-rs
libatk-rs is a Rust library that provides an abstraction over the reverse engineered ATK Mouse communication protocol, enabling others to easily communicate with and configure their devices. It offers a simple and type-safe interface for constructing commands and interacting with HID devices via the hidapi crate.
Modules
-
command Provides the
Commandstruct and theCommandDescriptortrait. The trait defines properties required for constructing command messages, such as data offsets, report IDs, and overall command lengths. TheCommandstruct encapsulates all command fields (command ID, status, EEPROM address, payload, and checksum) along with methods for data updates and serialization. -
device Contains the
Devicestruct which wraps around a HID device from thehidapicrate. It offers high-level functions to send commands and read responses from the device. The sending functionality automatically prepends the required report ID before writing to the device. -
types Contains values for
CommandIdandEEPROMAddressthat were reverse engineered from the ATK Mouse communication protocol.
Usage
Add libatk-rs to your Cargo.toml:
[]
= "0.1.0" # replace with the current version
Below is a simple example of how to use libatk-rs in your project:
use *;
// Replace these with actual vendor, product, usage_page, and usage values.
let vendor_id = 0x1234;
let product_id = 0x5678;
let usage_page = 0xFF00;
let usage = 0x01;
// Create a new device instance.
let device = new
.expect;
// Create a default command (your specific command type must implement CommandDescriptor).
let mut command = default;
// Modify command fields as required.
command.set_id;
command.set_status;
command.set_eeprom_address;
command.set_data_len;
// Optionally, you can update data payload.
command.set_data
.expect;
println!;
// Send the command to the device.
device.send
.expect;
// Read a response from the device.
let response = device.read.expect;
println!;
Implementing a new Command
To create a new command, you need to define a struct that implements the CommandDescriptor trait. This trait requires you to define the base offset, report ID, and command length for the command.
The following examples shows implementing GetBatteryStatus command for VXE R1 Pro:
use *;
]
;
Contributing
Contributions are welcome! Please follow standard Rust coding conventions and include tests for new features or bug fixes. Pull requests should be aimed at keeping the code clean and maintainable.
License
This project is licensed under the GPLv3 License. See the LICENSE file for details.