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:
Richard Acayan 2024-08-08 17:51:56 -04:00
parent 7d36dfaf89
commit d884e71d86
10 changed files with 42 additions and 33 deletions

View file

@ -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)?;