customization via wayvr_ipc
This commit is contained in:
@@ -54,6 +54,22 @@ pub enum PlayspaceTask {
|
||||
FixFloor,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum OverlayCustomCommand {
|
||||
SetText(String),
|
||||
SetColor(String),
|
||||
SetSprite(String),
|
||||
SetVisible(bool),
|
||||
SetStickyState(bool),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct OverlayCustomTask {
|
||||
pub overlay: String,
|
||||
pub element: String,
|
||||
pub command: OverlayCustomCommand,
|
||||
}
|
||||
|
||||
pub type ModifyOverlayTask = dyn FnOnce(&mut AppState, &mut OverlayWindowConfig) + Send;
|
||||
pub type CreateOverlayTask = dyn FnOnce(&mut AppState) -> Option<OverlayWindowConfig> + Send;
|
||||
pub enum OverlayTask {
|
||||
@@ -66,6 +82,7 @@ pub enum OverlayTask {
|
||||
CleanupMirrors,
|
||||
Modify(OverlaySelector, Box<ModifyOverlayTask>),
|
||||
Create(OverlaySelector, Box<CreateOverlayTask>),
|
||||
Custom(OverlayCustomTask),
|
||||
Drop(OverlaySelector),
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,10 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
use time::get_millis;
|
||||
use wayvr_ipc::{packet_client, packet_server};
|
||||
use wayvr_ipc::{
|
||||
packet_client::{self},
|
||||
packet_server,
|
||||
};
|
||||
use xkbcommon::xkb;
|
||||
|
||||
use crate::{
|
||||
@@ -94,6 +97,7 @@ pub enum WayVRSignal {
|
||||
BroadcastStateChanged(packet_server::WvrStateChanged),
|
||||
DropOverlay(crate::windowing::OverlayID),
|
||||
Haptics(super::input::Haptics),
|
||||
CustomTask(crate::backend::task::OverlayCustomTask),
|
||||
}
|
||||
|
||||
pub enum BlitMethod {
|
||||
|
||||
@@ -479,6 +479,35 @@ impl Connection {
|
||||
));
|
||||
}
|
||||
|
||||
fn handle_wlx_custom(params: &mut TickParams, custom_params: packet_client::WlxCustomParams) {
|
||||
use crate::backend::task::{OverlayCustomCommand, OverlayCustomTask};
|
||||
|
||||
params
|
||||
.state
|
||||
.signals
|
||||
.send(super::WayVRSignal::CustomTask(OverlayCustomTask {
|
||||
overlay: custom_params.overlay,
|
||||
element: custom_params.element,
|
||||
command: match custom_params.command {
|
||||
packet_client::WlxCustomCommand::SetText(text) => {
|
||||
OverlayCustomCommand::SetText(text)
|
||||
}
|
||||
packet_client::WlxCustomCommand::SetSprite(sprite) => {
|
||||
OverlayCustomCommand::SetSprite(sprite)
|
||||
}
|
||||
packet_client::WlxCustomCommand::SetStickyState(sticky) => {
|
||||
OverlayCustomCommand::SetStickyState(sticky)
|
||||
}
|
||||
packet_client::WlxCustomCommand::SetVisible(visible) => {
|
||||
OverlayCustomCommand::SetVisible(visible)
|
||||
}
|
||||
packet_client::WlxCustomCommand::SetColor(color) => {
|
||||
OverlayCustomCommand::SetColor(color)
|
||||
}
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
fn process_payload(&mut self, params: &mut TickParams, payload: Payload) -> anyhow::Result<()> {
|
||||
let packet: PacketClient = ipc::data_decode(&payload)?;
|
||||
|
||||
@@ -531,6 +560,9 @@ impl Connection {
|
||||
PacketClient::WlxHaptics(haptics_params) => {
|
||||
Self::handle_wlx_haptics(params, haptics_params);
|
||||
}
|
||||
PacketClient::WlxCustom(custom_params) => {
|
||||
Self::handle_wlx_custom(params, custom_params);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user