add evfb (evdev + fbdev) backend

Outside of a terminal emulator or web browser, this typing experience
can be useful outside the DE, such as in the TTY or when entering a
password for full-disk encryption. Add a target that uses the bare
hardware to allow the keyboard to be deployed in more flexible
environments.
This commit is contained in:
Richard Acayan 2025-07-21 19:01:23 -04:00
parent 9b893e474d
commit 7b38edb656
12 changed files with 866 additions and 0 deletions

View file

@ -60,6 +60,7 @@ pub struct Configuration {
repeat: u64,
layout: String,
extra_keys: Vec<String>,
evfb_height: f64,
wayland_height: i32,
wayland_im_enable: bool,
@ -67,6 +68,19 @@ pub struct Configuration {
}
impl Configuration {
fn load_evfb(&mut self, yaml: &Hash)
{
let height = yaml.get(&Yaml::String(String::from("height")));
if let Some(height) = height {
let height = match height.as_f64() {
Some(h) => h.try_into().ok(),
None => None,
};
let height = height.expect("Linux evdev-fbdev height should be a fraction from 0 to 1");
self.evfb_height = height;
}
}
fn load_wayland(&mut self, yaml: &Hash)
{
let height = yaml.get(&Yaml::String(String::from("height")));
@ -135,6 +149,7 @@ impl Configuration {
extra_keys: vec![ String::from("alt"), String::from("meta") ],
wayland_height: 185,
wayland_im_enable: true,
evfb_height: 0.25,
colors: KeyboardColors::default(),
};
@ -182,6 +197,12 @@ impl Configuration {
cfg.load_wayland(wl);
}
let evfb = yaml.get(&Yaml::String(String::from("evfb")));
if let Some(evfb) = evfb {
let evfb = evfb.as_hash().expect("Linux evdev-fbdev configuration should be a YAML mapping");
cfg.load_evfb(evfb);
}
let colors = yaml.get(&Yaml::String(String::from("colors")));
if let Some(colors) = colors {
let colors = colors.as_hash().expect("Color configuration should be a YAML mapping");
@ -228,6 +249,12 @@ impl Configuration {
self.wayland_im_enable
}
#[inline(always)]
pub fn evfb_height(&self) -> f64
{
self.evfb_height
}
#[inline(always)]
pub fn colors(&self) -> &KeyboardColors
{