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

Lock mouse #43

Closed
shauder opened this issue Feb 28, 2014 · 16 comments
Closed

Lock mouse #43

shauder opened this issue Feb 28, 2014 · 16 comments

Comments

@shauder
Copy link

shauder commented Feb 28, 2014

This program works great I only have one suggestion. On multiple monitors my mouse does not lock in the game. So in WC3 when I need to use the mouse to move the screen it will go off game into the second monitor.

@madpew
Copy link
Contributor

madpew commented Mar 1, 2014

If you want your game to use a whole screen AND catch your mouse, why aren't you playing it in normal fullscreen? As far as I know the only reason to go borderless IS to have the game fullscreen and still be able to move your mouse to the other monitors. I might be missing something so please clarify.

@shauder
Copy link
Author

shauder commented Mar 1, 2014

There are more reasons for wanting it. Mainly it will load the rest of the desktop faster and I can see the game and what is going on when I am on the desktop (two monitors). I can alt-tab quicker. Basically the mouse should lock into the app until I alt tab then I can user other apps.

@andrewmd5
Copy link
Collaborator

Mouse locking is left up to the developers of the game, there is no way I
know of in the WinAPI to bind your mouse to a specific window.

On Sat, Mar 1, 2014 at 7:08 AM, Shane A. Faulkner
notifications@github.comwrote:

Umm there are more reasons for wanting it. Mainly it will load the rest of
the desktop faster and I can see the game and what is going on when I am on
the desktop (two monitors). I can alt-tab quicker. Basically the mouse
should lock into the app until I alt tab then I can user other apps.

Reply to this email directly or view it on GitHubhttps://github.com//issues/43#issuecomment-36423160
.

@shauder
Copy link
Author

shauder commented Mar 1, 2014

There actually is a way. Check out this utility. The only problem I have with this one is it locks it 1 or 2 pixels to far and doesn't work if u move the mouse too fast.

http://dotautilities-forums.net/Thread-Tool-Warcraft-III-Runner

@shauder
Copy link
Author

shauder commented Mar 1, 2014

And it may not be in the WinAPI I just know that this guy found a way to do it,

@madpew
Copy link
Contributor

madpew commented Mar 1, 2014

There is an WinAPI Function called ClipCursor that does limit the mousecursor to a given rectangle. If we use the rectangle of the screen the window is on it should work. However this is a global change, so we'd need to figure out a reliable way to enable/disable this on window-switching. polling the currently active window could work. If noone else does I might take a look at this.

@shauder
Copy link
Author

shauder commented Mar 1, 2014

The way the app that I linked does it is it allows you to set scroll lock to the hotkey that enables and disables it. Thanks for looking into it.

@madpew
Copy link
Contributor

madpew commented Mar 5, 2014

Good news, I investigated and got this working. The hotkey will work on both bordered and borderless windows. I'll clean up my changes and upload a test-release on my fork. Would you be willing to test it before pushing the changes to master?

@shauder
Copy link
Author

shauder commented Mar 5, 2014

Awesome, thank you for doing this! I would be more than willing to test it out.

@madpew
Copy link
Contributor

madpew commented Mar 5, 2014

Ok, I uploaded the version here: http://behind.at/tmp/BorderlessGaming-6-mouselock.zip
Tested and working with KillingFloor.

To test, you need to enable the mouselock-hotkey in the options, select your game and press Scrolllock. This should clip the mouse to your window. Pressing Scrolllock again unlocks the cursor (also windows automatically unlocks the cursor on specific events like alt-tab for example. Due to this you need to press scrolllock twice to re-capture the cursor after its lost.)

@shauder
Copy link
Author

shauder commented Mar 5, 2014

Fantastic! As soon as I'm home from work I will test it and let you know

@shauder
Copy link
Author

shauder commented Mar 5, 2014

Great job man it works perfectly and even better than the one I had linked as an example! My mouse does not leave the screen with this if I go very fast. The alt-tab is awesome also - great job! The only suggestion I have (if even possible) is re-locking the mouse when the app gets refocused after alt-tab. However, it is not really that needed and pressing the hotkey again twice is no biggy! Thank you again.

@madpew
Copy link
Contributor

madpew commented Mar 5, 2014

Automatic re-locking is (sadly) not possible, but I added a simple fix so it's not needed to press the hotkey twice after loosing the lock.
Thank you for testing and suggesting this feature. I'll submit a pull request and if @Codeusa is ok with it, this feature should end up in the next release.

@shauder
Copy link
Author

shauder commented Mar 5, 2014

I'd maybe leave leave it to the double press because it keeps the scroll lock at the same on state. But it is up to you and what you think is better, thank you!

@madpew
Copy link
Contributor

madpew commented Mar 22, 2014

the implementation got merged and this issue can be closed.

@shauder shauder closed this as completed Mar 26, 2014
@fadster
Copy link

fadster commented Apr 7, 2016

This feature is not working for me. Hitting scroll lock with the option enabled does not lock the pointer to the game's monitor.

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

4 participants