Skip to content

Tauri desktop build via a Hardware Abstraction Layer - #97

Open
KeyboardNoMouse wants to merge 4 commits into
OpenMouse-Project:mainfrom
KeyboardNoMouse:main
Open

Tauri desktop build via a Hardware Abstraction Layer#97
KeyboardNoMouse wants to merge 4 commits into
OpenMouse-Project:mainfrom
KeyboardNoMouse:main

Conversation

@KeyboardNoMouse

Copy link
Copy Markdown

Desktop app (Tauri)
src-tauri/ wraps the frontend in a Tauri shell so DPI/polling-rate control works outside Chrome/Edge — where navigator.hid doesn't exist at all (Firefox, Safari) or is blocked (most embedded webviews, including Tauri's own). Hardware access goes through src/hardware/:

bridge.ts picks a transport once at startup by checking for window.TAURI_INTERNALS.
webHID.ts wraps navigator.hid directly (browser build).
native.ts proxies the same HIDDevice/HID shape over Tauri invoke() to src-tauri/src/hid/commands.rs, which talks to hardware via the hidapi crate.
Everywhere else in the app — every *-hid.ts driver, control.ts — reads hid from bridge.ts instead of touching navigator.hid. Adding a new mouse profile only ever means writing -hid.ts against the HIDDevice interface, same as before; it runs on both targets without change.

npm install
npm run desktop:dev # tauri dev — spawns vite, opens a native window
npm run desktop:build # tauri build — produces an installer in src-tauri/target
Desktop build prerequisites (not needed for npm run dev/npm run build):

A Rust toolchain (rustup) — see tauri.app/start/prerequisites.
Linux only: libudev-dev (hidapi's hidraw backend links against it) plus Tauri's own webview/build dependencies from the prerequisites page above.
macOS: the first time the app opens a mouse, macOS may prompt for Input Monitoring access under System Settings → Privacy & Security — this is an OS-level prompt, not something this app controls.
Known gap: control-app.html (the actual control panel) is currently gated by functions/_middleware.js, a Cloudflare Pages Function that checks a Supabase session cookie. That function doesn't run inside the Tauri webview — there's no Cloudflare edge runtime locally — so the desktop build as configured serves control-app.html unconditionally, bypassing the license check entirely. Decide how the desktop build should handle licensing (e.g. call /api/license/activate directly over the network and cache the resulting session) before shipping a build.

Known gap: src-tauri/src/hid/descriptor.rs parses the raw HID report descriptor into the same collections tree HIDDevice.collections exposes in a browser, since several drivers' isSupported() checks walk that tree. It was written without a Rust toolchain available to compile or test it — review it against a real descriptor dump for each supported mouse before relying on it.

@KeyboardNoMouse

Copy link
Copy Markdown
Author

Close the PR if u dont like the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant