Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump deps #125

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions examples/live.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -76,7 +77,7 @@ fn encode(img_buf: &[u8], format: ImageFormat) -> Vec<u8> {
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!(),
}
Expand Down
34 changes: 13 additions & 21 deletions examples/screenshot.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use image::{DynamicImage, ImageOutputFormat};
use image::{DynamicImage, ImageFormat};

use libremarkable::framebuffer::common::*;
use libremarkable::framebuffer::core::*;
Expand Down Expand Up @@ -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::<Vec<_>>();
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");
}
24 changes: 11 additions & 13 deletions src/appctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -35,7 +35,7 @@ unsafe impl<'a> Send for ApplicationContext<'a> {}
unsafe impl<'a> Sync for ApplicationContext<'a> {}

pub struct ApplicationContext<'a> {
framebuffer: Box<core::Framebuffer>,
framebuffer: Box<Framebuffer>,
yres: u32,
xres: u32,

Expand All @@ -49,17 +49,17 @@ pub struct ApplicationContext<'a> {
input_tx: std::sync::mpsc::Sender<InputEvent>,
input_rx: std::sync::mpsc::Receiver<InputEvent>,

button_ctx: RwLock<Option<ev::EvDevContext>>,
wacom_ctx: RwLock<Option<ev::EvDevContext>>,
touch_ctx: RwLock<Option<ev::EvDevContext>>,
button_ctx: RwLock<Option<EvDevContext>>,
wacom_ctx: RwLock<Option<EvDevContext>>,
touch_ctx: RwLock<Option<EvDevContext>>,

active_regions: QuadTree<ActiveRegionHandler>,
ui_elements: HashMap<String, UIElementHandle>,
}

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;

Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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();
Expand Down
7 changes: 3 additions & 4 deletions src/input/wacom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -22,7 +21,7 @@ pub struct WacomState {
last_ytilt: AtomicU16,
last_dist: AtomicU16,
last_pressure: AtomicU16,
last_touch_state: Atomic<bool>,
last_touch_state: AtomicBool,
}

impl ::std::default::Default for WacomState {
Expand All @@ -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),
}
}
}
Expand Down
Loading