diff --git a/crates/punktfunk-host/src/audio.rs b/crates/punktfunk-host/src/audio.rs index 8a73f3f..5146dbc 100644 --- a/crates/punktfunk-host/src/audio.rs +++ b/crates/punktfunk-host/src/audio.rs @@ -88,6 +88,8 @@ pub fn open_virtual_mic(_channels: u32) -> Result> { #[cfg(target_os = "linux")] mod linux; #[cfg(target_os = "windows")] +#[path = "audio/windows/wasapi_cap.rs"] mod wasapi_cap; #[cfg(target_os = "windows")] +#[path = "audio/windows/wasapi_mic.rs"] mod wasapi_mic; diff --git a/crates/punktfunk-host/src/audio/linux.rs b/crates/punktfunk-host/src/audio/linux/mod.rs similarity index 100% rename from crates/punktfunk-host/src/audio/linux.rs rename to crates/punktfunk-host/src/audio/linux/mod.rs diff --git a/crates/punktfunk-host/src/audio/wasapi_cap.rs b/crates/punktfunk-host/src/audio/windows/wasapi_cap.rs similarity index 100% rename from crates/punktfunk-host/src/audio/wasapi_cap.rs rename to crates/punktfunk-host/src/audio/windows/wasapi_cap.rs diff --git a/crates/punktfunk-host/src/audio/wasapi_mic.rs b/crates/punktfunk-host/src/audio/windows/wasapi_mic.rs similarity index 100% rename from crates/punktfunk-host/src/audio/wasapi_mic.rs rename to crates/punktfunk-host/src/audio/windows/wasapi_mic.rs diff --git a/crates/punktfunk-host/src/capture.rs b/crates/punktfunk-host/src/capture.rs index 21fb74f..12d5d9c 100644 --- a/crates/punktfunk-host/src/capture.rs +++ b/crates/punktfunk-host/src/capture.rs @@ -472,17 +472,25 @@ pub fn capture_virtual_output( anyhow::bail!("virtual-output capture requires Linux or Windows") } +// Goal-1 stage 6: the Windows backends live under `capture/windows/`, the Linux one under `capture/linux/` +// (`#[path]` keeps the module names flat, so every `crate::capture::*` path is unchanged). #[cfg(target_os = "windows")] +#[path = "capture/windows/composed_flip.rs"] pub mod composed_flip; #[cfg(target_os = "windows")] +#[path = "capture/windows/desktop_watch.rs"] pub mod desktop_watch; #[cfg(target_os = "windows")] +#[path = "capture/windows/dxgi.rs"] pub mod dxgi; #[cfg(target_os = "windows")] +#[path = "capture/windows/idd_push.rs"] pub mod idd_push; #[cfg(target_os = "linux")] mod linux; #[cfg(target_os = "windows")] +#[path = "capture/windows/wgc.rs"] pub mod wgc; #[cfg(target_os = "windows")] +#[path = "capture/windows/wgc_relay.rs"] pub mod wgc_relay; diff --git a/crates/punktfunk-host/src/capture/linux.rs b/crates/punktfunk-host/src/capture/linux/mod.rs similarity index 100% rename from crates/punktfunk-host/src/capture/linux.rs rename to crates/punktfunk-host/src/capture/linux/mod.rs diff --git a/crates/punktfunk-host/src/capture/composed_flip.rs b/crates/punktfunk-host/src/capture/windows/composed_flip.rs similarity index 100% rename from crates/punktfunk-host/src/capture/composed_flip.rs rename to crates/punktfunk-host/src/capture/windows/composed_flip.rs diff --git a/crates/punktfunk-host/src/capture/desktop_watch.rs b/crates/punktfunk-host/src/capture/windows/desktop_watch.rs similarity index 100% rename from crates/punktfunk-host/src/capture/desktop_watch.rs rename to crates/punktfunk-host/src/capture/windows/desktop_watch.rs diff --git a/crates/punktfunk-host/src/capture/dxgi.rs b/crates/punktfunk-host/src/capture/windows/dxgi.rs similarity index 100% rename from crates/punktfunk-host/src/capture/dxgi.rs rename to crates/punktfunk-host/src/capture/windows/dxgi.rs diff --git a/crates/punktfunk-host/src/capture/idd_push.rs b/crates/punktfunk-host/src/capture/windows/idd_push.rs similarity index 100% rename from crates/punktfunk-host/src/capture/idd_push.rs rename to crates/punktfunk-host/src/capture/windows/idd_push.rs diff --git a/crates/punktfunk-host/src/capture/wgc.rs b/crates/punktfunk-host/src/capture/windows/wgc.rs similarity index 100% rename from crates/punktfunk-host/src/capture/wgc.rs rename to crates/punktfunk-host/src/capture/windows/wgc.rs diff --git a/crates/punktfunk-host/src/capture/wgc_relay.rs b/crates/punktfunk-host/src/capture/windows/wgc_relay.rs similarity index 100% rename from crates/punktfunk-host/src/capture/wgc_relay.rs rename to crates/punktfunk-host/src/capture/windows/wgc_relay.rs diff --git a/crates/punktfunk-host/src/encode.rs b/crates/punktfunk-host/src/encode.rs index a85ce96..a493b14 100644 --- a/crates/punktfunk-host/src/encode.rs +++ b/crates/punktfunk-host/src/encode.rs @@ -531,15 +531,21 @@ pub fn windows_codec_support() -> CodecSupport { }) } +// Goal-1 stage 6: GPU/CPU encoders confined to `encode/windows/` (NVENC, AMF/QSV ffmpeg, software) and +// `encode/linux/` (NVENC/CUDA + VAAPI); `#[path]` keeps the `crate::encode::*` module names flat. #[cfg(all(target_os = "windows", feature = "amf-qsv"))] +#[path = "encode/windows/ffmpeg_win.rs"] mod ffmpeg_win; #[cfg(target_os = "linux")] mod linux; #[cfg(all(target_os = "windows", feature = "nvenc"))] +#[path = "encode/windows/nvenc.rs"] mod nvenc; #[cfg(target_os = "windows")] +#[path = "encode/windows/sw.rs"] mod sw; #[cfg(target_os = "linux")] +#[path = "encode/linux/vaapi.rs"] mod vaapi; #[cfg(test)] diff --git a/crates/punktfunk-host/src/encode/linux.rs b/crates/punktfunk-host/src/encode/linux/mod.rs similarity index 100% rename from crates/punktfunk-host/src/encode/linux.rs rename to crates/punktfunk-host/src/encode/linux/mod.rs diff --git a/crates/punktfunk-host/src/encode/vaapi.rs b/crates/punktfunk-host/src/encode/linux/vaapi.rs similarity index 100% rename from crates/punktfunk-host/src/encode/vaapi.rs rename to crates/punktfunk-host/src/encode/linux/vaapi.rs diff --git a/crates/punktfunk-host/src/encode/ffmpeg_win.rs b/crates/punktfunk-host/src/encode/windows/ffmpeg_win.rs similarity index 100% rename from crates/punktfunk-host/src/encode/ffmpeg_win.rs rename to crates/punktfunk-host/src/encode/windows/ffmpeg_win.rs diff --git a/crates/punktfunk-host/src/encode/nvenc.rs b/crates/punktfunk-host/src/encode/windows/nvenc.rs similarity index 100% rename from crates/punktfunk-host/src/encode/nvenc.rs rename to crates/punktfunk-host/src/encode/windows/nvenc.rs diff --git a/crates/punktfunk-host/src/encode/sw.rs b/crates/punktfunk-host/src/encode/windows/sw.rs similarity index 100% rename from crates/punktfunk-host/src/encode/sw.rs rename to crates/punktfunk-host/src/encode/windows/sw.rs diff --git a/crates/punktfunk-host/src/inject.rs b/crates/punktfunk-host/src/inject.rs index 137704a..867c164 100644 --- a/crates/punktfunk-host/src/inject.rs +++ b/crates/punktfunk-host/src/inject.rs @@ -425,29 +425,39 @@ fn gs_button_to_evdev(b: u32) -> Option { }) } +// Goal-1 stage 6: Linux UHID/uinput/libei/wlr backends under `inject/linux/`, the Windows UMDF/SendInput +// backends under `inject/windows/`, and the transport-independent HID codecs under `inject/proto/`; +// `#[path]` keeps every `crate::inject::*` module name flat. #[cfg(target_os = "linux")] +#[path = "inject/linux/dualsense.rs"] pub mod dualsense; /// Transport-independent DualSense HID contract, shared by the Linux UHID backend ([`dualsense`]) /// and the Windows UMDF-driver backend ([`dualsense_windows`]). #[cfg(any(target_os = "linux", target_os = "windows"))] +#[path = "inject/proto/dualsense_proto.rs"] pub mod dualsense_proto; /// Windows: virtual DualSense via the UMDF minidriver + a shared-memory host channel. #[cfg(target_os = "windows")] +#[path = "inject/windows/dualsense_windows.rs"] pub mod dualsense_windows; #[cfg(target_os = "linux")] +#[path = "inject/linux/dualshock4.rs"] pub mod dualshock4; /// Transport-independent DualShock 4 HID codec used by the Windows UMDF-driver backend /// ([`dualshock4_windows`]). (The Linux backend still carries its own copy — see the module FIXME.) #[cfg(any(target_os = "linux", target_os = "windows"))] +#[path = "inject/proto/dualshock4_proto.rs"] pub mod dualshock4_proto; /// Windows: virtual DualShock 4 via the same UMDF minidriver + shared-memory channel (device-type 1). #[cfg(target_os = "windows")] +#[path = "inject/windows/dualshock4_windows.rs"] pub mod dualshock4_windows; #[cfg(target_os = "linux")] +#[path = "inject/linux/gamepad.rs"] pub mod gamepad; /// Windows: virtual Xbox 360 pads via the in-tree XUSB companion UMDF driver (classic XInput). #[cfg(target_os = "windows")] -#[path = "inject/gamepad_windows.rs"] +#[path = "inject/windows/gamepad_windows.rs"] pub mod gamepad; /// Stub — virtual gamepads need Linux uinput or the Windows UMDF drivers; events are dropped elsewhere. #[cfg(not(any(target_os = "linux", target_os = "windows")))] @@ -463,10 +473,13 @@ pub mod gamepad { } } #[cfg(target_os = "linux")] +#[path = "inject/linux/libei.rs"] mod libei; #[cfg(target_os = "windows")] +#[path = "inject/windows/sendinput.rs"] mod sendinput; #[cfg(target_os = "linux")] +#[path = "inject/linux/wlr.rs"] mod wlr; #[cfg(test)] diff --git a/crates/punktfunk-host/src/inject/dualsense.rs b/crates/punktfunk-host/src/inject/linux/dualsense.rs similarity index 100% rename from crates/punktfunk-host/src/inject/dualsense.rs rename to crates/punktfunk-host/src/inject/linux/dualsense.rs diff --git a/crates/punktfunk-host/src/inject/dualshock4.rs b/crates/punktfunk-host/src/inject/linux/dualshock4.rs similarity index 100% rename from crates/punktfunk-host/src/inject/dualshock4.rs rename to crates/punktfunk-host/src/inject/linux/dualshock4.rs diff --git a/crates/punktfunk-host/src/inject/gamepad.rs b/crates/punktfunk-host/src/inject/linux/gamepad.rs similarity index 100% rename from crates/punktfunk-host/src/inject/gamepad.rs rename to crates/punktfunk-host/src/inject/linux/gamepad.rs diff --git a/crates/punktfunk-host/src/inject/libei.rs b/crates/punktfunk-host/src/inject/linux/libei.rs similarity index 100% rename from crates/punktfunk-host/src/inject/libei.rs rename to crates/punktfunk-host/src/inject/linux/libei.rs diff --git a/crates/punktfunk-host/src/inject/wlr.rs b/crates/punktfunk-host/src/inject/linux/wlr.rs similarity index 100% rename from crates/punktfunk-host/src/inject/wlr.rs rename to crates/punktfunk-host/src/inject/linux/wlr.rs diff --git a/crates/punktfunk-host/src/inject/dualsense_proto.rs b/crates/punktfunk-host/src/inject/proto/dualsense_proto.rs similarity index 100% rename from crates/punktfunk-host/src/inject/dualsense_proto.rs rename to crates/punktfunk-host/src/inject/proto/dualsense_proto.rs diff --git a/crates/punktfunk-host/src/inject/dualshock4_proto.rs b/crates/punktfunk-host/src/inject/proto/dualshock4_proto.rs similarity index 100% rename from crates/punktfunk-host/src/inject/dualshock4_proto.rs rename to crates/punktfunk-host/src/inject/proto/dualshock4_proto.rs diff --git a/crates/punktfunk-host/src/inject/dualsense_windows.rs b/crates/punktfunk-host/src/inject/windows/dualsense_windows.rs similarity index 100% rename from crates/punktfunk-host/src/inject/dualsense_windows.rs rename to crates/punktfunk-host/src/inject/windows/dualsense_windows.rs diff --git a/crates/punktfunk-host/src/inject/dualshock4_windows.rs b/crates/punktfunk-host/src/inject/windows/dualshock4_windows.rs similarity index 100% rename from crates/punktfunk-host/src/inject/dualshock4_windows.rs rename to crates/punktfunk-host/src/inject/windows/dualshock4_windows.rs diff --git a/crates/punktfunk-host/src/inject/gamepad_windows.rs b/crates/punktfunk-host/src/inject/windows/gamepad_windows.rs similarity index 100% rename from crates/punktfunk-host/src/inject/gamepad_windows.rs rename to crates/punktfunk-host/src/inject/windows/gamepad_windows.rs diff --git a/crates/punktfunk-host/src/inject/sendinput.rs b/crates/punktfunk-host/src/inject/windows/sendinput.rs similarity index 100% rename from crates/punktfunk-host/src/inject/sendinput.rs rename to crates/punktfunk-host/src/inject/windows/sendinput.rs diff --git a/crates/punktfunk-host/src/dmabuf_fence.rs b/crates/punktfunk-host/src/linux/dmabuf_fence.rs similarity index 100% rename from crates/punktfunk-host/src/dmabuf_fence.rs rename to crates/punktfunk-host/src/linux/dmabuf_fence.rs diff --git a/crates/punktfunk-host/src/drm_sync.rs b/crates/punktfunk-host/src/linux/drm_sync.rs similarity index 100% rename from crates/punktfunk-host/src/drm_sync.rs rename to crates/punktfunk-host/src/linux/drm_sync.rs diff --git a/crates/punktfunk-host/src/zerocopy/cuda.rs b/crates/punktfunk-host/src/linux/zerocopy/cuda.rs similarity index 100% rename from crates/punktfunk-host/src/zerocopy/cuda.rs rename to crates/punktfunk-host/src/linux/zerocopy/cuda.rs diff --git a/crates/punktfunk-host/src/zerocopy/egl.rs b/crates/punktfunk-host/src/linux/zerocopy/egl.rs similarity index 100% rename from crates/punktfunk-host/src/zerocopy/egl.rs rename to crates/punktfunk-host/src/linux/zerocopy/egl.rs diff --git a/crates/punktfunk-host/src/zerocopy/mod.rs b/crates/punktfunk-host/src/linux/zerocopy/mod.rs similarity index 100% rename from crates/punktfunk-host/src/zerocopy/mod.rs rename to crates/punktfunk-host/src/linux/zerocopy/mod.rs diff --git a/crates/punktfunk-host/src/zerocopy/vulkan.rs b/crates/punktfunk-host/src/linux/zerocopy/vulkan.rs similarity index 100% rename from crates/punktfunk-host/src/zerocopy/vulkan.rs rename to crates/punktfunk-host/src/linux/zerocopy/vulkan.rs diff --git a/crates/punktfunk-host/src/main.rs b/crates/punktfunk-host/src/main.rs index 44d2f92..a8bfc01 100644 --- a/crates/punktfunk-host/src/main.rs +++ b/crates/punktfunk-host/src/main.rs @@ -18,9 +18,13 @@ mod audio; mod capture; mod config; mod discovery; +// Goal-1 stage 6: top-level platform-only modules live under `src/linux/` and `src/windows/`; `#[path]` +// keeps the `crate::*` module names flat (every existing path is unchanged). #[cfg(target_os = "linux")] +#[path = "linux/dmabuf_fence.rs"] mod dmabuf_fence; #[cfg(target_os = "linux")] +#[path = "linux/drm_sync.rs"] mod drm_sync; mod encode; mod gamestream; @@ -34,18 +38,23 @@ mod pipeline; mod punktfunk1; mod pwinit; #[cfg(target_os = "windows")] +#[path = "windows/service.rs"] mod service; mod session_plan; mod session_tuning; mod spike; mod vdisplay; #[cfg(target_os = "windows")] +#[path = "windows/wgc_helper.rs"] mod wgc_helper; #[cfg(target_os = "windows")] +#[path = "windows/win_adapter.rs"] mod win_adapter; #[cfg(target_os = "windows")] +#[path = "windows/win_display.rs"] mod win_display; #[cfg(target_os = "linux")] +#[path = "linux/zerocopy/mod.rs"] mod zerocopy; use anyhow::{bail, Context, Result}; diff --git a/crates/punktfunk-host/src/vdisplay.rs b/crates/punktfunk-host/src/vdisplay.rs index 3bc3947..582f435 100644 --- a/crates/punktfunk-host/src/vdisplay.rs +++ b/crates/punktfunk-host/src/vdisplay.rs @@ -623,17 +623,25 @@ pub fn start_restore_worker() -> std::sync::Arc<()> { std::sync::Arc::new(()) } +// Goal-1 stage 6: per-compositor Linux backends under `vdisplay/linux/`, the Windows IddCx/SudoVDA +// backends under `vdisplay/windows/`; `#[path]` keeps the `crate::vdisplay::*` module names flat. #[cfg(target_os = "linux")] +#[path = "vdisplay/linux/gamescope.rs"] mod gamescope; #[cfg(target_os = "linux")] +#[path = "vdisplay/linux/kwin.rs"] mod kwin; #[cfg(target_os = "linux")] +#[path = "vdisplay/linux/mutter.rs"] mod mutter; #[cfg(target_os = "windows")] +#[path = "vdisplay/windows/pf_vdisplay.rs"] pub(crate) mod pf_vdisplay; #[cfg(target_os = "windows")] +#[path = "vdisplay/windows/sudovda.rs"] pub(crate) mod sudovda; #[cfg(target_os = "linux")] +#[path = "vdisplay/linux/wlroots.rs"] mod wlroots; #[cfg(test)] diff --git a/crates/punktfunk-host/src/vdisplay/gamescope.rs b/crates/punktfunk-host/src/vdisplay/linux/gamescope.rs similarity index 100% rename from crates/punktfunk-host/src/vdisplay/gamescope.rs rename to crates/punktfunk-host/src/vdisplay/linux/gamescope.rs diff --git a/crates/punktfunk-host/src/vdisplay/kwin.rs b/crates/punktfunk-host/src/vdisplay/linux/kwin.rs similarity index 100% rename from crates/punktfunk-host/src/vdisplay/kwin.rs rename to crates/punktfunk-host/src/vdisplay/linux/kwin.rs diff --git a/crates/punktfunk-host/src/vdisplay/mutter.rs b/crates/punktfunk-host/src/vdisplay/linux/mutter.rs similarity index 100% rename from crates/punktfunk-host/src/vdisplay/mutter.rs rename to crates/punktfunk-host/src/vdisplay/linux/mutter.rs diff --git a/crates/punktfunk-host/src/vdisplay/wlroots.rs b/crates/punktfunk-host/src/vdisplay/linux/wlroots.rs similarity index 100% rename from crates/punktfunk-host/src/vdisplay/wlroots.rs rename to crates/punktfunk-host/src/vdisplay/linux/wlroots.rs diff --git a/crates/punktfunk-host/src/vdisplay/pf_vdisplay.rs b/crates/punktfunk-host/src/vdisplay/windows/pf_vdisplay.rs similarity index 100% rename from crates/punktfunk-host/src/vdisplay/pf_vdisplay.rs rename to crates/punktfunk-host/src/vdisplay/windows/pf_vdisplay.rs diff --git a/crates/punktfunk-host/src/vdisplay/sudovda.rs b/crates/punktfunk-host/src/vdisplay/windows/sudovda.rs similarity index 100% rename from crates/punktfunk-host/src/vdisplay/sudovda.rs rename to crates/punktfunk-host/src/vdisplay/windows/sudovda.rs diff --git a/crates/punktfunk-host/src/service.rs b/crates/punktfunk-host/src/windows/service.rs similarity index 100% rename from crates/punktfunk-host/src/service.rs rename to crates/punktfunk-host/src/windows/service.rs diff --git a/crates/punktfunk-host/src/wgc_helper.rs b/crates/punktfunk-host/src/windows/wgc_helper.rs similarity index 100% rename from crates/punktfunk-host/src/wgc_helper.rs rename to crates/punktfunk-host/src/windows/wgc_helper.rs diff --git a/crates/punktfunk-host/src/win_adapter.rs b/crates/punktfunk-host/src/windows/win_adapter.rs similarity index 100% rename from crates/punktfunk-host/src/win_adapter.rs rename to crates/punktfunk-host/src/windows/win_adapter.rs diff --git a/crates/punktfunk-host/src/win_display.rs b/crates/punktfunk-host/src/windows/win_display.rs similarity index 100% rename from crates/punktfunk-host/src/win_display.rs rename to crates/punktfunk-host/src/windows/win_display.rs diff --git a/docs/windows-host-goal1-plan.md b/docs/windows-host-goal1-plan.md index db62223..844d7e2 100644 --- a/docs/windows-host-goal1-plan.md +++ b/docs/windows-host-goal1-plan.md @@ -110,11 +110,21 @@ The three §2.3 tightenings have different coupling, so they split: Risk: medium (Tightening 1 is behavior-preserving + Windows-only → box-compile is the gate; on-glass parity is the same env-limited story as Stage 3). -**Stage 6 — `src/windows/` tree (cfg-sprawl confinement, plan §2.2).** -Move the Windows backends under `src/windows/` + `capture/windows/`, `encode/windows/`, `inject/windows/`, -`audio/windows/`, `vdisplay/windows.rs` behind one `#[cfg(windows)] mod windows;` seam. Pure file move + -mod/use-path updates — behaviour-identical. Risk: low-but-huge (dozens of files; compile-verify catches all). -Do LAST so the earlier semantic stages don't fight path churn. Verify: Linux + box build. +**Stage 6 — `windows/` + `linux/` tree confinement (cfg-sprawl, plan §2.2). ✅ DONE (Linux + box-build validated).** +Moved **36 platform-specific files** into per-module `windows/` and `linux/` folders (and the shared HID +codecs into `inject/proto/`): `capture/{windows,linux}/`, `encode/{windows,linux}/`, +`inject/{windows,linux,proto}/`, `audio/{windows,linux}/`, `vdisplay/{windows,linux}/`, and the top-level +`src/windows/` (service, wgc_helper, win_adapter, win_display) + `src/linux/` (dmabuf_fence, drm_sync, +zerocopy/). + +**Done with `#[path]`, not a module rename** — every file moves into its folder while the `crate::*::*` module +names stay **flat**, so all caller paths and every internal `super::`/`crate::` reference are **unchanged** +(only the parent `mod` decls gained `#[path = "…"]`). This is the codebase's existing pattern (inject's +`gamepad_windows`) and makes the move byte-identical in behaviour with **zero reference churn** — far lower +risk than collapsing to a single `crate::capture::windows::` namespace (that deeper rename is an optional +follow-on; this delivers the folder confinement the stage is about). Done LAST, after the semantic stages. +Verify: Linux `cargo check`/`clippy`/`fmt` clean; all 36 `#[path]` targets exist; no internal +`#[path]`/`include!`/file-child-`mod` in any moved file; **box `cargo check --features nvenc` clean**. ## Guardrails (mandatory, plan §14)