How to confine mouse to a (minifb) window?

I'm writing a 2.5D Wolfenstein style raycasting engine. I'm using the minifb crate to draw pixels onto the screen.

It's working fine - it is currently controlled via a keyboard, but I would like to implement mouse look (use mouse to rotate the camera).

Minifb has get_mouse_down which allows me to grab the mouse cursor position, but I cannot force the cursor to stay in the window, I also can't hide the cursor. (I would need those 2 things to implement mouse-look like in modern FPS games).

I want the mouse cursor to disappear when the user clicks on the window created by my program. The program will than read relative mouse movements (from the window center or something), which I than use to rotate the camera.

GGEZ seems to support this feature, but I don't want to use that whole big library, just for this one functionality. The mouse_rs crate also exists, but I don't think it can help with this.

Mouse-look can be done in Python using pygame like so:


# And than

Does anybody have any tips, how to do that?

*P.S. - Sorry, can only include 2 links :frowning: *

Here is my code:

It seems that minifb does not have this feature:

Yeah, that's what I was afraid...
Thanks anyways

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.