1个不稳定版本
0.1.0 | 2020年8月27日 |
---|
#1411 in 异步
59KB
1.5K SLoC
openrazer-rs
使用纯Rust编写的对 OpenRazer 守护进程的异步绑定。API与Python模块 openrazer
类似。以下是一个将波浪效果应用于所有设备的示例
use openrazer::{devices::GenericMethods, DeviceManager, Error::UnsupportedCapability};
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
let manager = DeviceManager::new().await?;
manager.sync_effects().disable().await?;
let devices = manager.devices().await?;
println!("Found {} Razer devices", devices.len());
for device in devices {
println!("Setting wave effect for {}", device.name().await?);
device.wave_effect().ok_or(UnsupportedCapability)?.right().await?;
}
Ok(())
}
仓库中还有其他 示例。
免责声明
我编写了这个crate来满足自己的需求:更改我的Razer Huntsman键盘的照明模式。这是我所拥有的唯一一个Razer设备,并且我可以在这个设备上测试这个crate,因此我没有添加我的键盘不支持的功能的绑定。但是,实现的功能将适用于任何支持它们的所有设备,并且添加新的绑定也很容易,所以欢迎提交合并请求!
依赖项
~12MB
~215K SLoC