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

add MessageFilter to selectively block window message #183

Merged
merged 7 commits into from
May 8, 2024

Conversation

ruby3141
Copy link
Contributor

This PR introduces BREANKING changes described below;

  • add MessageFilter to selectively block window message
    Blocking every window message blocks intentional user actions like minimizing, closing(Alt-F4 doesn't work either), resizing, etc.
    This commit fixes that kind of problem by providing bitflag interface to block certain predefined range of window messages.
    To block every messages like before, you can return MessageFilter::all() on set_message_filter().

This PR fixes #182.

Blocking every window message blocks intentional user actions
like minimizing, closing(Alt-F4 doesn't work either), resizing etc.

This commit fixes that kind of problem by providing bitflag interface
to block certain predefined range of window messages.

To block every messages like before,
you can return `MessageFilter::all()` on `set_message_filter()`.
@veeenu
Copy link
Owner

veeenu commented Apr 16, 2024

Thank you for your contribution! 🙏
Please allow me a bit of time to thoroughly review this, but I like what I've seen so far.

Copy link
Owner

@veeenu veeenu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. I like this!

I'd like to have a few changes but otherwise this looks good. Also, could you please implement the new method in the test hook? This would be helpful both to users looking for an example and to us to check that the thing works correctly. Could e.g. ignore events according to time elapsed from first_time (2s ignore keyboard, 4s ignore mouse etc).

ruby3141 added 5 commits May 7, 2024 14:09
There was some perspective mistake during naming the method.
It's getter for pipeline, not setter for user code.
The method would(and maybe should) not be used in user code,
so make it protected seems good idea.
- Explanation about using MessageFilter is added.
- Wrap consts like `WM_USER` with backticks(`)
Harness doesn't seem to handle any input events,
so only thing we can simply test is `MessageFilter::WindowControl`
@ruby3141 ruby3141 requested a review from veeenu May 7, 2024 07:22
@ruby3141
Copy link
Contributor Author

ruby3141 commented May 7, 2024

In addition to your change requests, I made MessageFilter::is_blocking() pub(crate),
because it would not be used in user code.

Test for only MessageFilter::WindowControl is added to the test hook, because harness itself doesn't seems to handle any input.

@ruby3141
Copy link
Contributor Author

ruby3141 commented May 7, 2024

out.webm

Copy link
Owner

@veeenu veeenu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thank you again! 🙌

(p.s. what font is that in your editor? I like it!)

@ruby3141
Copy link
Contributor Author

ruby3141 commented May 8, 2024

The font is NeoDunggeunmo Code.
It's one of a few programming fonts that natively supports korean glyphs, and because of its bitmap appearance and square sizing it matches very well with unifont fallback.

@veeenu veeenu merged commit e34f748 into veeenu:main May 8, 2024
1 check passed
@Godnoken
Copy link
Contributor

Godnoken commented Feb 13, 2025

Oi oi!

I've just recently started working on my application again.

I'm quite hesitant to spend time bumping up since I ended up changing a lot of code in my own local hudhook repo and I haven't had the chance to try newer versions of hudhook yet, but I'm wondering if this PR made it possible to completely block all input to games?

P.S.
I've been following the development with one eye for over 1.5 years, happy to see that it has been going strong! :)


Can confirm that while it does block click-throughs etc, it doesn't block mouse hovering input. Not sure if this current solution could cover that as well? I can barely remember how my own code does it lol.

@veeenu
Copy link
Owner

veeenu commented Feb 16, 2025

Hey, welcome back @Godnoken! 🙌

This specifically did not solve my own issue with Souls games but the likely reason is that the input isn't sourced via windows events at all, nor GetKeyState, and it's instead directinput or something like that which I haven't looked into yet. Games that do that should for now add their own hook implementations, I'm not opposed to upstreaming that kind of functionality for common cases though.

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

Successfully merging this pull request may close these issues.

need ways to filter certain windows message, without blocking everything
3 participants