Fix duplicated button press event on touch input - #120864
Conversation
|
|
@Nintorch I tested it but can't reproduce that regression. |
There was a problem hiding this comment.
This PR seems to work correctly for me on both Windows and Android, I can reproduce the issue on master but not here.
I'm not sure why this doesn't reintroduce the problem I mentioned earlier, it's possible it could have been fixed by something else besides my PR. But that's good!
This also begs the question: should we really ignore emulated events altogether in BaseButton? Could there be a project that relies on BaseButton reacting to artificial InputEventMouseButton and InputEventMouseMotion events generated by the game code?
But if it's not a big deal, I think this approach looks good!
According to implementation, if The same logic also applies when the user calls So, if the event's device is explicitly set to InputEvent.DEVICE_ID_EMULATION class reference already makes it very clear that it's only for checking physical input. |
|
This also needs to be cherrypicked to 4.7, and |
KoBeWi
left a comment
There was a problem hiding this comment.
I can't test, but the change makes sense.
|
Thanks! |
|
I still think this fix is too broad and not precise enough. Returning early for every
The bug here is specifically about the duplicated mouse event generated from touch input, so I think the fix should distinguish that source instead of treating all emulated events as equivalent. Why not use the more precise approach from my PR? It marks mouse events generated from touch input and makes |
|
Has anyone tested how this interacts with a button_mask set to right click and/or the project setting enable_long_press_as_right_click? |
Yes, but it is documented that DEVICE_ID_EMULATION is used for
The only other emulated event is for
As I said, DEVICE_ID_EMULATION is documented that it's for touch-mouse emulation, so I'd say it shouldn't be resued for any other purpose.
Your PR is essentially doing the same thing. Instead of returning early, it ntroduces a new property and add checks for emulated events. |
Touch events don't have a button mask, so this has no effect on touch input. However, if you have encountered unexpected behavior, please open a bug report. Edit: tested with |
Small correction: my PR does not check for emulated events in general. It checks for mouse events specifically generated from touch input. So difference is not early return vs extra property. Difference is device-wide filtering vs source-specific filtering. I see your point about My concern is where policy is applied. Returning early in That also creates a compat break for user-dispatched I don’t think my PR does same thing. It only marks mouse events generated from touch input, then Bug is specifically “real touch + generated mouse both handled”. So fix can suppress only generated mouse sibling, not all emulated input. |
This compact break is intentional and I think this is only issue. If there's any other behaviour change that you observed then please create a bug report for that. |
Fix duplicated button press event on touch input
|
Despite being minor, maintenance releases aren't the place for compat-breaking changes. I would instead encourage making a dedicated 4.7 PR that documents the issue instead |
Currently touch input and drag input is being handled twice. Once as the screen touch and then below as mouse events.
This PR returns early if
p_event->get_device() == InputEvent::DEVICE_ID_EMULATIONbecause we have logic for handling both screen touch and mouse events, so there's no need for emulated events here.closes #120439