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

deps: drop once_cell with MSRV=1.80 #129

Open
wants to merge 1 commit 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
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ edition = "2021"

[dependencies]
log = "0.4.14"
once_cell = "1.9.0"
atomic = "0.5.1"
cgmath = "0.18.0"
libc = "0.2.69"
Expand Down
22 changes: 11 additions & 11 deletions examples/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use libremarkable::stopwatch;
use atomic::Atomic;
use chrono::{DateTime, Local};
use log::info;
use once_cell::sync::Lazy;
use std::sync::LazyLock;

use std::collections::VecDeque;
use std::fmt;
Expand Down Expand Up @@ -100,16 +100,16 @@ const CANVAS_REGION: mxcfb_rect = mxcfb_rect {

type PointAndPressure = (cgmath::Point2<f32>, i32);

static G_TOUCH_MODE: Lazy<Atomic<TouchMode>> = Lazy::new(|| Atomic::new(TouchMode::OnlyUI));
static G_DRAW_MODE: Lazy<Atomic<DrawMode>> = Lazy::new(|| Atomic::new(DrawMode::Draw(2)));
static UNPRESS_OBSERVED: Lazy<AtomicBool> = Lazy::new(|| AtomicBool::new(false));
static WACOM_IN_RANGE: Lazy<AtomicBool> = Lazy::new(|| AtomicBool::new(false));
static WACOM_RUBBER_SIDE: Lazy<AtomicBool> = Lazy::new(|| AtomicBool::new(false));
static WACOM_HISTORY: Lazy<Mutex<VecDeque<PointAndPressure>>> =
Lazy::new(|| Mutex::new(VecDeque::new()));
static G_COUNTER: Lazy<Mutex<u32>> = Lazy::new(|| Mutex::new(0));
static SAVED_CANVAS: Lazy<Mutex<Option<storage::CompressedCanvasState>>> =
Lazy::new(|| Mutex::new(None));
static G_TOUCH_MODE: LazyLock<Atomic<TouchMode>> = LazyLock::new(|| Atomic::new(TouchMode::OnlyUI));
static G_DRAW_MODE: LazyLock<Atomic<DrawMode>> = LazyLock::new(|| Atomic::new(DrawMode::Draw(2)));
static UNPRESS_OBSERVED: LazyLock<AtomicBool> = LazyLock::new(|| AtomicBool::new(false));
static WACOM_IN_RANGE: LazyLock<AtomicBool> = LazyLock::new(|| AtomicBool::new(false));
static WACOM_RUBBER_SIDE: LazyLock<AtomicBool> = LazyLock::new(|| AtomicBool::new(false));
static WACOM_HISTORY: LazyLock<Mutex<VecDeque<PointAndPressure>>> =
LazyLock::new(|| Mutex::new(VecDeque::new()));
static G_COUNTER: LazyLock<Mutex<u32>> = LazyLock::new(|| Mutex::new(0));
static SAVED_CANVAS: LazyLock<Mutex<Option<storage::CompressedCanvasState>>> =
LazyLock::new(|| Mutex::new(None));

// ####################
// ## Button Handlers
Expand Down
12 changes: 6 additions & 6 deletions examples/spy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@ use std::sync::Mutex;

use libc::c_int;
use libc::intptr_t;
use once_cell::sync::Lazy;
use redhook::{hook, real};
use std::sync::LazyLock;

use libremarkable::framebuffer::common::*;
use libremarkable::framebuffer::mxcfb::*;
use libremarkable::framebuffer::screeninfo::VarScreeninfo;

static DIST_DITHER: Lazy<Mutex<HashMap<u32, u32>>> = Lazy::new(|| {
static DIST_DITHER: LazyLock<Mutex<HashMap<u32, u32>>> = LazyLock::new(|| {
let m = HashMap::new();
Mutex::new(m)
});
static DIST_WAVEFORM: Lazy<Mutex<HashMap<u32, u32>>> = Lazy::new(|| {
static DIST_WAVEFORM: LazyLock<Mutex<HashMap<u32, u32>>> = LazyLock::new(|| {
let m = HashMap::new();
Mutex::new(m)
});
static DIST_QUANT: Lazy<Mutex<HashMap<u32, u32>>> = Lazy::new(|| {
static DIST_QUANT: LazyLock<Mutex<HashMap<u32, u32>>> = LazyLock::new(|| {
let m = HashMap::new();
Mutex::new(m)
});
static DIST_FLAGS: Lazy<Mutex<HashMap<u32, u32>>> = Lazy::new(|| {
static DIST_FLAGS: LazyLock<Mutex<HashMap<u32, u32>>> = LazyLock::new(|| {
let m = HashMap::new();
Mutex::new(m)
});
static DIST_TEMP: Lazy<Mutex<HashMap<u32, u32>>> = Lazy::new(|| {
static DIST_TEMP: LazyLock<Mutex<HashMap<u32, u32>>> = LazyLock::new(|| {
let m = HashMap::new();
Mutex::new(m)
});
Expand Down
4 changes: 2 additions & 2 deletions src/device/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use once_cell::sync::Lazy;
use rotate::InputDeviceRotation;
use std::sync::LazyLock;

/// Utility for rotating
pub mod rotate;
Expand Down Expand Up @@ -52,7 +52,7 @@ impl Model {
}
}

pub static CURRENT_DEVICE: Lazy<Device> = Lazy::new(Device::new);
pub static CURRENT_DEVICE: LazyLock<Device> = LazyLock::new(Device::new);

/// Differentiate between the reasons why the determination of the current device model can fail.
#[derive(Debug)]
Expand Down
10 changes: 5 additions & 5 deletions src/dimensions.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#[cfg(feature = "input")]
use crate::input::scan::SCANNED;
#[cfg(feature = "input")]
use once_cell::sync::Lazy;
use std::sync::LazyLock;

pub const DISPLAYWIDTH: u16 = 1404;
pub const DISPLAYHEIGHT: u16 = 1872;

/// Will be 767 rM1 and 1403 on the rM2
#[cfg(feature = "input")]
pub static MTWIDTH: Lazy<u16> = Lazy::new(|| SCANNED.mt_width);
pub static MTWIDTH: LazyLock<u16> = LazyLock::new(|| SCANNED.mt_width);
/// Will be 1023 the rM1 and 1871 on the rM2
#[cfg(feature = "input")]
pub static MTHEIGHT: Lazy<u16> = Lazy::new(|| SCANNED.mt_height);
pub static MTHEIGHT: LazyLock<u16> = LazyLock::new(|| SCANNED.mt_height);

/// Will be 15725 on both the rM1 and rM2
#[cfg(feature = "input")]
pub static WACOMWIDTH: Lazy<u16> = Lazy::new(|| SCANNED.wacom_width);
pub static WACOMWIDTH: LazyLock<u16> = LazyLock::new(|| SCANNED.wacom_width);
/// Will be 20967 on the rM1 and 20966 on the rM2
#[cfg(feature = "input")]
pub static WACOMHEIGHT: Lazy<u16> = Lazy::new(|| SCANNED.wacom_height);
pub static WACOMHEIGHT: LazyLock<u16> = LazyLock::new(|| SCANNED.wacom_height);
6 changes: 3 additions & 3 deletions src/framebuffer/draw.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#[cfg(feature = "image")]
use image::RgbImage;

#[cfg(feature = "framebuffer-text-drawing")]
use once_cell::sync::Lazy;
#[cfg(feature = "framebuffer-text-drawing")]
use rusttype::{point, Font, Scale};
#[cfg(feature = "framebuffer-text-drawing")]
use std::sync::LazyLock;

use crate::framebuffer;
use crate::framebuffer::cgmath::*;
Expand All @@ -14,7 +14,7 @@ use crate::framebuffer::graphics;
use crate::framebuffer::FramebufferIO;

#[cfg(feature = "framebuffer-text-drawing")]
pub static DEFAULT_FONT: Lazy<Font<'static>> = Lazy::new(|| {
pub static DEFAULT_FONT: LazyLock<Font<'static>> = LazyLock::new(|| {
Font::try_from_bytes(include_bytes!("../../assets/Roboto-Regular.ttf").as_slice())
.expect("corrupted font data")
});
Expand Down
7 changes: 4 additions & 3 deletions src/input/multitouch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::device::CURRENT_DEVICE;
use crate::dimensions::{DISPLAYHEIGHT, DISPLAYWIDTH, MTHEIGHT, MTWIDTH};
use crate::input::scan::SCANNED;
use crate::input::{Finger, InputDeviceState, InputEvent, MultitouchEvent};
use once_cell::sync::Lazy;
use std::sync::LazyLock;

use evdev::InputEvent as EvInputEvent;
use fxhash::FxHashMap;
Expand All @@ -14,8 +14,9 @@ use std::sync::{
Mutex,
};

static MT_HSCALAR: Lazy<f32> = Lazy::new(|| f32::from(DISPLAYWIDTH) / f32::from(*MTWIDTH));
static MT_VSCALAR: Lazy<f32> = Lazy::new(|| f32::from(DISPLAYHEIGHT) / f32::from(*MTHEIGHT));
static MT_HSCALAR: LazyLock<f32> = LazyLock::new(|| f32::from(DISPLAYWIDTH) / f32::from(*MTWIDTH));
static MT_VSCALAR: LazyLock<f32> =
LazyLock::new(|| f32::from(DISPLAYHEIGHT) / f32::from(*MTHEIGHT));

pub struct MultitouchState {
fingers: Mutex<FxHashMap<i32 /* slot */, Finger>>,
Expand Down
4 changes: 2 additions & 2 deletions src/input/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ use super::ecodes;
use super::InputDevice;
use cgmath::Vector2;
use log::debug;
use once_cell::sync::Lazy;
use std::path::{Path, PathBuf};
use std::sync::LazyLock;
use std::sync::{Arc, Mutex};
use std::time::Duration;

pub const INITIAL_DEVS_AVAILABLE_FOR: Duration = Duration::from_millis(150);

/// A singleton of the EvDevsScan object
pub static SCANNED: Lazy<EvDevs> = Lazy::new(EvDevs::new);
pub static SCANNED: LazyLock<EvDevs> = LazyLock::new(EvDevs::new);

/// This struct contains the results of initially scaning all evdev devices,
/// which allows for device model independancy.
Expand Down
8 changes: 5 additions & 3 deletions src/input/wacom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ 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::LazyLock;

use crate::cgmath;
use crate::dimensions::{DISPLAYHEIGHT, DISPLAYWIDTH, WACOMHEIGHT, WACOMWIDTH};

static WACOM_HSCALAR: Lazy<f32> = Lazy::new(|| f32::from(DISPLAYWIDTH) / f32::from(*WACOMWIDTH));
static WACOM_VSCALAR: Lazy<f32> = Lazy::new(|| f32::from(DISPLAYHEIGHT) / f32::from(*WACOMHEIGHT));
static WACOM_HSCALAR: LazyLock<f32> =
LazyLock::new(|| f32::from(DISPLAYWIDTH) / f32::from(*WACOMWIDTH));
static WACOM_VSCALAR: LazyLock<f32> =
LazyLock::new(|| f32::from(DISPLAYHEIGHT) / f32::from(*WACOMHEIGHT));

pub struct WacomState {
last_x: AtomicU16,
Expand Down
Loading