continue without keymap (#18)

This commit is contained in:
Ferdinand Schober
2023-09-12 12:17:44 +02:00
committed by GitHub
parent fae710aab6
commit 31eead5f8e

View File

@@ -120,18 +120,20 @@ impl App {
let keyboard: Vk = vkm.create_virtual_keyboard(&self.seat, &self.qh, ()); let keyboard: Vk = vkm.create_virtual_keyboard(&self.seat, &self.qh, ());
// receive keymap from device // receive keymap from device
eprint!("\rconnecting to {} ", client.addr); eprint!("\rtrying to recieve keymap from {} ", client.addr);
let mut attempts = 0; let mut attempts = 0;
let data = loop { let data = loop {
if attempts > 10 { break None }
let result = request::request_data(client.addr, Request::KeyMap); let result = request::request_data(client.addr, Request::KeyMap);
eprint!("\rconnecting to {} ", client.addr); eprint!("\rtrying to recieve keymap from {} ", client.addr);
for _ in 0..attempts { match result {
Ok(data) => break Some(data),
Err(e) => {
eprint!(" - {} ", e);
for _ in 0..attempts % 4 {
eprint!("."); eprint!(".");
} }
match result { eprint!(" ");
Ok(data) => break data,
Err(e) => {
eprint!(" - {}", e);
} }
} }
io::stderr().flush().unwrap(); io::stderr().flush().unwrap();
@@ -139,11 +141,9 @@ impl App {
attempts += 1; attempts += 1;
}; };
eprint!("\rconnecting to {} ", client.addr); if let Some(data) = data {
for _ in 0..attempts { eprint!("\rtrying to recieve keymap from {} ", client.addr);
eprint!("."); eprintln!(" - done! ");
}
eprintln!(" done! ");
// TODO use shm_open // TODO use shm_open
let f = tempfile::tempfile().unwrap(); let f = tempfile::tempfile().unwrap();
@@ -151,6 +151,11 @@ impl App {
buf.write_all(&data[..]).unwrap(); buf.write_all(&data[..]).unwrap();
buf.flush().unwrap(); buf.flush().unwrap();
keyboard.keymap(1, f.as_raw_fd(), data.len() as u32); keyboard.keymap(1, f.as_raw_fd(), data.len() as u32);
} else {
eprint!("\rtrying to recieve keymap from {} ", client.addr);
eprintln!("no keyboard provided, using server keymap");
}
let vinput = VirtualInput::Wlroots { pointer, keyboard }; let vinput = VirtualInput::Wlroots { pointer, keyboard };