Fix some lints

This commit is contained in:
Jakub Hlusička 2026-01-12 01:03:27 +01:00
parent a07d13f4e8
commit 24daa0ad29
7 changed files with 32 additions and 37 deletions

View file

@ -4,7 +4,7 @@ use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use const_gen::*;
use indoc::formatdoc;
use indoc::{formatdoc, writedoc};
use json::JsonValue;
use slint_build::{CompilerConfiguration, EmbedResourcesKind};
use xz2::read::XzEncoder;
@ -107,7 +107,15 @@ fn generate_vial_config() {
writeln!(out_file, "{}", const_declarations).unwrap();
writeln!(out_file, "#[repr(u8)] pub enum CustomKeycodes {{").unwrap();
writedoc!(
out_file,
"
#[allow(dead_code, non_camel_case_types)]
#[repr(u8)]
pub enum CustomKeycodes {{
"
)
.unwrap();
// const CUSTOM_KEYCODE_FIRST: u16 = 0x840;

View file

@ -18,7 +18,7 @@ pub unsafe extern "C" fn __xkbc_malloc(size: c_size_t) -> *mut c_void {
#[unsafe(no_mangle)]
pub unsafe extern "C" fn __xkbc_calloc(number: c_size_t, size: c_size_t) -> *mut c_void {
let total_size = number as usize * size;
let total_size = number * size;
unsafe {
let ptr = __xkbc_malloc(total_size) as *mut u8;

View file

@ -13,7 +13,7 @@ pub unsafe extern "C" fn __xkbc_memset(
c: c_int,
n: c_size_t,
) -> *mut c_void {
if dest_original == null_mut() {
if dest_original.is_null() {
if n > 0 {
panic!("Attempted to memset a nullptr.");
} else {

View file

@ -1,5 +1,4 @@
use core::alloc::Layout;
use core::convert::TryFrom;
use core::fmt::Debug;
use core::slice;
@ -12,7 +11,6 @@ use embassy_time::Instant;
use esp_alloc::MemoryCapability;
use log::{debug, info, warn};
use rmk::descriptor::KeyboardReport;
use rmk::futures::FutureExt;
use rmk::hid::Report;
use rmk::types::action::{Action, KeyAction};
use rmk::{a, k, layer};
@ -167,7 +165,7 @@ pub fn create_hid_report_interceptor() -> impl Future<Output = ()> {
}
}
previous_state = report.clone();
previous_state = *report;
for keycode in released_keys {
debug!("Release: 0x{:02x} ({})", keycode, keycode);

View file

@ -18,18 +18,15 @@ extern crate alloc;
use core::alloc::Layout;
use core::cell::RefCell;
use core::slice;
use core::sync::atomic::{AtomicBool, Ordering};
use alloc::boxed::Box;
use alloc::string::String;
use alloc::vec;
use cfg_if::cfg_if;
use embassy_executor::Spawner;
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use embassy_sync::channel::Channel;
use embassy_sync::signal::Signal;
use embassy_time::{Duration, Instant};
use embassy_time::Duration;
use esp_alloc::{HeapRegion, MemoryCapability};
use esp_hal::Blocking;
use esp_hal::clock::CpuClock;
@ -45,12 +42,11 @@ use esp_hal::system::Stack;
use esp_hal::timer::timg::TimerGroup;
use esp_rtos::embassy::Executor;
use esp_storage::FlashStorage;
use log::{LevelFilter, error, info, warn};
use log::{error, info};
use rmk::channel::{CONTROLLER_CHANNEL, ControllerSub};
use rmk::config::{BehaviorConfig, PositionalConfig, RmkConfig, StorageConfig, VialConfig};
use rmk::controller::{Controller, EventController};
use rmk::debounce::default_debouncer::DefaultDebouncer;
use rmk::descriptor::KeyboardReport;
use rmk::event::ControllerEvent;
use rmk::hid::Report;
use rmk::input_device::Runnable;
@ -58,16 +54,12 @@ use rmk::join_all;
use rmk::keyboard::Keyboard;
use rmk::storage::async_flash_wrapper;
use rmk::types::action::{Action, KeyAction};
use rmk::types::keycode::{HidKeyCode, KeyCode};
use rmk::{initialize_keymap_and_storage, run_devices, run_rmk};
use slint::ComponentHandle;
use slint::platform::software_renderer::Rgb565Pixel;
use static_cell::StaticCell;
use ui::AppWindow;
use xkbcommon::xkb::{self, FeedResult, KeyDirection, Keysym, Status};
use {esp_alloc as _, esp_backtrace as _};
use crate::keymap::{KEY_MESSAGE_CHANNEL, create_hid_report_interceptor};
use crate::keymap::create_hid_report_interceptor;
use crate::logging::LOG_LEVEL_FILTER;
use crate::matrix::IoeMatrix;
use crate::peripherals::st7701s::St7701s;
@ -430,25 +422,22 @@ impl Controller for UserController {
type Event = ControllerEvent;
async fn process_event(&mut self, event: Self::Event) {
if let ControllerEvent::Key(
keyboard_event,
KeyAction::Single(Action::User(user_key_index)),
) = event
if let ControllerEvent::Key(keyboard_event, KeyAction::Single(Action::User(user_key_index))) =
event
&& user_key_index == CustomKeycodes::FOCUS_LCD as u8
&& keyboard_event.pressed
{
if user_key_index == CustomKeycodes::FOCUS_LCD as u8 && keyboard_event.pressed {
let enabled = !LCD_ENABLED.fetch_xor(true, Ordering::SeqCst);
let enabled = !LCD_ENABLED.fetch_xor(true, Ordering::SeqCst);
match enabled {
false => {
info!("Disabling LCD.");
*rmk::channel::KEYBOARD_REPORT_SENDER.write().await =
&rmk::channel::KEYBOARD_REPORT_RECEIVER;
}
true => {
info!("Enabling LCD.");
*rmk::channel::KEYBOARD_REPORT_SENDER.write().await =
&KEYBOARD_REPORT_PROXY;
}
match enabled {
false => {
info!("Disabling LCD.");
*rmk::channel::KEYBOARD_REPORT_SENDER.write().await =
&rmk::channel::KEYBOARD_REPORT_RECEIVER;
}
true => {
info!("Enabling LCD.");
*rmk::channel::KEYBOARD_REPORT_SENDER.write().await = &KEYBOARD_REPORT_PROXY;
}
}
}

View file

@ -2,7 +2,7 @@ use core::{cell::RefCell, time::Duration};
use alloc::rc::Rc;
use esp_hal::time::Instant;
use log::{debug, info, warn};
use log::{debug, info};
use slint::{
PhysicalSize, SharedString, WindowSize,
platform::{

View file

@ -5,7 +5,7 @@ use alloc::boxed::Box;
#[cfg(feature = "limit-fps")]
use crate::FRAME_DURATION_MIN;
use crate::{
SIGNAL_LCD_SUBMIT, SIGNAL_UI_RENDER, keymap::KEY_MESSAGE_CHANNEL, ui::backend::SlintBackend,
SIGNAL_LCD_SUBMIT, SIGNAL_UI_RENDER, ui::backend::SlintBackend,
};
pub mod backend;