Merge remote-tracking branch 'origin/main' into next-dash-interface

This commit is contained in:
galister
2026-01-09 11:46:43 +09:00
10 changed files with 89 additions and 2 deletions

View File

@@ -410,6 +410,13 @@ impl WayVRClient {
Ok(())
}
pub async fn fn_wlx_overlay_show_hide(
client: WayVRClientMutex,
) -> anyhow::Result<()> {
send_only!(client, &PacketClient::WlxShowHide);
Ok(())
}
pub async fn fn_wlx_modify_panel(
client: WayVRClientMutex,
params: packet_client::WlxModifyPanelParams,

View File

@@ -67,4 +67,5 @@ pub enum PacketClient {
WlxInputState(Serial),
WlxModifyPanel(WlxModifyPanelParams),
WlxDeviceHaptics(usize, WlxHapticsParams),
WlxShowHide,
}

View File

@@ -156,6 +156,18 @@ pub async fn wlx_device_haptics(
)
}
pub async fn wlx_overlay_show_hide(
state: &mut WayVRClientState,
) {
handle_empty_result(
WayVRClient::fn_wlx_overlay_show_hide(
state.wayvr_client.clone(),
)
.await
.context("failed to trigger overlay show hide"),
)
}
pub async fn wlx_panel_modify(
state: &mut WayVRClientState,
overlay: String,

View File

@@ -163,6 +163,9 @@ async fn run_once(state: &mut WayVRClientState, args: Args) -> anyhow::Result<()
} => {
wlx_device_haptics(state, device, intensity, duration, frequency).await;
}
Subcommands::ShowHide {} => {
wlx_overlay_show_hide(state).await;
}
Subcommands::PanelModify {
overlay,
element,
@@ -268,6 +271,8 @@ enum Subcommands {
#[arg(short, long, default_value = "0.1")]
frequency: f32,
},
/// Toggle overlay show or hide
ShowHide,
/// Apply a modification to a panel element
PanelModify {
/// The name of the overlay (XML file name without extension)

View File

@@ -58,7 +58,7 @@
"ALIGN_TO_HMD": "常にHMDの方を向く",
"MOUSE": {
"TITLE": "マウスの修正",
"WRONG_SCREEN_SELECTION_HELP": "カーソルが全く別のスクリーンで動く場合、\nスクリーンが正しく選択されていない可能性があります。\nマニュアルをご確認ください。",
"WRONG_SCREEN_SELECTION_HELP": "カーソルが全く別のスクリーンで動く場合、\nスクリーンが正しく選択されていない可能性があります。\nReadmeをご参照ください。",
"NORMAL": "通常",
"FLIPPED": "ミラー",
"FLIP90": "ミラー 90°",
@@ -95,4 +95,4 @@
"CANNOT_ADD_SET": "セットを追加できません!",
"MAXIMUM_SETS_REACHED": "最大セット数に達しました。"
}
}
}

View File

@@ -18,6 +18,16 @@ See the Custom Timezones section for more info on timezones. Skip `_timezone` to
<label _source="clock" _display="time" _timezone="0" [...] />
```
#### Timer label
Instead of a clock, this label shows the amount of time since program start, (aka time in VR).
Use `_format` to arrange `%h` hours, `%m` minutes, and `%s` seconds.
```xml
<label _source="timer" _format="%h:%m:%s" [...] />
```
#### Battery label
This is a label type that's used internally to display battery states.

View File

@@ -1,5 +1,6 @@
use std::rc::Rc;
use chrono::DateTime;
use chrono::Local;
use chrono_tz::Tz;
use wgui::{
@@ -138,6 +139,19 @@ pub(super) fn setup_custom_label<S: 'static>(
Ok(EventResult::Pass)
})
}
"timer" => {
let format = attribs.get_value("_format").unwrap_or("%h:%m");
let state = TimerLabelState {
start: Local::now(),
format: format.into(),
};
Box::new(move |common, data, _, _| {
timer_on_tick(&state, common, data);
Ok(EventResult::Pass)
})
}
"ipd" => Box::new(|common, data, app, _| {
ipd_on_tick(common, data, app);
Ok(EventResult::Pass)
@@ -217,6 +231,30 @@ fn clock_on_tick(
label.set_text(common, Translation::from_raw_text(&date_time));
}
struct TimerLabelState {
start: DateTime<Local>,
format: Rc<str>,
}
fn timer_on_tick(
state: &TimerLabelState,
common: &mut event::CallbackDataCommon,
data: &mut event::CallbackData,
) {
let duration = Local::now()
.signed_duration_since(&state.start)
.num_seconds();
let time = &state
.format
.replace("%s", &format!("{:02}", (duration % 60)))
.replace("%m", &format!("{:02}", ((duration / 60) % 60)))
.replace("%h", &format!("{:02}", ((duration / 60) / 60)));
let label = data.obj.get_as_mut::<WidgetLabel>().unwrap();
label.set_text(common, Translation::from_raw_text(&time));
}
fn ipd_on_tick(
common: &mut event::CallbackDataCommon,
data: &mut event::CallbackData,

View File

@@ -50,6 +50,10 @@ where
app.tasks
.enqueue(TaskType::Input(InputTask::Haptics { device, haptics }));
}
WayVRSignal::ShowHide => {
app.tasks
.enqueue(TaskType::Overlay(OverlayTask::ShowHide));
}
WayVRSignal::DropOverlay(overlay_id) => {
app.tasks
.enqueue(TaskType::Overlay(OverlayTask::Drop(OverlaySelector::Id(

View File

@@ -350,6 +350,12 @@ impl Connection {
));
}
fn handle_wlx_overlay_show_hide(
params: &mut TickParams
) {
params.signals.send(WayVRSignal::ShowHide);
}
fn handle_wlx_panel(
params: &mut TickParams,
custom_params: packet_client::WlxModifyPanelParams,
@@ -424,6 +430,9 @@ impl Connection {
PacketClient::WlxDeviceHaptics(device, haptics_params) => {
Self::handle_wlx_device_haptics(params, device, haptics_params);
}
PacketClient::WlxShowHide => {
Self::handle_wlx_overlay_show_hide(params);
}
PacketClient::WlxModifyPanel(custom_params) => {
Self::handle_wlx_panel(params, custom_params);
}

View File

@@ -4,5 +4,6 @@ pub enum WayVRSignal {
BroadcastStateChanged(wayvr_ipc::packet_server::WvrStateChanged),
DeviceHaptics(usize, crate::backend::input::Haptics),
DropOverlay(crate::windowing::OverlayID),
ShowHide,
CustomTask(crate::backend::task::ModifyPanelTask),
}