This repository has been archived on 2026-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
macropad-rs/src/keysend.rs

31 lines
964 B
Rust

//! Module: keysend.rs
//!
//! This module handles the sending of keypresses to the computer.
//!
//! It provides functionality for simulating keypress events and sending them to the computer's operating system
//! or other applications. This can involve low-level system calls or interacting with platform-specific APIs.
//!
//! Example Usage:
//! ```
//! use keysend::KeysendManager;
//!
//! let mut keysend_manager = KeysendManager::new();
//! keysend_manager.send_keypress('A'); // Simulate sending a keypress event for the letter 'A'
//! ```
use usbd_hid::descriptor::KeyboardReport;
use crate::{keyboard::KeyCode, ChannelType};
pub(crate) async fn send_keypress(list_key: &[KeyCode], sender: &ChannelType) {
for key in list_key.iter() {
let report = KeyboardReport {
keycodes: [*key as u8, 0, 0, 0, 0, 0],
leds: 0,
modifier: 0,
reserved: 0,
};
sender.send(report).await;
}
}