add yaml configuration
Example: %YAML 1.2 --- longpress_ms: 600 repeat_ms: 25 layout: latn_qwerty_us.xml wayland: height: 185
This commit is contained in:
parent
7d36dfaf89
commit
d884e71d86
10 changed files with 42 additions and 33 deletions
|
|
@ -3,6 +3,7 @@
|
|||
* Copyright (c) 2024, Richard Acayan. All rights reserved.
|
||||
*/
|
||||
|
||||
use crate::core::Configuration;
|
||||
use crate::core::Display;
|
||||
use crate::core::Graphics;
|
||||
use crate::core::Layout;
|
||||
|
|
@ -164,7 +165,8 @@ const ANGLE_PARTS: [[usize; 4]; 16] = [
|
|||
const NO_PRESS: Option<Press> = None;
|
||||
|
||||
impl<D: Display, K: Keyboard> Button<D, K> {
|
||||
pub fn new(mut layout: Layout, mut kbd: K,
|
||||
pub fn new(cfg: &Configuration,
|
||||
mut layout: Layout, mut kbd: K,
|
||||
gfx: Arc<Mutex<Graphics<D>>>) -> Button<D, K>
|
||||
{
|
||||
kbd.change_layout(&layout);
|
||||
|
|
@ -179,8 +181,8 @@ impl<D: Display, K: Keyboard> Button<D, K> {
|
|||
modifiers: [ModState::Released; MODIFIERS_MAX],
|
||||
timers: VecDeque::with_capacity(PRESSES_MAX),
|
||||
|
||||
longpress: Duration::from_millis(600),
|
||||
repeat: Duration::from_millis(25),
|
||||
longpress: Duration::from_millis(cfg.longpress_ms()),
|
||||
repeat: Duration::from_millis(cfg.repeat_ms()),
|
||||
r_square: 0.25,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
* Copyright (c) 2024, Richard Acayan. All rights reserved.
|
||||
*/
|
||||
|
||||
use crate::core::Configuration;
|
||||
use crate::core::Keyboard;
|
||||
use crate::core::button::ModState;
|
||||
use crate::core::ModState;
|
||||
use crate::core::expat;
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashMap;
|
||||
|
|
@ -634,7 +635,7 @@ impl Layout {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn load(dir: &Path, filename: &str) -> Result<Self, Error>
|
||||
pub fn load(cfg: &Configuration) -> Result<Self, Error>
|
||||
{
|
||||
let mut layout = Layout {
|
||||
rows: Vec::new(),
|
||||
|
|
@ -645,8 +646,10 @@ impl Layout {
|
|||
text_supp: false,
|
||||
};
|
||||
|
||||
let dir = Path::new("/usr/share/unfettered-keyboard/layouts");
|
||||
|
||||
let mut vec = Vec::new();
|
||||
let path = dir.join(filename);
|
||||
let path = dir.join(cfg.layout());
|
||||
let mut file = File::open(path)?;
|
||||
file.read_to_end(&mut vec)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
|
||||
mod button;
|
||||
mod config;
|
||||
mod expat;
|
||||
mod graphics;
|
||||
mod layout;
|
||||
|
|
@ -11,6 +12,7 @@ mod layout;
|
|||
pub use self::button::Button;
|
||||
pub use self::button::Keyboard;
|
||||
pub use self::button::ModState;
|
||||
pub use self::config::Configuration;
|
||||
pub use self::graphics::Display;
|
||||
pub use self::graphics::Graphics;
|
||||
pub use self::layout::Layout;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue