Skip to content

srwi/qmk-via-api

Repository files navigation

qmk-via-api

Versionimageimage

qmk-via-api provides an implementation of the VIA API for QMK (Quantum Mechanical Keyboard) based keyboards. It allows developers to interact with QMK keyboards programmatically, enabling tasks such as configuring keymaps, macros, lighting effects and more.

Additionally, this library includes Python bindings for all API calls for integration of QMK keyboard configuration into Python-based applications or scripts.

Usage

Rust

Add dependency with Cargo:

cargo add qmk-via-api

Usage example:

use qmk_via_api::{api::KeyboardApi, scan::scan_keyboards};fnmain(){ifletSome(dev) = scan_keyboards().first(){let api = KeyboardApi::new(dev.vendor_id, dev.product_id, dev.usage_page).unwrap();println!("Protocol version:{:?}", api.get_protocol_version());println!("Layer count:{:?}", api.get_layer_count());}else{println!("No devices found");}}

Disable Python Bindings

The python feature flag is enabled by default. In projects that don't interoperate with Python, the Python bindings can be disabled by turning off default features. In Cargo.toml:

[dependencies] qmk-via-api ={version = "0.3.0", default-features = false }

Python

Install with pip:

pip install qmk-via-api

Usage example:

importqmk_via_apifromqmk_via_apiimportscan_keyboardsdevices=scan_keyboards() ifdevices: dev=devices[0] api=qmk_via_api.KeyboardApi(dev.vendor_id, dev.product_id, dev.usage_page) print(f"Protocol version {api.get_protocol_version()}") print(f"Layers count: {api.get_layer_count()}") else: print("No devices found")

License & Attribution

Parts of this project are based on code from the VIA project, which is licensed under the GNU General Public License v3.0.

About

VIA api implementation for QMK-based keyboards

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages