summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-03-14 21:36:45 -0400
committerLLLL Colonq <llll@colonq>2025-03-14 21:36:45 -0400
commit6ca8afe419b3eb28d68e24c61b5f25cf8ff0e740 (patch)
treeb791c937d8ca4c526dcf05cc6af01ed86a42428a
parent8525f8d1f9f8ad3ea234ff485652f4f90acc3f56 (diff)
Update
-rw-r--r--Cargo.lock116
-rw-r--r--crates/renderer/Cargo.toml3
-rw-r--r--crates/renderer/src/fig.rs6
-rw-r--r--crates/renderer/src/main.rs75
-rw-r--r--crates/throwshade/src/assets/shaders/throwshade/frag.glsl5
5 files changed, 170 insertions, 35 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 986f670..cfdad53 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -20,14 +20,20 @@ checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046"
[[package]]
name = "addr2line"
-version = "0.24.2"
+version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
+checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
dependencies = [
"gimli",
]
[[package]]
+name = "adler"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+
+[[package]]
name = "adler2"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -244,17 +250,17 @@ dependencies = [
[[package]]
name = "backtrace"
-version = "0.3.74"
+version = "0.3.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
+checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d"
dependencies = [
"addr2line",
+ "cc",
"cfg-if",
"libc",
- "miniz_oxide",
+ "miniz_oxide 0.7.4",
"object",
"rustc-demangle",
- "windows-targets 0.52.6",
]
[[package]]
@@ -485,6 +491,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
[[package]]
+name = "color-eyre"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5"
+dependencies = [
+ "backtrace",
+ "eyre",
+ "indenter",
+ "once_cell",
+ "owo-colors",
+]
+
+[[package]]
name = "color_quant"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -553,6 +572,19 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "core-graphics"
+version = "0.22.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb"
+dependencies = [
+ "bitflags 1.3.2",
+ "core-foundation",
+ "core-graphics-types",
+ "foreign-types 0.3.2",
+ "libc",
+]
+
+[[package]]
+name = "core-graphics"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081"
@@ -676,7 +708,7 @@ checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f"
[[package]]
name = "directories"
version = "6.0.0"
-source = "git+https://github.com/lcolonq/teleia#e73044fbd51f9c8f15eb6bd60248887ccd8b16f0"
+source = "git+https://github.com/lcolonq/teleia#7407dc2a99ce74ae733c350ad239d2a4017e0684"
dependencies = [
"dirs-sys",
]
@@ -808,7 +840,7 @@ dependencies = [
"bit_field",
"half",
"lebe",
- "miniz_oxide",
+ "miniz_oxide 0.8.4",
"rayon-core",
"smallvec",
"zune-inflate",
@@ -821,6 +853,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af9673d8203fcb076b19dfd17e38b3d4ae9f44959416ea532ce72415a6020365"
[[package]]
+name = "eyre"
+version = "0.6.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec"
+dependencies = [
+ "indenter",
+ "once_cell",
+]
+
+[[package]]
name = "fastrand"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -842,7 +884,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c"
dependencies = [
"crc32fast",
- "miniz_oxide",
+ "miniz_oxide 0.8.4",
]
[[package]]
@@ -1004,9 +1046,9 @@ dependencies = [
[[package]]
name = "gimli"
-version = "0.31.1"
+version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
+checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
[[package]]
name = "glam"
@@ -1020,7 +1062,7 @@ dependencies = [
[[package]]
name = "glfw"
version = "0.59.0"
-source = "git+https://github.com/lcolonq/teleia#e73044fbd51f9c8f15eb6bd60248887ccd8b16f0"
+source = "git+https://github.com/lcolonq/teleia#7407dc2a99ce74ae733c350ad239d2a4017e0684"
dependencies = [
"bitflags 1.3.2",
"objc2 0.5.2",
@@ -1062,7 +1104,7 @@ dependencies = [
[[package]]
name = "gltf"
version = "1.4.1"
-source = "git+https://github.com/lcolonq/teleia#e73044fbd51f9c8f15eb6bd60248887ccd8b16f0"
+source = "git+https://github.com/lcolonq/teleia#7407dc2a99ce74ae733c350ad239d2a4017e0684"
dependencies = [
"base64 0.13.1",
"byteorder",
@@ -1076,7 +1118,7 @@ dependencies = [
[[package]]
name = "gltf-derive"
version = "1.4.1"
-source = "git+https://github.com/lcolonq/teleia#e73044fbd51f9c8f15eb6bd60248887ccd8b16f0"
+source = "git+https://github.com/lcolonq/teleia#7407dc2a99ce74ae733c350ad239d2a4017e0684"
dependencies = [
"inflections",
"proc-macro2",
@@ -1087,7 +1129,7 @@ dependencies = [
[[package]]
name = "gltf-json"
version = "1.4.1"
-source = "git+https://github.com/lcolonq/teleia#e73044fbd51f9c8f15eb6bd60248887ccd8b16f0"
+source = "git+https://github.com/lcolonq/teleia#7407dc2a99ce74ae733c350ad239d2a4017e0684"
dependencies = [
"gltf-derive",
"serde",
@@ -1455,6 +1497,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0263a3d970d5c054ed9312c0057b4f3bde9c0b33836d3637361d4a9e6e7a408"
[[package]]
+name = "indenter"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
+
+[[package]]
name = "indexmap"
version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1735,6 +1783,15 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide"
+version = "0.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08"
+dependencies = [
+ "adler",
+]
+
+[[package]]
+name = "miniz_oxide"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3b1c9bd4fe1f0f8b387f6eb9eb3b4a1aa26185e5750efb9140301703f62cd1b"
@@ -1761,6 +1818,17 @@ dependencies = [
]
[[package]]
+name = "mouse_position"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "824feb0675ad2ffda7b1da534f394c5779fb39d123b5f376a221d50fad54b3c2"
+dependencies = [
+ "core-graphics 0.22.3",
+ "winapi",
+ "x11-dl",
+]
+
+[[package]]
name = "native-tls"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1969,9 +2037,9 @@ checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33"
[[package]]
name = "object"
-version = "0.36.7"
+version = "0.32.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
+checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441"
dependencies = [
"memchr",
]
@@ -2074,6 +2142,12 @@ dependencies = [
]
[[package]]
+name = "owo-colors"
+version = "3.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
+
+[[package]]
name = "parking_lot"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2136,7 +2210,7 @@ dependencies = [
"crc32fast",
"fdeflate",
"flate2",
- "miniz_oxide",
+ "miniz_oxide 0.8.4",
]
[[package]]
@@ -2416,6 +2490,7 @@ dependencies = [
"lazy_static",
"lexpr",
"log",
+ "mouse_position",
"polling",
"rand",
"strum",
@@ -3051,11 +3126,12 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
[[package]]
name = "teleia"
version = "0.1.0"
-source = "git+https://github.com/lcolonq/teleia#e73044fbd51f9c8f15eb6bd60248887ccd8b16f0"
+source = "git+https://github.com/lcolonq/teleia#7407dc2a99ce74ae733c350ad239d2a4017e0684"
dependencies = [
"bimap",
"bitflags 2.8.0",
"bytes",
+ "color-eyre",
"console_error_panic_hook",
"console_log",
"directories",
@@ -4074,7 +4150,7 @@ dependencies = [
"calloop",
"cfg_aliases",
"core-foundation",
- "core-graphics",
+ "core-graphics 0.23.2",
"cursor-icon",
"icrate",
"js-sys",
diff --git a/crates/renderer/Cargo.toml b/crates/renderer/Cargo.toml
index f891a7a..4d3024d 100644
--- a/crates/renderer/Cargo.toml
+++ b/crates/renderer/Cargo.toml
@@ -25,4 +25,5 @@ tokio = { version = "*", features = ["full"] } # async runtime
clap = { version = "*", features = ["cargo"] } # cli arg parsing
base64 = "0.22.1" # base64 encoding/decoding
polling = "*" # polling sockets
-termion = "*" # terminal escapes \ No newline at end of file
+termion = "*" # terminal escapes
+mouse_position = "*" # get mouse position \ No newline at end of file
diff --git a/crates/renderer/src/fig.rs b/crates/renderer/src/fig.rs
index 66dc229..aa972a4 100644
--- a/crates/renderer/src/fig.rs
+++ b/crates/renderer/src/fig.rs
@@ -39,9 +39,9 @@ impl Client {
}
},
Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => {
- if self.buf.len() > 0 {
- log::error!("error wouldblock: buf is {}", self.buf);
- }
+ // if self.buf.len() > 0 {
+ // log::error!("error wouldblock: buf is {}", self.buf);
+ // }
None
},
Err(e) => panic!("IO error on message bus: {}", e),
diff --git a/crates/renderer/src/main.rs b/crates/renderer/src/main.rs
index b8e6825..d40aad6 100644
--- a/crates/renderer/src/main.rs
+++ b/crates/renderer/src/main.rs
@@ -50,6 +50,10 @@ pub struct Overlay {
tracking_mouth: f32,
tracking_neck: glam::Quat,
throwshade: throwshade::ThrowShade,
+ emacs_cursor: (f32, f32),
+ mouse_cursor: (f32, f32),
+ emacs_heartrate: i32,
+ muzak_author: Option<String>,
chat: Chat,
toggles: HashMap<String, Toggle>,
}
@@ -82,12 +86,20 @@ impl Overlay {
sexp!((avatar reset)),
sexp!((avatar tracking)),
sexp!((avatar overlay shader)),
+ sexp!((avatar overlay muzak)),
+ sexp!((avatar overlay muzak clear)),
sexp!((avatar overlay chat)),
+ sexp!((avatar overlay cursor)),
+ sexp!((avatar overlay emacs)),
]),
tracking_eyes: (1.0, 1.0),
tracking_mouth: 0.0,
tracking_neck: glam::Quat::IDENTITY,
+ emacs_cursor: (0.0, 0.0),
+ mouse_cursor: (0.0, 0.0),
+ emacs_heartrate: 0,
throwshade,
+ muzak_author: None,
chat: Chat::new(),
toggles: HashMap::new(),
}
@@ -171,6 +183,16 @@ impl Overlay {
}
Some(())
}
+ pub fn handle_overlay_muzak(&mut self, msg: fig::Message) -> Option<()> {
+ let ba = BASE64_STANDARD.decode(msg.data.get(0)?.as_str()?).ok()?;
+ let author = String::from_utf8_lossy(&ba);
+ self.muzak_author = Some(author.to_string());
+ Some(())
+ }
+ pub fn handle_overlay_muzak_clear(&mut self) -> Option<()> {
+ self.muzak_author = None;
+ Some(())
+ }
pub fn handle_overlay_chat(&mut self, msg: fig::Message) -> Option<()> {
let bs = BASE64_STANDARD.decode(msg.data.get(0)?.as_str()?).ok()?;
let s = String::from_utf8_lossy(&bs);
@@ -182,6 +204,16 @@ impl Overlay {
self.chat.biblicality = biblicality;
Some(())
}
+ pub fn handle_overlay_cursor(&mut self, msg: fig::Message) -> Option<()> {
+ let cursor_x = msg.data.get(0)?.as_i64()? as f32;
+ let cursor_y = msg.data.get(1)?.as_i64()? as f32;
+ self.emacs_cursor = (cursor_x, cursor_y);
+ Some(())
+ }
+ pub fn handle_overlay_emacs(&mut self, msg: fig::Message) -> Option<()> {
+ self.emacs_heartrate = msg.data.get(0)?.as_i64()? as i32;
+ Some(())
+ }
fn render_model_terminal(&mut self, ctx: &context::Context, st: &mut state::State) -> Option<()> {
self.model_fb.bind(ctx);
ctx.clear_color(glam::Vec4::new(0.0, 0.0, 0.0, 0.0));
@@ -222,7 +254,7 @@ impl teleia::state::Game for Overlay {
fn finish_title(&mut self, _st: &mut state::State) {}
fn mouse_press(&mut self, _ctx: &context::Context, _st: &mut state::State) {}
fn mouse_move(&mut self, _ctx: &context::Context, _st: &mut state::State, _x: i32, _y: i32) {}
- fn update(&mut self, ctx: &context::Context, st: &mut state::State) -> Option<()> {
+ fn update(&mut self, ctx: &context::Context, st: &mut state::State) -> Erm<()> {
st.projection = glam::Mat4::perspective_lh(
PI / 4.0,
terminal::WIDTH as f32 / terminal::HEIGHT as f32,
@@ -234,6 +266,12 @@ impl teleia::state::Game for Overlay {
&glam::Vec3::new(0.0, 0.0, -1.0),
&glam::Vec3::new(0.0, 1.0, 0.0),
);
+ match mouse_position::mouse_position::Mouse::get_mouse_position() {
+ mouse_position::mouse_position::Mouse::Position { x, y } => {
+ self.mouse_cursor = (x as f32, y as f32);
+ },
+ _ => {},
+ }
while let Some(msg) = self.fig.pump() {
let malformed = format!("malformed {} data: {}", msg.event, msg.data);
if msg.event == sexp!((avatar tracking)) {
@@ -252,8 +290,14 @@ impl teleia::state::Game for Overlay {
if self.handle_frame(msg).is_none() { log::warn!("{}", malformed) }
} else if msg.event == sexp!((avatar overlay shader)) {
if self.handle_overlay_shader(ctx, st, msg).is_none() { log::warn!("{}", malformed) }
+ } else if msg.event == sexp!((avatar overlay muzak)) {
+ if self.handle_overlay_muzak(msg).is_none() { log::warn!("{}", malformed) }
+ } else if msg.event == sexp!((avatar overlay muzak clear)) {
+ if self.handle_overlay_muzak_clear().is_none() { log::warn!("{}", malformed) }
} else if msg.event == sexp!((avatar overlay chat)) {
if self.handle_overlay_chat(msg).is_none() { log::warn!("{}", malformed) }
+ } else if msg.event == sexp!((avatar overlay cursor)) {
+ if self.handle_overlay_cursor(msg).is_none() { log::warn!("{}", malformed) }
} else {
log::info!("received unhandled event {} with data: {}", msg.event, msg.data);
}
@@ -261,9 +305,9 @@ impl teleia::state::Game for Overlay {
if let Some(n) = self.model.nodes_by_name.get("J_Bip_C_Neck").and_then(|i| self.model.nodes.get_mut(*i)) {
n.transform = self.model_neck_base * glam::Mat4::from_quat(self.tracking_neck);
}
- Some(())
+ Ok(())
}
- fn render(&mut self, ctx: &context::Context, st: &mut state::State) -> Option<()> {
+ fn render(&mut self, ctx: &context::Context, st: &mut state::State) -> Erm<()> {
ctx.clear_color(glam::Vec4::new(0.0, 0.0, 0.0, 0.0));
ctx.clear();
if let Some(s) = &self.throwshade.shader {
@@ -287,10 +331,9 @@ impl teleia::state::Game for Overlay {
// log::info!("eyes: {:?}", self.tracking_eyes);
s.set_vec2(ctx, "tracking_eyes", &glam::Vec2::new(self.tracking_eyes.0, self.tracking_eyes.1));
s.set_mat4(ctx, "tracking_neck", &glam::Mat4::from_quat(self.tracking_neck));
- self.assets.font.render_text(
- ctx, &glam::Vec2::new(0.0, 0.0),
- &format!("shader by {}", self.throwshade.author),
- );
+ s.set_vec2(ctx, "emacs_cursor", &glam::Vec2::new(self.emacs_cursor.0, self.emacs_cursor.1));
+ s.set_vec2(ctx, "mouse_cursor", &glam::Vec2::new(self.mouse_cursor.0, self.mouse_cursor.1));
+ s.set_i32(ctx, "heartrate", self.emacs_heartrate);
}
if let Some(t@Toggle { val: true, .. }) = self.get_toggle(ctx, st, "adblock") {
st.bind_2d(ctx, &self.assets.shader_flat);
@@ -304,13 +347,22 @@ impl teleia::state::Game for Overlay {
);
self.assets.mesh_square.render(ctx);
}
+ let mut authors = Vec::new();
+ if let Some(_) = &self.throwshade.shader {
+ authors.push(format!("shader by {}", self.throwshade.author));
+ }
+ if let Some(a) = &self.muzak_author {
+ authors.push(format!("music by {}", a));
+ }
+ let astr: String = authors.join(", ");
+ self.assets.font.render_text(ctx, &glam::Vec2::new(0.0, 0.0), &astr);
// self.render_model_terminal(ctx, st);
- Some(())
+ Ok(())
}
}
#[tokio::main]
-pub async fn main() {
+pub async fn main() -> Erm<()> {
let matches = command!()
.propagate_version(true)
.subcommand_required(true)
@@ -330,10 +382,10 @@ pub async fn main() {
.get_matches();
match matches.subcommand() {
Some(("overlay", _cm)) => {
- teleia::run("LCOLONQ", 1920, 1080, teleia::Options::OVERLAY, Overlay::overlay).await;
+ teleia::run("LCOLONQ", 1920, 1080, teleia::Options::OVERLAY, Overlay::overlay).await?;
},
Some(("terminal", _cm)) => {
- teleia::run("LCOLONQ", 1920, 1080, teleia::Options::HIDDEN, Overlay::terminal).await;
+ teleia::run("LCOLONQ", 1920, 1080, teleia::Options::HIDDEN, Overlay::terminal).await?;
},
Some(("server", _cm)) => {
env_logger::Builder::new().filter(None, log::LevelFilter::Info).init();
@@ -341,4 +393,5 @@ pub async fn main() {
},
_ => unreachable!("no subcommand"),
}
+ Ok(())
}
diff --git a/crates/throwshade/src/assets/shaders/throwshade/frag.glsl b/crates/throwshade/src/assets/shaders/throwshade/frag.glsl
index 745b6e6..962deac 100644
--- a/crates/throwshade/src/assets/shaders/throwshade/frag.glsl
+++ b/crates/throwshade/src/assets/shaders/throwshade/frag.glsl
@@ -21,6 +21,11 @@ uniform float tracking_mouth;
uniform vec2 tracking_eyes;
uniform mat4 tracking_neck;
+uniform vec2 emacs_cursor;
+uniform vec2 mouse_cursor;
+
+uniform int heartrate;
+
vec4 shade(vec2);
void main() {