{"id":18041623,"url":"https://github.com/katyo/hidg-rs","last_synced_at":"2025-04-09T19:21:38.493Z","repository":{"id":66335206,"uuid":"539620607","full_name":"katyo/hidg-rs","owner":"katyo","description":"Linux HID Gadget Emulation in Rust","archived":false,"fork":false,"pushed_at":"2024-05-11T04:58:55.000Z","size":73,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T04:45:24.224Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/katyo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-21T18:00:33.000Z","updated_at":"2025-02-22T10:59:19.000Z","dependencies_parsed_at":"2024-10-30T16:21:13.127Z","dependency_job_id":null,"html_url":"https://github.com/katyo/hidg-rs","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katyo%2Fhidg-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katyo%2Fhidg-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katyo%2Fhidg-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katyo%2Fhidg-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/katyo","download_url":"https://codeload.github.com/katyo/hidg-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248095260,"owners_count":21046820,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-30T16:11:04.247Z","updated_at":"2025-04-09T19:21:38.457Z","avatar_url":"https://github.com/katyo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HID Gadget Emulation in Rust\n\n[![github](https://img.shields.io/badge/github-katyo/hidg--rs-8da0cb.svg?style=for-the-badge\u0026logo=github)](https://github.com/katyo/hidg-rs)\n[![crate](https://img.shields.io/crates/v/hidg.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust)](https://crates.io/crates/hidg)\n[![docs](https://img.shields.io/badge/docs.rs-hidg-66c2a5?style=for-the-badge\u0026logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K)](https://docs.rs/hidg)\n[![MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)\n[![CI](https://img.shields.io/github/actions/workflow/status/katyo/hidg-rs/ci.yml?branch=master\u0026style=for-the-badge\u0026logo=github-actions\u0026logoColor=white)](https://github.com/katyo/hidg-rs/actions?query=workflow%3ARust)\n\nRust crate for interfacing with Linux HID Gadget devices (/dev/hidgX).\n\nSince all functionality is dependent on Linux function calls, this crate only compiles for Linux systems.\n\n## Crates\n\n- [hidg-core](https://crates.io/crates/hidg-core) - core abstractions and low level interface (not for end users)\n- **[hidg](https://crates.io/crates/hidg)** - std interface which supports synchronous operation only\n- [tokio-hidg](https://crates.io/crates/tokio-hidg) - async interface for [tokio](https://tokio.rs/) runtime\n- [async-hidg](https://crates.io/crates/async-hidg) - async interface for other runtimes\n\n## Features\n\n- *fromstr* - implements [core::str::FromStr] implementation for some types\n- *display* - implements [std::fmt::Display] implementation for some types\n- *phf* - use [phf](https://crates.io/crates/phf) in [core::str::FromStr] trait implementations\n- *serde* - enables [serde](https://crates.io/crates/serde) support for some types\n- *keyboard* - enables keyboard class support\n- *mouse* - enables mouse class support\n\n## Usage examples\n\nKeyboard input simulation:\n\n```rust,no_run\nuse hidg::{Class, Device, Keyboard, Key, Led, StateChange};\n\nfn main() -\u003e std::io::Result\u003c()\u003e {\n    let mut device = Device::\u003cKeyboard\u003e::open(0)?; // open device\n\n    // Create input report\n    let mut input = Keyboard.input();\n\n    // Press left ctrl modifier\n    input.press_key(Key::LeftCtrl);\n\n    // Press key 'A'\n    input.press_key(Key::A);\n\n    // Send input report\n    device.input(\u0026input)?;\n\n    // Get pressed keys\n    println!(\"Keys: {:?}\", input.pressed().collect::\u003cVec\u003cKey\u003e\u003e());\n\n    // Release left ctrl modifier\n    input.release_key(Key::LeftCtrl);\n\n    // Release key 'A'\n    input.release_key(Key::A);\n\n    // Send input report\n    device.input(\u0026input)?;\n\n    // Create output report\n    let mut output = Keyboard.output();\n\n    // Receive output report\n    device.output(\u0026mut output)?;\n\n    // Print lit LEDs\n    println!(\"LEDs: {:?}\", output.lit().collect::\u003cVec\u003cLed\u003e\u003e());\n\n    Ok(())\n}\n```\n\nMouse input simulation:\n\n```rust,no_run\nuse hidg::{Button, Class, Device, Mouse, StateChange, ValueChange};\n\nfn main() -\u003e std::io::Result\u003c()\u003e {\n    let mut device = Device::\u003cMouse\u003e::open(\"hidg0\")?; // open device\n\n    // Create input report\n    let mut input = Mouse.input();\n\n    // Press primary button\n    input.press_button(Button::Primary);\n\n    // Update pointer coordinates\n    input.change_pointer((150, 50), false);\n\n    // Send input report\n    device.input(\u0026input)?;\n\n    // Move pointer relatively\n    input.change_pointer((70, -30), true);\n\n    // Get pressed buttons\n    println!(\"Buttons: {:?}\", input.pressed().collect::\u003cVec\u003cButton\u003e\u003e());\n\n    // Release primary button\n    input.release_button(Button::Primary);\n\n    // Send input report\n    device.input(\u0026input)?;\n\n    Ok(())\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatyo%2Fhidg-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkatyo%2Fhidg-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatyo%2Fhidg-rs/lists"}