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/keypress.rs

53 lines
1.4 KiB
Rust

//! Module: keypress.rs
//!
//! This module is responsible for gathering keypresses and sending them to the dispatch module for analysis.
//!
//! It provides functionality for capturing keypress events from the physical keyboard or any other input source,
//! accumulating them, and passing them to the dispatch module for further processing.
//!
//! Example Usage:
//! ```
//! use keypress::KeypressManager;
//!
//! let mut keypress_manager = KeypressManager::new();
//! keypress_manager.start_capture(); // Start capturing keypresses
//!
//! // Somewhere in the loop...
//! keypress_manager.capture_keypress('A'); // Captures a keypress event for the letter 'A'
//! ```
use core::sync::atomic::AtomicU32;
pub(crate) static KEYMASK: AtomicU32 = AtomicU32::new(0);
#[repr(u32)]
pub(crate) enum Keyboard {
A1 = 1,
A2 = 1 << 1,
A3 = 1 << 2,
A4 = 1 << 3,
B1 = 1 << 4,
B2 = 1 << 5,
B3 = 1 << 6,
B4 = 1 << 7,
C1 = 1 << 8,
C2 = 1 << 9,
C3 = 1 << 10,
C4 = 1 << 11,
}
#[repr(u32)]
enum KeyboardMask {
A1 = 0b111111111111 - (1 << 0),
A2 = 0b111111111111 - (1 << 1),
A3 = 0b111111111111 - (1 << 2),
A4 = 0b111111111111 - (1 << 3),
B1 = 0b111111111111 - (1 << 4),
B2 = 0b111111111111 - (1 << 5),
B3 = 0b111111111111 - (1 << 6),
B4 = 0b111111111111 - (1 << 7),
C1 = 0b111111111111 - (1 << 8),
C2 = 0b111111111111 - (1 << 9),
C3 = 0b111111111111 - (1 << 10),
C4 = 0b111111111111 - (1 << 11),
}