settings implementation
This commit is contained in:
@@ -107,7 +107,7 @@ impl BlitMethod {
|
||||
}
|
||||
|
||||
pub struct Config {
|
||||
pub click_freeze_time_ms: u32,
|
||||
pub click_freeze_time_ms: i32,
|
||||
pub keyboard_repeat_delay_ms: u32,
|
||||
pub keyboard_repeat_rate: u32,
|
||||
pub auto_hide_delay: Option<u32>, // if None, auto-hide is disabled
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
use dash_frontend::{
|
||||
frontend::{self, FrontendTask, FrontendUpdateParams},
|
||||
settings::{self, SettingsIO},
|
||||
};
|
||||
use dash_frontend::frontend::{self, FrontendTask, FrontendUpdateParams};
|
||||
use glam::{Affine2, Affine3A, Vec2, vec2, vec3};
|
||||
use wayvr_ipc::{
|
||||
packet_client::WvrProcessLaunchParams,
|
||||
@@ -26,7 +23,6 @@ use wlx_common::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
app_misc,
|
||||
backend::{
|
||||
input::{Haptics, HoverResult, PointerHit, PointerMode},
|
||||
task::{OverlayTask, PlayspaceTask, TaskType},
|
||||
@@ -53,43 +49,6 @@ pub const DASH_NAME: &str = "Dashboard";
|
||||
const DASH_RES_U32A: [u32; 2] = [1920, 1080];
|
||||
const DASH_RES_VEC2: Vec2 = vec2(DASH_RES_U32A[0] as _, DASH_RES_U32A[1] as _);
|
||||
|
||||
//FIXME: replace with proper impl
|
||||
struct SimpleSettingsIO {
|
||||
settings: settings::Settings,
|
||||
}
|
||||
impl SimpleSettingsIO {
|
||||
fn new() -> Self {
|
||||
let mut res = Self {
|
||||
settings: settings::Settings::default(),
|
||||
};
|
||||
res.read_from_disk();
|
||||
res
|
||||
}
|
||||
}
|
||||
impl settings::SettingsIO for SimpleSettingsIO {
|
||||
fn get_mut(&mut self) -> &mut settings::Settings {
|
||||
&mut self.settings
|
||||
}
|
||||
fn get(&self) -> &dash_frontend::settings::Settings {
|
||||
&self.settings
|
||||
}
|
||||
fn save_to_disk(&mut self) {
|
||||
log::info!("saving settings");
|
||||
let data = self.settings.save();
|
||||
std::fs::write("/tmp/testbed_settings.json", data).unwrap();
|
||||
}
|
||||
fn read_from_disk(&mut self) {
|
||||
log::info!("loading settings");
|
||||
if let Ok(res) = std::fs::read("/tmp/testbed_settings.json") {
|
||||
let data = String::from_utf8(res).unwrap();
|
||||
self.settings = settings::Settings::load(&data).unwrap();
|
||||
}
|
||||
}
|
||||
fn mark_as_dirty(&mut self) {
|
||||
self.save_to_disk();
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DashFrontend {
|
||||
inner: frontend::Frontend<AppState>,
|
||||
initialized: bool,
|
||||
@@ -103,13 +62,14 @@ const GUI_SCALE: f32 = 2.0;
|
||||
|
||||
impl DashFrontend {
|
||||
fn new(app: &mut AppState) -> anyhow::Result<Self> {
|
||||
let settings = SimpleSettingsIO::new();
|
||||
let interface = DashInterfaceLive::new();
|
||||
|
||||
let frontend = frontend::Frontend::new(frontend::InitParams {
|
||||
settings: Box::new(settings),
|
||||
interface: Box::new(interface),
|
||||
})?;
|
||||
let frontend = frontend::Frontend::new(
|
||||
frontend::InitParams {
|
||||
interface: Box::new(interface),
|
||||
},
|
||||
app,
|
||||
)?;
|
||||
|
||||
frontend
|
||||
.tasks
|
||||
@@ -448,4 +408,11 @@ impl DashInterface<AppState> for DashInterfaceLive {
|
||||
) -> &'a mut wlx_common::desktop_finder::DesktopFinder {
|
||||
&mut data.desktop_finder
|
||||
}
|
||||
|
||||
fn general_config<'a>(
|
||||
&'a mut self,
|
||||
data: &'a mut AppState,
|
||||
) -> &'a mut wlx_common::config::GeneralConfig {
|
||||
&mut data.session.config
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ impl OverlayBackend for ScreenBackend {
|
||||
{
|
||||
let pos = self.mouse_transform.transform_point2(hit.uv);
|
||||
app.hid_provider.inner.mouse_move(pos);
|
||||
set_next_move(u64::from(app.session.config.mouse_move_interval_ms));
|
||||
set_next_move(app.session.config.mouse_move_interval_ms as _);
|
||||
}
|
||||
HoverResult {
|
||||
consume: true,
|
||||
@@ -290,7 +290,7 @@ impl OverlayBackend for ScreenBackend {
|
||||
}
|
||||
|
||||
if pressed {
|
||||
set_next_move(u64::from(app.session.config.click_freeze_time_ms));
|
||||
set_next_move(app.session.config.click_freeze_time_ms as _);
|
||||
}
|
||||
|
||||
app.hid_provider.inner.send_button(btn, pressed);
|
||||
|
||||
Reference in New Issue
Block a user