Capture mouse on dual monitors? (GLFW3)

Monkey Targets Forums/Desktop/Capture mouse on dual monitors? (GLFW3)

DeadFall(Posted 2015) [#1]
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.


k.o.g.(Posted 2015) [#2]
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




DeadFall(Posted 2015) [#3]
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.


k.o.g.(Posted 2015) [#4]
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


DeadFall(Posted 2015) [#5]
I've actually tried it with #MOJO_AUTO_SUSPEND_ENABLED = False still didn't work.


k.o.g.(Posted 2015) [#6]
something like this?
https://msdn.microsoft.com/en-us/library/windows/desktop/ms648383(v=vs.85).aspx


DeadFall(Posted 2015) [#7]
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.


k.o.g.(Posted 2015) [#8]
I don't find any alternative for the other OS's :/ sorry!


DeadFall(Posted 2015) [#9]
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.


Nobuyuki(Posted 2015) [#10]
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!