-
Notifications
You must be signed in to change notification settings - Fork 191
fix(MouseHandler): route XButtons (Mouse4/5) as keybinds instead of mouse ownership #2613
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
base: master
Are you sure you want to change the base?
fix(MouseHandler): route XButtons (Mouse4/5) as keybinds instead of mouse ownership #2613
Conversation
…ownership When bound through uikeys, Mouse4/5 (aka XButtons) try to assign ownership to gameInputReceiver. This causes either the mouse input or the X-button bind to be misrouted when pressed in combination. To prevent this, Mouse4/5 are routed like keybinds instead of sharing mouse ownership. This allows them to be pressed/released without stealing or confusing the activeReceiver.
|
Hi! Would you be so kind as to answer a few questions?
Thanks for contributing to Recoils input system! |
Another possible bug this handles is if the player presses LMB down and the activeReceiver is set to anywhere, the release of keybind mouse4 will get sent there and not back to the keybind system So in short, yes, the problem starts in MousePress and is noticed with missed input MouseReleases |
|
Alright, tell me if I understood incorrectly:
While I have assessed in the past the current mouse ownership system is very restrictive and demands some rethinking I have a few points to address:
RemarkSimilar to #2603, in your "Notes / Dependencies" section please provide all context necessary for engine devs to understand without assuming specific BAR knowledge. |
|
This is for allowing the mouse4/5 buttons to work well with the uikeys keybinding system, which currently results in missed inputs when the mouse4/5 buttons are bound, and the LMB RMB etc. are pressed at the same time (a common input) Actually, it doesn't enable Mouse Buildspacing widget, Mouse Buildspacing is already loaded in BAR. That widget also ultimately causes problems when you want to bind mouse4/5 it is aka gui_buildspacing.lua. This has to do with the uikeys.txt keybindings system, specifically for mouse4/5 Here for example LMB can set activeReceiver RecoilEngine/rts/Game/UI/MouseHandler.cpp Lines 377 to 381 in 3f0f87a
Or here for mouse4 when something like "bind mouse4 boxbuild" is in uikeys.txt RecoilEngine/rts/Game/UI/MouseHandler.cpp Lines 366 to 370 in 3f0f87a
Gets set to GameInputReceiver Then on mouserelease (any release, not linked to which button set the receiver) RecoilEngine/rts/Game/UI/MouseHandler.cpp Lines 506 to 513 in 3f0f87a
Since widgets would be working with actions, they would still be affected by the misrouting that causes the bound mouse4 mouserelease to not get sent to GameInputReceiver (as if it's not released), or the LMB to be sent to GameInputReceiver instead of the correct location when pressed in combination |
How specifically? I still don't know how this change interacts with engine and gameside defined actions and bindings. I need further clarification to understand the use case.
Is the
This makes sense. I still require some clarification on the points above but I can anticipate some issues with the ownership model. In particular, assuming we are using engine defined actions and the engine supports the mouse keysets natively, we should send the list of actions on mousepress/mouserelease. This way the game itself can skip the ownership model. With the paragraph above in mind, it's likely some current issue with the ownership model would indeed have to be addressed on the engine. Before reaching that I'd like to understand what and how is the current gameside implementation attempt better as I asked in this message above and in other messages. |
|
Once the mouse4 press gets sent to GameInputReceiver, RecoilEngine/rts/Game/GameInputReceiver.cpp Lines 89 to 105 in 3f0f87a
It consumes the press RecoilEngine/rts/Game/GameInputReceiver.cpp Lines 123 to 134 in 3f0f87a
Resolving the bound action via TryOnPressActions, and because the event was handled, the engine designates GameInputReceiver as the activeReceiver. These are on the engine side. It's not really about the fact that the press is or is not consumed when bound using uikeys (though it would have to be consumed for the release event to reach the action system currently) By routing them in a focused, isolated path, mouse4/5 behave like keybinds in that they are sent to receivers in order and do not interact with other key press and release events, other than optionally stopping further propagation of just their own event, down the route, by consuming the press. The receivers don't "subscribe" to the release event of the key; it's a broadcast model |
|
Looks good. Some remarks:
Provisional +1 from me but I would still like @badosu's feedback. |
Summary
Adjusts MouseHandler so that XButtons (Mouse4/5) are routed like keybinds instead of sharing mouse ownership.
Rationale
When bound through uikeys, Mouse4/5 attempt to assign ownership to
GameInputReceiver. This causes misrouting when pressed in combination with other mouse inputs. By routing them through the keybind path and bypassing ownership, XButtons can be pressed/released without stealing or confusing the active receiver.Scope
MouseHandler.cppTesting
Notes / Dependencies
Mouse Buildspacingwidget currently hardcodes MOUSE4/MOUSE5 for buildspacing changes; it should be disabled if testing MOUSE4/MOUSE5 with the uikeys system.gui_buildspacing.lua