-
Notifications
You must be signed in to change notification settings - Fork 17
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
No way to disable mouse move event capture. #27
Comments
I'm pretty sure you have to capture all events - I don't think the windows api lets you selectively listen. Allocations are likely due to the class vs struct nature of things which can't really be changed. |
Instead of preventing the capture, what could be done is to just ignore the event and not do any processing if it's a mouse move event. I have made some tests. The two parts that cause the memory allocations are :
So instead of doing :
We could do something like (we check the type of event from the callback data) :
The logic to interpret the type of event (for the CheckIgnoredEvent function) is in MouseEventSourceState.cs : |
This is a great analysis! Here my thoughts: It has been a long time since I wrote a lot of this code, and I would honestly be concerned about making too many changes to it. As you look at things, you will notice that it has the ability to capture events, and then replay them! That was no easy feat! Anyways, I noticed that the method that you wanted to optimize was virtual so you could do your own custom filtering directly in it. Does that work? I would be much more open to enabling you to override a method, then implementing an optimization specific to avoid allocations. |
Thanks for the fast replies. I appreciate your work! It would be indeed great to have the ability to override the callback method and possibly being able to call the original callback method from the overriding one. |
Hello, I only need to capture mouse button inputs. All events are captured and dispatched when using the following :
WindowsInput.Capture.Global.MouseAsync(true);
The issue I have with mouse move events being captured is that it triggers a ton of events and a lot of memory allocations.
Example after a few seconds of moving the mouse :
The 2 spikes are memory allocations due to moving the mouse, after I stop moving the mouse.
Stack trace of relevant memory allocations (over a few seconds) :
I believe it would be nice to have a way to disable the capture of mouse move events as it adds a ton of overhead.
The text was updated successfully, but these errors were encountered: