diff --git a/Cargo.toml b/Cargo.toml index 68f2153..b21646e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,26 +10,26 @@ exclude = [ "reference-material/*", "legacy-c-impl/*", "private/*" ] edition = "2021" [dependencies] -log = "0.4.14" -once_cell = "1.9.0" +log = "0.4.22" +once_cell = "1.19.0" atomic = "0.5.1" cgmath = "0.18.0" libc = "0.2.69" # framebuffer -memmap2 = { version = "0.5.2", optional = true } +memmap2 = { version = "0.9.4", optional = true } ioctl-gen = { version = "0.1.1", optional = true } -zstd = { version = "0.9.0", optional = true } +zstd = { version = "0.13.2", optional = true } # framebuffer-drawing -rusttype = { version = "0.9.2", optional = true } -image = { version = "0.23.14", optional = true } +rusttype = { version = "0.9.3", optional = true } +image = { version = "0.25.2", optional = true } line_drawing = { version = "1.0.0", optional = true } # input -evdev = { version = "0.12.1", optional = true } -epoll = { version = "4.3.1", optional = true } +evdev = { version = "0.12.2", optional = true } +epoll = { version = "4.3.3", optional = true } fxhash = { version = "0.2.1", optional = true } # appctx @@ -39,7 +39,7 @@ aabb-quadtree = { version = "0.1.0", optional = true } hlua = { git = "https://github.com/fenollp/hlua.git", rev = "f327e79", optional = true } # hlua = { version = "0.4.1", optional = true } TODO: https://github.com/tomaka/hlua/pull/223 # runtime benchmarking -stopwatch = { version = "0.0.7", optional = true } +stopwatch = { git = "https://github.com/jwpjrdev/rust-stopwatch.git", rev = "dd9adfef", optional = true } # https://github.com/ellisonch/rust-stopwatch/pull/18 # stopwatch = { version = "0.0.7", optional = true } [features] default = ["scan", "framebuffer-types", "framebuffer", "framebuffer-storage", "framebuffer-drawing", "image", "framebuffer-text-drawing", "input-types", "input", "battery", "appctx", "hlua"] @@ -81,12 +81,11 @@ path = "examples/live.rs" crate-type = ["bin"] [dev-dependencies] -env_logger = "0.10.0" +env_logger = "0.11.5" # For spy redhook = "2.0.0" -libc = "0.2.69" # For demo -chrono = "0.4.26" +chrono = "0.4.38" # For live tiny_http = "0.12.0" # For screenshot diff --git a/examples/live.rs b/examples/live.rs index 84bfab7..3778f6f 100644 --- a/examples/live.rs +++ b/examples/live.rs @@ -1,7 +1,8 @@ -use image::{ +use image::codecs::{ bmp::BmpEncoder, gif::GifEncoder, jpeg::JpegEncoder, png::PngEncoder, tga::TgaEncoder, - ColorType::Rgb8, ImageFormat, }; +use image::ImageEncoder; +use image::{ExtendedColorType::Rgb8, ImageFormat}; use libremarkable::framebuffer; use libremarkable::framebuffer::common::{DISPLAYHEIGHT, DISPLAYWIDTH}; use libremarkable::framebuffer::core::Framebuffer; @@ -76,7 +77,7 @@ fn encode(img_buf: &[u8], format: ImageFormat) -> Vec { ImageFormat::Bmp => BmpEncoder::new(&mut writer).encode(img_buf, width, height, Rgb8), ImageFormat::Gif => GifEncoder::new(&mut writer).encode(img_buf, width, height, Rgb8), ImageFormat::Jpeg => JpegEncoder::new(&mut writer).encode(img_buf, width, height, Rgb8), - ImageFormat::Png => PngEncoder::new(&mut writer).encode(img_buf, width, height, Rgb8), + ImageFormat::Png => PngEncoder::new(&mut writer).write_image(img_buf, width, height, Rgb8), ImageFormat::Tga => TgaEncoder::new(&mut writer).encode(img_buf, width, height, Rgb8), _ => unimplemented!(), } diff --git a/examples/screenshot.rs b/examples/screenshot.rs index 62b2a7e..1e37eee 100644 --- a/examples/screenshot.rs +++ b/examples/screenshot.rs @@ -1,4 +1,4 @@ -use image::{DynamicImage, ImageOutputFormat}; +use image::{DynamicImage, ImageFormat}; use libremarkable::framebuffer::common::*; use libremarkable::framebuffer::core::*; @@ -27,25 +27,17 @@ fn main() { let image = RgbImage::from_raw(width, height, contents).expect("unable to construct the rgb image"); - let args = std::env::args().collect::>(); + let Some(path) = std::env::args().nth(1) else { + panic!("First argument must be the path to the PNG we will be writing") + }; - match args.get(1) { - Some(path) => { - let mut output_file = OpenOptions::new() - .write(true) - .create(true) - .truncate(false) - .open(path) - .expect("Invalid path provided as argument!"); - DynamicImage::ImageRgb8(image) - .write_to(&mut output_file, ImageOutputFormat::Png) - .expect("failed while writing to output file"); - } - None => { - let mut stdout = std::io::stdout(); - DynamicImage::ImageRgb8(image) - .write_to(&mut stdout, ImageOutputFormat::Png) - .expect("failed while writing to stdout"); - } - } + let mut output_file = OpenOptions::new() + .write(true) + .create(true) + .truncate(false) + .open(path) + .expect("Invalid path provided as argument!"); + DynamicImage::ImageRgb8(image) + .write_to(&mut output_file, ImageFormat::Png) + .expect("failed while writing to output file"); } diff --git a/src/appctx.rs b/src/appctx.rs index 623c109..a6a651a 100644 --- a/src/appctx.rs +++ b/src/appctx.rs @@ -13,11 +13,11 @@ use log::warn; use crate::framebuffer::cgmath; use crate::framebuffer::common::*; -use crate::framebuffer::core; +use crate::framebuffer::core::Framebuffer; use crate::framebuffer::FramebufferDraw; use crate::framebuffer::FramebufferRefresh; use crate::framebuffer::PartialRefreshMode; -use crate::input::ev; +use crate::input::ev::EvDevContext; use crate::input::MultitouchEvent; use crate::input::{InputDevice, InputEvent}; use crate::ui_extensions::element::{ @@ -35,7 +35,7 @@ unsafe impl<'a> Send for ApplicationContext<'a> {} unsafe impl<'a> Sync for ApplicationContext<'a> {} pub struct ApplicationContext<'a> { - framebuffer: Box, + framebuffer: Box, yres: u32, xres: u32, @@ -49,9 +49,9 @@ pub struct ApplicationContext<'a> { input_tx: std::sync::mpsc::Sender, input_rx: std::sync::mpsc::Receiver, - button_ctx: RwLock>, - wacom_ctx: RwLock>, - touch_ctx: RwLock>, + button_ctx: RwLock>, + wacom_ctx: RwLock>, + touch_ctx: RwLock>, active_regions: QuadTree, ui_elements: HashMap, @@ -59,7 +59,7 @@ pub struct ApplicationContext<'a> { impl Default for ApplicationContext<'static> { fn default() -> ApplicationContext<'static> { - let framebuffer = Box::new(core::Framebuffer::new()); + let framebuffer = Box::new(Framebuffer::new()); let yres = framebuffer.var_screen_info.yres; let xres = framebuffer.var_screen_info.xres; @@ -98,7 +98,7 @@ impl Default for ApplicationContext<'static> { // Reluctantly resort to using a static global to associate the lua context with the // one and only framebuffer that's going to be used - unsafe { luaext::G_FB = res.framebuffer.deref_mut() as *mut core::Framebuffer }; + unsafe { luaext::G_FB = res.framebuffer.deref_mut() as *mut Framebuffer }; let mut nms = lua.empty_array("fb"); // Clears and refreshes the entire screen @@ -120,10 +120,8 @@ impl Default for ApplicationContext<'static> { } impl<'a> ApplicationContext<'a> { - pub fn get_framebuffer_ref(&mut self) -> &'static mut core::Framebuffer { - unsafe { - std::mem::transmute::<_, &'static mut core::Framebuffer>(self.framebuffer.deref_mut()) - } + pub fn get_framebuffer_ref(&mut self) -> &'static mut Framebuffer { + unsafe { std::mem::transmute::<_, &'static mut Framebuffer>(self.framebuffer.deref_mut()) } } /// Perhaps this is bad practice but we know that the ApplicationContext, @@ -434,7 +432,7 @@ impl<'a> ApplicationContext<'a> { _ => return false, }; - *dev = Some(ev::EvDevContext::new(t, self.input_tx.clone())); + *dev = Some(EvDevContext::new(t, self.input_tx.clone())); match dev.as_mut() { Some(ref mut device) => { device.start(); diff --git a/src/input/wacom.rs b/src/input/wacom.rs index 36bed02..ab1003c 100644 --- a/src/input/wacom.rs +++ b/src/input/wacom.rs @@ -3,11 +3,10 @@ use crate::device::rotate::CoordinatePart; use crate::device::CURRENT_DEVICE; use crate::input::scan::SCANNED; use crate::input::{InputDeviceState, InputEvent, WacomEvent, WacomPen}; -use atomic::Atomic; use evdev::InputEvent as EvInputEvent; use log::debug; use once_cell::sync::Lazy; -use std::sync::atomic::{AtomicU16, Ordering}; +use std::sync::atomic::{AtomicBool, AtomicU16, Ordering}; use crate::cgmath; use crate::dimensions::{DISPLAYHEIGHT, DISPLAYWIDTH, WACOMHEIGHT, WACOMWIDTH}; @@ -22,7 +21,7 @@ pub struct WacomState { last_ytilt: AtomicU16, last_dist: AtomicU16, last_pressure: AtomicU16, - last_touch_state: Atomic, + last_touch_state: AtomicBool, } impl ::std::default::Default for WacomState { @@ -34,7 +33,7 @@ impl ::std::default::Default for WacomState { last_ytilt: AtomicU16::new(0), last_dist: AtomicU16::new(0), last_pressure: AtomicU16::new(0), - last_touch_state: Atomic::new(false), + last_touch_state: AtomicBool::new(false), } } }