Signed-off-by: Frank Villaro-Dixon <frank@villaro-dixon.eu>
This commit is contained in:
Frank Villaro-Dixon 2024-05-08 23:21:27 +02:00
parent 65088be75c
commit 8341b9d54c
5 changed files with 13 additions and 44 deletions

View file

@ -21,11 +21,7 @@ use winit::{event_loop::EventLoop, window::WindowBuilder};
mod perf_graph;
pub use perf_graph::PerfGraph;
pub fn start(
width: u32,
height: u32,
title: &'static str,
) {
pub fn start(width: u32, height: u32, title: &'static str) {
// This provides better error messages in debug mode.
// It's disabled in release mode so it doesn't bloat up the file size.
#[cfg(all(debug_assertions, target_arch = "wasm32"))]
@ -114,12 +110,5 @@ pub fn start(
(canvas, window, gl_context, surface)
};
run(
canvas,
event_loop,
context,
surface,
window,
);
run(canvas, event_loop, context, surface, window);
}

View file

@ -1,16 +1,12 @@
use core::panic;
use nix::{
fcntl::{FcntlArg, OFlag},
sys::epoll,
};
use std::{
collections::VecDeque,
io,
os::fd::{AsRawFd, FromRawFd, OwnedFd},
};
use evdev;
const LASER_POINTER_MAX: i32 = 121;
#[derive(Debug)]
pub enum Beo5Event {
@ -93,7 +89,7 @@ impl Beo5Device {
}
}
Err(x) => {
if (x.kind() == std::io::ErrorKind::WouldBlock) {
if x.kind() == std::io::ErrorKind::WouldBlock {
// Wait forever for bytes available on raw_fd
let mut events = [epoll::EpollEvent::empty(); 2];
epoll::epoll_wait(8, &mut events, -1);
@ -107,7 +103,7 @@ impl Beo5Device {
if ev.is_some() {
return Beo5Device::parse_event(ev.unwrap());
}
return None;
None
}
fn parse_event(ev: evdev::InputEvent) -> Option<Beo5Event> {
@ -177,6 +173,6 @@ impl Beo5Device {
}
_ => {} //SYN et al
}
return None;
None
}
}

View file

@ -1,6 +1,5 @@
use femtovg::{
renderer::OpenGl, Align, Baseline, Canvas, Color, FontId, ImageFlags, ImageId, Paint, Path,
Renderer,
renderer::OpenGl, Align, Baseline, Canvas, Color, FontId, ImageId, Paint, Path, Renderer,
};
use instant::Instant;
use resource::resource;
@ -75,7 +74,7 @@ fn run(
let mut t = 0;
el.run(move |event, _, control_flow| {
t = t + 1;
t += 1;
*control_flow = ControlFlow::Poll;
let hw_event = beo_device.get_event_nonblocking();

View file

@ -55,7 +55,7 @@ impl VirtualCircle {
pub fn get_x_on_circle(&self, y: f32) -> f32 {
// Given an x coordinate, return the y coordinate so that it lies on the circle
let x = self.center.x - (self.radius.powf(2.) - (y - self.center.y).powf(2.)).sqrt();
x as f32
self.center.x - (self.radius.powf(2.) - (y - self.center.y).powf(2.)).sqrt()
}
}

View file

@ -50,12 +50,7 @@ impl Beo {
paint_title.set_text_baseline(Baseline::Top);
paint_title.set_text_align(Align::Center);
paint_title.set_font_size(20.);
let _ = canvas.fill_text(
CANVAS_WIDTH / 2.,
10.,
format!("{}", selected_app.name()),
&paint_title,
);
let _ = canvas.fill_text(CANVAS_WIDTH / 2., 10., selected_app.name(), &paint_title);
}
}
@ -75,7 +70,7 @@ impl Beo {
return Some(i);
}
}
return None;
None
}
fn draw_main_menu<T: Renderer>(&self, canvas: &mut Canvas<T>, fonts: &Fonts) {
@ -109,19 +104,9 @@ impl Beo {
paint_selected.set_text_baseline(Baseline::Top);
for i in 0..apps.len() {
if self.lasered_application_id() == Some(i) {
let _ = canvas.fill_text(
pts[i].x as f32,
pts[i].y as f32,
format!("{}", apps[i].name()),
&paint_selected,
);
let _ = canvas.fill_text(pts[i].x, pts[i].y, apps[i].name(), &paint_selected);
} else {
let _ = canvas.fill_text(
pts[i].x as f32,
pts[i].y as f32,
format!("{}", apps[i].name()),
&paint_normal,
);
let _ = canvas.fill_text(pts[i].x, pts[i].y, apps[i].name(), &paint_normal);
}
}