diff --git a/Cargo.lock b/Cargo.lock index 87a91f8..8eaabce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -144,6 +144,133 @@ dependencies = [ "num-traits", ] +[[package]] +name = "async-broadcast" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cd0e2e25ea8e5f7e9df04578dc6cf5c83577fd09b1a46aaf5c85e1c33f2a7e" +dependencies = [ + "event-listener", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-channel" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a" +dependencies = [ + "concurrent-queue", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8828ec6e544c02b0d6691d21ed9f9218d0384a82542855073c2a3f58304aaf0" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "slab", +] + +[[package]] +name = "async-fs" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a" +dependencies = [ + "async-lock", + "blocking", + "futures-lite", +] + +[[package]] +name = "async-io" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6baa8f0178795da0e71bc42c9e5d13261aac7ee549853162e66a241ba17964" +dependencies = [ + "async-lock", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite", + "parking", + "polling", + "rustix", + "slab", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "async-lock" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" +dependencies = [ + "event-listener", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-process" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7eda79bbd84e29c2b308d1dc099d7de8dcc7035e48f4bf5dc4a531a44ff5e2a" +dependencies = [ + "async-channel", + "async-io", + "async-lock", + "async-signal", + "async-task", + "blocking", + "cfg-if", + "event-listener", + "futures-lite", + "rustix", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "async-recursion" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "async-signal" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "794f185324c2f00e771cd9f1ae8b5ac68be2ca7abb129a87afd6e86d228bc54d" +dependencies = [ + "async-io", + "async-lock", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix", + "signal-hook-registry", + "slab", + "windows-sys 0.52.0", +] + [[package]] name = "async-stream" version = "0.3.5" @@ -166,6 +293,12 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "async-task" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" + [[package]] name = "async-trait" version = "0.1.80" @@ -177,6 +310,12 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.3.0" @@ -261,6 +400,28 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "blocking" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" +dependencies = [ + "async-channel", + "async-task", + "futures-io", + "futures-lite", + "piper", +] + [[package]] name = "bytemuck" version = "1.16.0" @@ -325,6 +486,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "cfg_aliases" version = "0.2.1" @@ -413,18 +580,6 @@ dependencies = [ "owo-colors", ] -[[package]] -name = "color-rs" -version = "0.8.0" -source = "git+https://github.com/arturoc/color-rs.git#d50d5e37aaf91ccd39d0832f43a417e3405d2ece" -dependencies = [ - "angle", - "half", - "num-traits", - "serde", - "serde_derive", -] - [[package]] name = "colorchoice" version = "1.0.1" @@ -497,6 +652,15 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + [[package]] name = "crc32fast" version = "1.4.2" @@ -521,6 +685,16 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "cty" version = "0.2.2" @@ -533,6 +707,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "directories" version = "5.0.1" @@ -623,6 +807,33 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +[[package]] +name = "endi" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3d8a32ae18130a3c84dd492d4215c3d913c3b07c6b63c2eb3eb7ff1101ab7bf" + +[[package]] +name = "enumflags2" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d232db7f5956f3f14313dc2f87985c58bd2c695ce124c8cdd984e08e15ac133d" +dependencies = [ + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "env_logger" version = "0.10.2" @@ -649,6 +860,27 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "event-listener" +version = "5.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" +dependencies = [ + "event-listener", + "pin-project-lite", +] + [[package]] name = "eyre" version = "0.6.12" @@ -719,6 +951,25 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-lite" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + [[package]] name = "futures-sink" version = "0.3.30" @@ -738,9 +989,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", + "futures-io", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", + "slab", ] [[package]] @@ -757,6 +1012,16 @@ dependencies = [ "windows", ] +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.2.15" @@ -867,6 +1132,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "http" version = "0.2.12" @@ -1296,6 +1567,19 @@ dependencies = [ "memoffset", ] +[[package]] +name = "nix" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "cfg_aliases 0.1.1", + "libc", + "memoffset", +] + [[package]] name = "nix" version = "0.29.0" @@ -1304,7 +1588,7 @@ checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ "bitflags 2.5.0", "cfg-if", - "cfg_aliases", + "cfg_aliases 0.2.1", "libc", ] @@ -1419,6 +1703,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "ordered-stream" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +dependencies = [ + "futures-core", + "pin-project-lite", +] + [[package]] name = "overload" version = "0.1.1" @@ -1431,6 +1725,12 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" +[[package]] +name = "parking" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" + [[package]] name = "parking_lot" version = "0.11.2" @@ -1517,6 +1817,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1d5c74c9876f070d3e8fd503d748c7d974c3e48da8f41350fa5222ef9b4391" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + [[package]] name = "pkg-config" version = "0.3.30" @@ -1790,9 +2101,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "1.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustc_version" @@ -1918,6 +2229,17 @@ dependencies = [ "serde", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -1927,6 +2249,19 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shiva-color-rs" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7bea807e4f40f1a3df2717cc134562397b6a8f869f22568388fd5eb14bb1b69" +dependencies = [ + "angle", + "half", + "num-traits", + "serde", + "serde_derive", +] + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -2015,10 +2350,9 @@ checksum = "2f2b15926089e5526bb2dd738a2eb0e59034356e06eb71e1cd912358c0e62c4d" [[package]] name = "stardust-xr" version = "0.45.0" -source = "git+https://github.com/StardustXR/core.git?branch=dev#4f2a7f87a864d07db4a2a783d52c30a4926e8925" +source = "git+https://github.com/StardustXR/core.git?branch=dev#3b6b77aafc2058e40462bf528703be317a8323d1" dependencies = [ "cluFlock", - "color-rs", "dirs", "global_counter", "mint", @@ -2026,6 +2360,7 @@ dependencies = [ "parking_lot 0.12.3", "rustc-hash", "serde", + "shiva-color-rs", "stardust-xr-schemas", "thiserror", "tokio", @@ -2035,7 +2370,7 @@ dependencies = [ [[package]] name = "stardust-xr-schemas" version = "1.5.3" -source = "git+https://github.com/StardustXR/core.git?branch=dev#4f2a7f87a864d07db4a2a783d52c30a4926e8925" +source = "git+https://github.com/StardustXR/core.git?branch=dev#3b6b77aafc2058e40462bf528703be317a8323d1" dependencies = [ "flatbuffers", "flexbuffers", @@ -2045,6 +2380,7 @@ dependencies = [ "serde", "serde_repr", "thiserror", + "zbus", ] [[package]] @@ -2085,6 +2421,7 @@ dependencies = [ "wayland-backend", "wayland-scanner", "xkbcommon", + "zbus", ] [[package]] @@ -2099,6 +2436,12 @@ dependencies = [ "stardust-xr-schemas", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "stereokit-rust" version = "0.1.0" @@ -2472,6 +2815,23 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "uds_windows" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9" +dependencies = [ + "memoffset", + "tempfile", + "winapi", +] + [[package]] name = "unicode-ident" version = "1.0.12" @@ -2904,6 +3264,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "xdg-home" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca91dcf8f93db085f3a0a29358cd0b9d670915468f4290e8b85d118a34211ab8" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "xkbcommon" version = "0.7.0" @@ -2926,3 +3296,103 @@ name = "xml-rs" version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" + +[[package]] +name = "zbus" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23915fcb26e7a9a9dc05fd93a9870d336d6d032cd7e8cebf1c5c37666489fdd5" +dependencies = [ + "async-broadcast", + "async-executor", + "async-fs", + "async-io", + "async-lock", + "async-process", + "async-recursion", + "async-task", + "async-trait", + "blocking", + "enumflags2", + "event-listener", + "futures-core", + "futures-sink", + "futures-util", + "hex", + "nix 0.28.0", + "ordered-stream", + "rand", + "serde", + "serde_repr", + "sha1", + "static_assertions", + "tokio", + "tracing", + "uds_windows", + "windows-sys 0.52.0", + "xdg-home", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02bcca0b586d2f8589da32347b4784ba424c4891ed86aa5b50d5e88f6b2c4f5d" +dependencies = [ + "proc-macro-crate 3.1.0", + "proc-macro2", + "quote", + "syn 2.0.66", + "zvariant_utils", +] + +[[package]] +name = "zbus_names" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b9b1fef7d021261cc16cba64c351d291b715febe0fa10dc3a443ac5a5022e6c" +dependencies = [ + "serde", + "static_assertions", + "zvariant", +] + +[[package]] +name = "zvariant" +version = "4.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa6d31a02fbfb602bfde791de7fedeb9c2c18115b3d00f3a36e489f46ffbbc7" +dependencies = [ + "endi", + "enumflags2", + "serde", + "static_assertions", + "zvariant_derive", +] + +[[package]] +name = "zvariant_derive" +version = "4.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "642bf1b6b6d527988b3e8193d20969d53700a36eac734d21ae6639db168701c8" +dependencies = [ + "proc-macro-crate 3.1.0", + "proc-macro2", + "quote", + "syn 2.0.66", + "zvariant_utils", +] + +[[package]] +name = "zvariant_utils" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc242db087efc22bd9ade7aa7809e4ba828132edc312871584a6b4391bdf8786" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] diff --git a/Cargo.toml b/Cargo.toml index 9c78372..037c444 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,7 +56,7 @@ nanoid = "0.4.0" once_cell = "1.19.0" parking_lot = "0.12.3" portable-atomic = { version = "1.6.0", features = ["float", "std"] } -rustc-hash = "1.1.0" +rustc-hash = "2.0.0" tokio = { version = "1.38.0", features = ["rt-multi-thread", "signal", "time"] } send_wrapper = "0.6.0" prisma = "0.1.1" @@ -75,6 +75,7 @@ wayland-backend = "0.3.4" toml = "0.8.14" global_counter = "=0.2.2" slotmap = "1.0.7" +zbus = { version = "4.3.0", default-features = false, features = ["tokio"] } [dependencies.smithay] # git = "https://github.com/technobaboo/smithay.git" diff --git a/src/core/client.rs b/src/core/client.rs index 00e65c3..82897d0 100644 --- a/src/core/client.rs +++ b/src/core/client.rs @@ -6,7 +6,7 @@ use super::{ use crate::{ core::{registry::OwnedRegistry, task}, nodes::{ - audio, data, drawable, fields, hmd, input, items, + audio, data, drawable, fields, input, items, root::{ClientState, Root}, spatial, Node, }, @@ -108,7 +108,6 @@ impl Client { }); let _ = client.scenegraph.client.set(Arc::downgrade(&client)); let _ = client.root.set(Root::create(&client, state.root)?); - hmd::make_alias(&client)?; spatial::create_interface(&client)?; fields::create_interface(&client)?; drawable::create_interface(&client)?; diff --git a/src/main.rs b/src/main.rs index 6cde995..fd43a7a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,12 +8,14 @@ mod wayland; use crate::core::destroy_queue; use crate::nodes::items::camera; -use crate::nodes::{audio, drawable, hmd, input}; +use crate::nodes::{audio, drawable, input}; use clap::Parser; use core::client::Client; use core::task; use directories::ProjectDirs; +use nodes::spatial::Spatial; +use objects::hmd::HMD; use objects::ServerObjects; use once_cell::sync::OnceCell; use session::{launch_start, save_session}; @@ -33,6 +35,7 @@ use tokio::sync::Notify; use tracing::metadata::LevelFilter; use tracing::{debug_span, error, info}; use tracing_subscriber::{fmt, prelude::*, EnvFilter}; +use zbus::Connection; #[derive(Parser)] #[clap(author, version, about, long_about = None)] @@ -107,6 +110,13 @@ async fn main() { error!("Unable to get Stardust project directories, default skybox and startup script will not work."); } + let dbus_connection = Connection::session().await.unwrap(); + let hmd = HMD::create(&dbus_connection).await; + dbus_connection + .request_name("org.stardustxr.HMD") + .await + .unwrap(); + let sk_ready_notifier = Arc::new(Notify::new()); let stereokit_loop = tokio::task::spawn_blocking({ let sk_ready_notifier = sk_ready_notifier.clone(); @@ -119,6 +129,7 @@ async fn main() { project_dirs, flatscreen, overlay_priority, + hmd, ) } }); @@ -148,6 +159,7 @@ fn stereokit_loop( project_dirs: Option, intentional_flatscreen: bool, overlay_priority: Option, + hmd: Arc, ) { let sk = SkSettings::default() .app_name("Stardust XR") @@ -206,7 +218,7 @@ fn stereokit_loop( sk_ready_notifier.notify_waiters(); info!("Stardust ready!"); - let mut objects = ServerObjects::new(intentional_flatscreen, &sk); + let mut objects = ServerObjects::new(intentional_flatscreen, &sk, hmd); let mut last_frame_delta = Duration::ZERO; let mut sleep_duration = Duration::ZERO; @@ -215,7 +227,6 @@ fn stereokit_loop( let _span = debug_span!("StereoKit step"); let _span = _span.enter(); - hmd::frame(); camera::update(token); #[cfg(feature = "wayland")] wayland.frame_event(); diff --git a/src/nodes/hmd.rs b/src/nodes/hmd.rs deleted file mode 100644 index e152057..0000000 --- a/src/nodes/hmd.rs +++ /dev/null @@ -1,34 +0,0 @@ -use super::{ - alias::Alias, - spatial::{Spatial, SPATIAL_ASPECT_ALIAS_INFO}, - Node, -}; -use crate::core::client::{Client, INTERNAL_CLIENT}; -use color_eyre::eyre::Result; -use glam::{vec3, Mat4}; -use std::sync::Arc; -use stereokit_rust::system::Input; - -lazy_static::lazy_static! { - static ref HMD: Arc = create(); -} - -fn create() -> Arc { - let node = Arc::new(Node::generate(&INTERNAL_CLIENT, false)); - Spatial::add_to(&node, None, Mat4::IDENTITY, false); - node -} - -pub fn frame() { - let spatial = HMD.get_aspect::().unwrap(); - let hmd_pose = Input::get_head(); - spatial.set_local_transform(Mat4::from_scale_rotation_translation( - vec3(1.0, 1.0, 1.0), - hmd_pose.orientation.into(), - hmd_pose.position.into(), - )); -} - -pub fn make_alias(client: &Arc) -> Result> { - Alias::create(&HMD, client, SPATIAL_ASPECT_ALIAS_INFO.clone(), None) -} diff --git a/src/nodes/mod.rs b/src/nodes/mod.rs index c42b220..01f16d7 100644 --- a/src/nodes/mod.rs +++ b/src/nodes/mod.rs @@ -3,7 +3,6 @@ pub mod audio; pub mod data; pub mod drawable; pub mod fields; -pub mod hmd; pub mod input; pub mod items; pub mod root; diff --git a/src/objects/hmd.rs b/src/objects/hmd.rs new file mode 100644 index 0000000..345f332 --- /dev/null +++ b/src/objects/hmd.rs @@ -0,0 +1,28 @@ +use crate::{ + core::client::INTERNAL_CLIENT, + nodes::{ + spatial::{Spatial, EXPORTED_SPATIALS}, + Node, + }, +}; +use glam::Mat4; +use std::sync::Arc; +use zbus::{interface, Connection}; + +pub struct HMD; +impl HMD { + pub async fn create(connection: &Connection) -> Arc { + let node = Arc::new(Node::generate(&INTERNAL_CLIENT, false)); + let spatial = Spatial::add_to(&node, None, Mat4::IDENTITY, false); + EXPORTED_SPATIALS.lock().insert(0, node); + connection.object_server().at("/hmd", Self).await.unwrap(); + spatial + } +} +#[interface(name = "org.stardustxr.SpatialRef")] +impl HMD { + #[zbus(property)] + pub fn uid(&self) -> u64 { + 0 + } +} diff --git a/src/objects/mod.rs b/src/objects/mod.rs index e0926b7..9f02a00 100644 --- a/src/objects/mod.rs +++ b/src/objects/mod.rs @@ -1,18 +1,23 @@ +use crate::nodes::spatial::Spatial; +use glam::{vec3, Mat4}; use input::{ eye_pointer::EyePointer, mouse_pointer::MousePointer, sk_controller::SkController, sk_hand::SkHand, }; use play_space::PlaySpace; +use std::sync::Arc; use stereokit_rust::{ sk::{DisplayMode, MainThreadToken, Sk}, - system::{Handed, World}, + system::{Handed, Input, World}, util::Device, }; +pub mod hmd; pub mod input; pub mod play_space; pub struct ServerObjects { + hmd: Arc, mouse_pointer: Option, hands: Option<(SkHand, SkHand)>, controllers: Option<(SkController, SkController)>, @@ -20,8 +25,9 @@ pub struct ServerObjects { play_space: Option, } impl ServerObjects { - pub fn new(intentional_flatscreen: bool, sk: &Sk) -> ServerObjects { + pub fn new(intentional_flatscreen: bool, sk: &Sk, hmd: Arc) -> ServerObjects { ServerObjects { + hmd, mouse_pointer: intentional_flatscreen .then(MousePointer::new) .transpose() @@ -50,6 +56,14 @@ impl ServerObjects { } pub fn update(&mut self, sk: &Sk, token: &MainThreadToken) { + let hmd_pose = Input::get_head(); + self.hmd + .set_local_transform(Mat4::from_scale_rotation_translation( + vec3(1.0, 1.0, 1.0), + hmd_pose.orientation.into(), + hmd_pose.position.into(), + )); + if let Some(mouse_pointer) = self.mouse_pointer.as_mut() { mouse_pointer.update(); }