WIP WIP: keymap generation test passes meta: Update features and version WiP: cargo.lock WIP: don't crash WIP: no outlines parsing: New tests WIP: base level works WIP: remove old keyboard symbols correctly input WIP: lodaing files WIP: fallback works Valid fallback
56 lines
1.2 KiB
Rust
56 lines
1.2 KiB
Rust
/*! The symbol object, defining actions that the key can do when activated */
|
|
|
|
use std::ffi::CString;
|
|
|
|
/// Just defines some int->identifier mappings for convenience
|
|
#[derive(Debug, Clone)]
|
|
pub enum KeySym {
|
|
Unknown = 0,
|
|
Shift = 0xffe1,
|
|
}
|
|
|
|
impl KeySym {
|
|
pub fn from_u32(num: u32) -> KeySym {
|
|
match num {
|
|
0xffe1 => KeySym::Shift,
|
|
_ => KeySym::Unknown,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct XKeySym(pub u32);
|
|
|
|
/// Use to switch layouts
|
|
type Level = u8;
|
|
|
|
/// Use to send modified keypresses
|
|
#[derive(Debug, Clone)]
|
|
pub enum Modifier {
|
|
Control,
|
|
Alt,
|
|
}
|
|
|
|
/// Action to perform on the keypress and, in reverse, on keyrelease
|
|
#[derive(Debug, Clone)]
|
|
pub enum Action {
|
|
/// Switch to this level TODO: reverse?
|
|
SetLevel(Level),
|
|
/// Set this modifier TODO: release?
|
|
SetModifier(Modifier),
|
|
/// Submit some text
|
|
Submit {
|
|
/// Text to submit with input-method
|
|
text: Option<CString>,
|
|
/// The key events this symbol submits when submitting text is not possible
|
|
keys: Vec<XKeySym>,
|
|
},
|
|
}
|
|
|
|
/// Contains a static description of a particular key's actions
|
|
#[derive(Debug, Clone)]
|
|
pub struct Symbol {
|
|
/// The action that this key performs
|
|
pub action: Action,
|
|
}
|