Capture mouse on dual monitors? (GLFW3)
Monkey Targets Forums/Desktop/Capture mouse on dual monitors? (GLFW3)
| ||
I'm trying to prevent my mouse from being able to go on my other monitor while in fullscreen. Any help given would be appreciated. |
| ||
The only way i think is to reset the mouse position with an native os command. Windows API: https://msdn.microsoft.com/en-us/library/windows/desktop/ms648394(v=vs.85).aspx Pseudo: if MouseX() < 0 SetMousePosition(0,MouseY()) maybe diddy has this function already wrapped? *edit* glfw has an function: glfwSetMousePos |
| ||
I actually already have something similar to that but once the mouse is out of the window it stops updating so it wont see that MouseX is > DeviceWidth. I've done other tests that are like this to see if the repositioning code was actually working, If MouseX() > DeviceWidth-25 then SetMouse(DeviceWidth-25,y) Which works up until you move the mouse fast enough past the screen which then is back to square one where MouseX isn't being updated again so the game doesn't see that it's past the DeviceWidth. So I'm sort of stumped on the problem. |
| ||
When the window lost his focus and you didn't have #MOJO_AUTO_SUSPEND_ENABLED = False, the application goes to an supsended mode. So you have no chance to update i think. maybe that someone else has an idea |
| ||
I've actually tried it with #MOJO_AUTO_SUSPEND_ENABLED = False still didn't work. |
| ||
something like this? https://msdn.microsoft.com/en-us/library/windows/desktop/ms648383(v=vs.85).aspx |
| ||
That works thanks! I was trying to also dig around the GLFW library stuff too but didn't find anything that matched the one you linked. But if you know one for that would be nice to know about too. |
| ||
I don't find any alternative for the other OS's :/ sorry! |
| ||
That's alright I'm sure I'll figure something out. PC is my main focus right now so having that working helps out a lot. |
| ||
Did you guys try a "Last chance" event on OnSuspend() ? I noticed that without a custom captive pointer, doing position resets on the OS pointer while the app is in focus has its limits in multi-monitor, and even professionally-designed games have this problem (Source engine games for example). If you scroll out of context and accidentally "click out" of the window's area before the next update cycle, the app loses focus, even in full screen! |