Fix for a mouse hook conflict with games which capture mouse inside their window#459
Draft
mezotaken wants to merge 3 commits into
Draft
Fix for a mouse hook conflict with games which capture mouse inside their window#459mezotaken wants to merge 3 commits into
mezotaken wants to merge 3 commits into
Conversation
a101817 to
15e8f56
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There have been quite a lot of issues created about this problem.
#439 #438 #411 #388 #363 #355 #327 #321 #302 #255 #221 #207 #195 #184 #163 #125 #97 #61
Whenever certain apps (mostly games) capture the mouse with their hook to prevent it from leaving the window, the LBM hook is starting to conflict with the game hook. Previously proposed solution with manually excluding processes was incredibly tedious, so i've found a way to incorporate this check into the LBM hook.
It works like this:
Any time user switches focus, an event fires in the LBM hook process. This was already present in the code, so I used it to make a deferred check (about a second later) if the focus didn't change still. So if it was stable for this second, we test if mouse was clipped by a virtual screen, which correlates with mouse capture from at least some UE games (i didn't test most of them yet, that would be great to see reports). So when we see that we have a stable window which clips your mouse area, we pause the daemon. Main reason for delay is that Windows processes the clipping slightly later than the refocus event itself, so the delay makes it much more robust.
Whenever we switch back and focus is again stable for a second, I unpause the hook, so the app can continue working.
There were difficulties with building the app completely from source, its UI project is a bit broken, but luckily anyone who wants this fixed without the merge and subsequent new release only needs
LittleBigMouse.Hook.exereplaced in the installation folder.https://github.com/mezotaken/LittleBigMouse/actions/runs/27840207182
Here's the version i've built on github actions with an artifact that contains fixed
LittleBigMouse.Hook.exefile (it's in my fork since there is no permission to run workflows here for a first time contributor)Feedback on effectiveness of this would be great. As soon as the upstream override will be fixed (HLab.Avalonia) so this repo could be built completely, this PR can be marked as ready for review.