rust_minifb icon indicating copy to clipboard operation
rust_minifb copied to clipboard

Capture cursor

Open LoganDark opened this issue 3 years ago • 10 comments

I'd like a way to capture the cursor inside the window (to the center, like some games), is it possible for this feature to be added to minifb?

LoganDark avatar Oct 04 '20 07:10 LoganDark

It's certainly possible, but not something I have planned to do. Would it be possible for you to do a PR with this feature?

emoon avatar Oct 04 '20 08:10 emoon

Not sure, especially because I have to reboot to access other OSes and I'm currently focused on another project. I suppose I could just use click and drag instead of cursor locking.

LoganDark avatar Oct 04 '20 08:10 LoganDark

So exactly what do you need to support this? a set_cursor_pos would do the trick?

emoon avatar Oct 04 '20 09:10 emoon

I suppose it could be hacked together by setting the cursor position every frame, yeah. But, I would prefer to use the OS's cursor locking.

LoganDark avatar Oct 04 '20 09:10 LoganDark

Also, I just ran into a weird bug where there is a blank space at the top of the window.

image

That has absolutely nothing to do with this, but here it is.

image

LoganDark avatar Oct 04 '20 09:10 LoganDark

I think many games actually just set the cursor pos actually (that is because in an FPS you want to detect the direction the user switches the mouse and then you move it back to the center after detecting it)

Unsure what the issue above is, likely something with client area of the window being calculated wrong or something like.

emoon avatar Oct 04 '20 09:10 emoon

I think many games actually just set the cursor pos actually (that is because in an FPS you want to detect the direction the user switches the mouse and then you move it back to the center after detecting it)

Well, it will probably work just fine :P

likely something with client area of the window being calculated wrong

The window's detected correctly, that's why the buffer is the right size, but the positioning of the buffer gets screwed up.

LoganDark avatar Oct 04 '20 09:10 LoganDark

Is setting cursor position still unsupported?

arvsrn avatar Jun 13 '23 14:06 arvsrn

Yes, it's still unsupported.

emoon avatar Jun 13 '23 15:06 emoon

I wrote a function for windows and made a PR: https://github.com/emoon/rust_minifb/pull/321

arvsrn avatar Jun 13 '23 15:06 arvsrn