Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture cursor #220

Open
LoganDark opened this issue Oct 4, 2020 · 10 comments
Open

Capture cursor #220

LoganDark opened this issue Oct 4, 2020 · 10 comments

Comments

@LoganDark
Copy link
Contributor

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?

@emoon
Copy link
Owner

emoon commented Oct 4, 2020

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?

@LoganDark
Copy link
Contributor Author

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.

@emoon
Copy link
Owner

emoon commented Oct 4, 2020

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

@LoganDark
Copy link
Contributor Author

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
Copy link
Contributor Author

LoganDark commented Oct 4, 2020

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

@emoon
Copy link
Owner

emoon commented Oct 4, 2020

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.

@LoganDark
Copy link
Contributor Author

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.

@arvsrn
Copy link

arvsrn commented Jun 13, 2023

Is setting cursor position still unsupported?

@emoon
Copy link
Owner

emoon commented Jun 13, 2023

Yes, it's still unsupported.

@arvsrn
Copy link

arvsrn commented Jun 13, 2023

I wrote a function for windows and made a PR: #321

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

No branches or pull requests

3 participants