Fix clippy lints

This commit is contained in:
Jakub Hlusička 2026-02-13 03:00:46 +01:00
parent 707c994a76
commit ea58ef0c8e
12 changed files with 35 additions and 78 deletions

View file

@ -210,7 +210,7 @@ fn generate_vial_config() {
writedoc!( writedoc!(
out_file, out_file,
" "
#[allow(dead_code, non_camel_case_types)] #[allow(dead_code, non_camel_case_types, clippy::upper_case_acronyms)]
#[repr(u8)] #[repr(u8)]
pub enum CustomKeycodes {{ pub enum CustomKeycodes {{
" "

View file

@ -1,35 +1,11 @@
use core::alloc::Layout;
use core::fmt::Debug;
use core::ops::Index;
use core::slice;
use alloc::alloc::Allocator;
use alloc::boxed::Box;
use alloc::collections::btree_map::{BTreeMap, Entry};
use alloc::string::String;
use alloc::sync::Arc;
use alloc::vec::Vec;
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use embassy_sync::channel::Channel;
use embassy_time::Instant;
use esp_alloc::{EspHeap, MemoryCapability};
use itertools::Itertools;
use log::{debug, error, info, warn};
use rmk::config::{BehaviorConfig, ForksConfig, PositionalConfig}; use rmk::config::{BehaviorConfig, ForksConfig, PositionalConfig};
use rmk::descriptor::KeyboardReport;
use rmk::fork::{Fork, StateBits}; use rmk::fork::{Fork, StateBits};
use rmk::futures::FutureExt;
use rmk::hid::Report;
use rmk::types::action::{Action, KeyAction}; use rmk::types::action::{Action, KeyAction};
use rmk::types::modifier::ModifierCombination; use rmk::types::modifier::ModifierCombination;
use rmk::{a, heapless, join_all, k, layer}; use rmk::{a, heapless, k, layer};
use slint::platform::Key;
use static_cell::StaticCell;
use xkbcommon::xkb::{self, FeedResult, KeyDirection, Keysym, ModIndex, ModMask, Status};
use crate::util::{DurationExt, get_file_name};
use crate::vial::CustomKeycodes; use crate::vial::CustomKeycodes;
use crate::{KEYBOARD_REPORT_PROXY, PSRAM_ALLOCATOR};
pub const NUM_LAYER: usize = 8; pub const NUM_LAYER: usize = 8;
pub const MATRIX_ROWS: usize = 5; pub const MATRIX_ROWS: usize = 5;

View file

@ -230,7 +230,7 @@ impl DbKey {
pub struct DbPathSpectreUsers; pub struct DbPathSpectreUsers;
impl<'a> IntoIterator for DbPathSpectreUsers { impl IntoIterator for DbPathSpectreUsers {
type Item = DbPathSegment<'static>; type Item = DbPathSegment<'static>;
type IntoIter = core::array::IntoIter<DbPathSegment<'static>, 2>; type IntoIter = core::array::IntoIter<DbPathSegment<'static>, 2>;

View file

@ -4,9 +4,7 @@ use core::{
}; };
use critical_section::Mutex; use critical_section::Mutex;
use data_encoding_macro::hexlower;
use embassy_sync::blocking_mutex::{self, raw::CriticalSectionRawMutex}; use embassy_sync::blocking_mutex::{self, raw::CriticalSectionRawMutex};
use esp_sync::RawMutex;
use hmac::digest::{FixedOutput, KeyInit, Update}; use hmac::digest::{FixedOutput, KeyInit, Update};
use password_hash::Key; use password_hash::Key;
use sha2::{ use sha2::{
@ -89,6 +87,7 @@ unsafe extern "C" fn __spre_crypto_generichash_blake2b_salt_personal(
todo!() todo!()
} }
#[allow(non_camel_case_types)]
#[repr(C)] #[repr(C)]
struct crypto_hash_sha256_state { struct crypto_hash_sha256_state {
state: [u32; 8], state: [u32; 8],
@ -96,6 +95,7 @@ struct crypto_hash_sha256_state {
buf: [u8; 64], buf: [u8; 64],
} }
#[allow(non_camel_case_types, unused)]
struct crypto_auth_hmacsha256_state { struct crypto_auth_hmacsha256_state {
ictx: crypto_hash_sha256_state, ictx: crypto_hash_sha256_state,
octx: crypto_hash_sha256_state, octx: crypto_hash_sha256_state,

View file

@ -2,7 +2,7 @@
use core::ffi::{c_char, c_int}; use core::ffi::{c_char, c_int};
#[allow(non_camel_case_types)] #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
pub enum DIR {} pub enum DIR {}
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]

View file

@ -1,6 +1,7 @@
use embassy_time::Instant; use embassy_time::Instant;
// TODO: Is this right? // TODO: Is this right?
#[allow(non_camel_case_types)]
pub type time_t = i64; pub type time_t = i64;
#[unsafe(no_mangle)] #[unsafe(no_mangle)]

View file

@ -1,12 +1,6 @@
use core::fmt::Write; use core::fmt::Arguments;
use core::{cell::RefCell, fmt::Arguments};
use critical_section::{CriticalSection, Mutex}; use log::LevelFilter;
use esp_hal::Blocking;
use esp_hal::clock::CpuClock;
use esp_hal::psram::{FlashFreq, PsramConfig, PsramSize, SpiRamFreq, SpiTimingConfigCoreClock};
use esp_hal::uart::UartTx;
use log::{LevelFilter, Log};
pub const LOG_LEVEL_FILTER: LevelFilter = { pub const LOG_LEVEL_FILTER: LevelFilter = {
if let Some(string) = option_env!("ESP_LOG") { if let Some(string) = option_env!("ESP_LOG") {

View file

@ -61,27 +61,23 @@ use itertools::Itertools;
use log::{error, info, warn}; use log::{error, info, warn};
use rmk::channel::{CONTROLLER_CHANNEL, ControllerSub}; use rmk::channel::{CONTROLLER_CHANNEL, ControllerSub};
use rmk::config::{ use rmk::config::{
BehaviorConfig, DeviceConfig, ForksConfig, PositionalConfig, RmkConfig, StorageConfig, DeviceConfig, RmkConfig, StorageConfig,
VialConfig, VialConfig,
}; };
use rmk::controller::{Controller, EventController}; use rmk::controller::{Controller, EventController};
use rmk::debounce::default_debouncer::DefaultDebouncer; use rmk::debounce::default_debouncer::DefaultDebouncer;
use rmk::event::ControllerEvent; use rmk::event::ControllerEvent;
use rmk::fork::{Fork, StateBits};
use rmk::hid::Report; use rmk::hid::Report;
use rmk::input_device::Runnable; use rmk::input_device::Runnable;
use rmk::keyboard::Keyboard; use rmk::keyboard::Keyboard;
use rmk::storage::async_flash_wrapper; use rmk::storage::async_flash_wrapper;
use rmk::types::action::{Action, KeyAction}; use rmk::types::action::{Action, KeyAction};
use rmk::types::keycode::KeyCode; use rmk::join_all;
use rmk::types::modifier::ModifierCombination;
use rmk::{heapless, join_all};
use rmk::{initialize_keymap_and_storage, run_devices, run_rmk}; use rmk::{initialize_keymap_and_storage, run_devices, run_rmk};
use slint::platform::software_renderer::Rgb565Pixel; use slint::platform::software_renderer::Rgb565Pixel;
use static_cell::StaticCell; use static_cell::StaticCell;
use {esp_alloc as _, esp_backtrace as _}; use {esp_alloc as _, esp_backtrace as _};
use crate::logging::LOG_LEVEL_FILTER;
use crate::matrix::IoeMatrix; use crate::matrix::IoeMatrix;
use crate::peripherals::st7701s::St7701s; use crate::peripherals::st7701s::St7701s;
use crate::proxy::create_hid_report_interceptor; use crate::proxy::create_hid_report_interceptor;
@ -392,12 +388,12 @@ async fn main(_spawner: Spawner) {
start_addr: 0, start_addr: 0,
num_sectors: { num_sectors: {
assert!( assert!(
flash_part_info_rmk.len() as u32 % FlashStorage::SECTOR_SIZE == 0, flash_part_info_rmk.len() % FlashStorage::SECTOR_SIZE == 0,
"The size of the RMK partition must be a multiple of {} bytes. Current size: {}", "The size of the RMK partition must be a multiple of {} bytes. Current size: {}",
FlashStorage::SECTOR_SIZE, FlashStorage::SECTOR_SIZE,
flash_part_info_rmk.len() flash_part_info_rmk.len()
); );
(flash_part_info_rmk.len() as u32 / FlashStorage::SECTOR_SIZE) as u8 (flash_part_info_rmk.len() / FlashStorage::SECTOR_SIZE) as u8
}, },
..Default::default() ..Default::default()
}; };
@ -425,7 +421,6 @@ async fn main(_spawner: Spawner) {
device_config, device_config,
vial_config, vial_config,
storage_config, storage_config,
..Default::default()
}; };
// Initialze keyboard stuffs // Initialze keyboard stuffs

View file

@ -1,6 +1,5 @@
use core::alloc::Layout; use core::alloc::Layout;
use core::fmt::Debug; use core::fmt::Debug;
use core::ops::Index;
use core::slice; use core::slice;
use alloc::alloc::Allocator; use alloc::alloc::Allocator;
@ -13,20 +12,14 @@ use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use embassy_sync::channel::Channel; use embassy_sync::channel::Channel;
use embassy_time::Instant; use embassy_time::Instant;
use esp_alloc::{EspHeap, MemoryCapability}; use esp_alloc::{EspHeap, MemoryCapability};
use itertools::Itertools;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use rmk::descriptor::KeyboardReport; use rmk::descriptor::KeyboardReport;
use rmk::futures::FutureExt;
use rmk::hid::Report; use rmk::hid::Report;
use rmk::types::action::{Action, KeyAction}; use rmk::{heapless, join_all};
use rmk::{a, heapless, join_all, k, layer};
use slint::platform::Key; use slint::platform::Key;
use static_cell::StaticCell; use xkbcommon::xkb::{self, FeedResult, KeyDirection, Keysym, ModMask, Status};
use xkbcommon::xkb::{self, FeedResult, KeyDirection, Keysym, ModIndex, ModMask, Status};
use crate::config::{MATRIX_COLS, MATRIX_ROWS};
use crate::util::{DurationExt, get_file_name}; use crate::util::{DurationExt, get_file_name};
use crate::vial::CustomKeycodes;
use crate::{KEYBOARD_REPORT_PROXY, PSRAM_ALLOCATOR}; use crate::{KEYBOARD_REPORT_PROXY, PSRAM_ALLOCATOR};
pub static KEY_MESSAGE_CHANNEL: Channel<CriticalSectionRawMutex, KeyMessage, 16> = Channel::new(); pub static KEY_MESSAGE_CHANNEL: Channel<CriticalSectionRawMutex, KeyMessage, 16> = Channel::new();
@ -199,8 +192,9 @@ async fn send_strings_to_host<A: Allocator>(
let mut index = 0; let mut index = 0;
while remaining_mask != 0 { while remaining_mask != 0 {
if remaining_mask & 1 != 0 { if remaining_mask & 1 != 0
if let Some(mod_descriptor) = modifier_xkb_index_to_descriptor[index] { && let Some(mod_descriptor) = modifier_xkb_index_to_descriptor[index]
{
if let Some(hid_flag) = mod_descriptor.hid_flag { if let Some(hid_flag) = mod_descriptor.hid_flag {
modifier |= hid_flag; modifier |= hid_flag;
} }
@ -209,7 +203,6 @@ async fn send_strings_to_host<A: Allocator>(
let _ = keycodes_vec.push(keycode); let _ = keycodes_vec.push(keycode);
} }
} }
}
remaining_mask >>= 1; remaining_mask >>= 1;
index += 1; index += 1;
@ -432,7 +425,7 @@ pub struct HidKeycodeWithMods {
pub fn string_to_hid_keycodes( pub fn string_to_hid_keycodes(
keymap: &xkb::Keymap, keymap: &xkb::Keymap,
compose_table: &xkb::compose::Table, _compose_table: &xkb::compose::Table,
string: &str, string: &str,
) -> Result<Vec<HidKeycodeWithMods, &'static EspHeap>, char> { ) -> Result<Vec<HidKeycodeWithMods, &'static EspHeap>, char> {
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
@ -582,7 +575,7 @@ pub const fn xkb_to_hid_keycode(xkb_keycode: xkb::Keycode) -> Option<u8> {
let mut hid: u8 = 0; let mut hid: u8 = 0;
loop { loop {
xkb_to_hid[hid_to_xkb_keycode_inner(hid as u8) as usize] = hid; xkb_to_hid[hid_to_xkb_keycode_inner(hid) as usize] = hid;
let overflow; let overflow;
(hid, overflow) = hid.overflowing_add(1); (hid, overflow) = hid.overflowing_add(1);
if overflow { if overflow {

View file

@ -10,7 +10,6 @@ use alloc::{
use critical_section::Mutex; use critical_section::Mutex;
use esp_hal::time::Instant; use esp_hal::time::Instant;
use log::{debug, info}; use log::{debug, info};
use rmk::futures::sink::drain;
use slint::{ use slint::{
EventLoopError, PhysicalSize, SharedString, WindowSize, EventLoopError, PhysicalSize, SharedString, WindowSize,
platform::{ platform::{

View file

@ -1,6 +1,6 @@
// #![cfg_attr(not(feature = "simulator"), no_main)] // #![cfg_attr(not(feature = "simulator"), no_main)]
use core::{cell::RefCell, ffi::CStr, ops::DerefMut, pin::Pin}; use core::{cell::RefCell, ffi::CStr, pin::Pin};
use alloc::{ use alloc::{
borrow::Cow, borrow::Cow,
@ -17,14 +17,13 @@ use hex::FromHexError;
use i_slint_core::model::{ModelChangeListener, ModelChangeListenerContainer}; use i_slint_core::model::{ModelChangeListener, ModelChangeListenerContainer};
use log::{error, info, warn}; use log::{error, info, warn};
use password_hash::Key; use password_hash::Key;
use rmk::futures::{FutureExt, TryFutureExt};
use slint::{ use slint::{
Model, ModelExt, ModelNotify, ModelRc, ModelTracker, SharedString, StandardListViewItem, Model, ModelExt, ModelNotify, ModelRc, ModelTracker, SharedString, StandardListViewItem,
VecModel, VecModel,
}; };
use spectre_api_sys::{ use spectre_api_sys::{
SpectreAlgorithm, SpectreCounter, SpectreKeyID, SpectreKeyPurpose, SpectreResultType, SpectreAlgorithm, SpectreCounter, SpectreKeyID, SpectreKeyPurpose, SpectreResultType,
SpectreSiteKey, SpectreUserKey, SpectreUserKey,
}; };
#[cfg(feature = "limit-fps")] #[cfg(feature = "limit-fps")]
@ -453,7 +452,7 @@ impl AppViewTrait for StateLogin {
if user.key_id != user_key.keyID.bytes { if user.key_id != user_key.keyID.bytes {
State::process_callback_message( State::process_callback_message(
&state_rc, state_rc,
CallbackMessage::Login(CallbackMessageLogin::LoginResult { CallbackMessage::Login(CallbackMessageLogin::LoginResult {
username: user.username, username: user.username,
result: LoginResult::Failure, result: LoginResult::Failure,
@ -494,7 +493,7 @@ impl AppViewTrait for StateLogin {
let mut key_segments = key.segments(); let mut key_segments = key.segments();
let value = &buffer[..value_len]; let value = &buffer[..value_len];
let site_config = let site_config =
postcard::from_bytes::<SpectreSiteConfig>(&value).unwrap(); postcard::from_bytes::<SpectreSiteConfig>(value).unwrap();
let site = SpectreSite { let site = SpectreSite {
config: site_config, config: site_config,
username: key_segments.nth(2).unwrap().as_ref().into(), username: key_segments.nth(2).unwrap().as_ref().into(),
@ -683,12 +682,12 @@ impl AppViewTrait for StateUserEdit {
let mut existing_index = None; let mut existing_index = None;
for index in 0..state.users.users.row_count() { for index in 0..state.users.users.row_count() {
if let Some(current_user) = state.users.users.row_data(index) { if let Some(current_user) = state.users.users.row_data(index)
if current_user.username == user.username { && current_user.username == user.username
{
existing_index = Some(index); existing_index = Some(index);
} }
} }
}
if let Some(existing_index) = existing_index { if let Some(existing_index) = existing_index {
state.users.users.set_row_data(existing_index, user); state.users.users.set_row_data(existing_index, user);

View file

@ -1,10 +1,10 @@
use core::fmt::{Debug, Formatter}; use core::fmt::{Debug, Formatter};
use alloc::{rc::Rc, string::String, vec::Vec}; use alloc::rc::Rc;
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use password_hash::Key; use password_hash::Key;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use slint::{Model, ModelRc, SharedString, VecModel}; use slint::{Model, SharedString, VecModel};
use spectre_api_sys::{SpectreAlgorithm, SpectreCounter, SpectreResultType}; use spectre_api_sys::{SpectreAlgorithm, SpectreCounter, SpectreResultType};
#[derive(Deserialize, Serialize, Default)] #[derive(Deserialize, Serialize, Default)]