I'm on Rust compiled to Chrome/wasm32. I have a canvas that is rendering via wgpu.
I would like to hide + "lock" the cursor (as one would expect a FPS style game to).
I am trying:
// window: winit:;window::Window
web_sys::console::log_1(&"hiding cursor".into());
window.set_cursor_grab(CursorGrabMode::Confined)
.or_else(|_e| window.set_cursor_grab(CursorGrabMode::Locked))
.unwrap();
window.set_cursor_visible(false);
It is doing nothing. The "hiding cursor" line appears in Google chrome dev console, but the cursor is neither hidden nor locked in the web browser.
Question: am I (1) calling the wrong functions or (2) calling the right functions but in the wrong place or (3) need some other magical incantation to hide + lock more cursor ?
Thanks!