godotengine / godotengine/godot

InputEventMouseMotion event firing when pressing and releasing mouse buttons while holding other mouse buttons and not moving the mouse in web

Open
#118,908 6 comments 0 reactions 0 assignees View on GitHub
bug platform:web topic:input topic:platforms
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in: 4.7.dev5, 4.7.dev1, 4.5.stable, 4.5.beta3, 4.5.beta1
- Not reproducible in: 4.5.dev5, 4.5.dev1, 4.4.1.stable, 4.4.stable, 4.3.stable, 4.0.stable

Bug introduced in 4.5.beta1

### System information

Godot v4.7.dev5 - Fedora Linux 43 (Workstation Edition) on Wayland - X11 display driver, Single-window, 3 monitors - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 3080 (nvidia; 580.142) - 12th Gen Intel(R) Core(TM) i5-12400F (12 threads) - 31.14 GiB memory

### Issue description

InputEventMouseMotion is being fired when just mouse buttons are being pressed and released while other mouse buttons are being held, all the while holding the mouse in mid-air, making sure there's no movement.

For example, when holding left mouse button and pressing right mouse button InputEventMouseMotion fires, the same happens when adding the scroll wheel into the mix.

It's weird, when holding the left mouse button and pressing the right mouse button, the event is printed as such:
```
InputEventMouseMotion: button_mask=1 (Left Mouse Button), position=((1264.0, 229.0)), relative=((0.0, 0.0)), velocity=((0.0, 0.0)), pressure=0.50, tilt=((0.0, 0.0)), pen_inverted=(false)
```

Then when releasing the right mouse button, the event is printed like such:
```
InputEventMouseMotion: button_mask=3 (Left Mouse Button) (Right Mouse Button), position=((1264.0, 229.0)), relative=((0.0, 0.0)), velocity=((0.0, 0.0)), pressure=0.50, tilt=((0.0, 0.0)), pen_inverted=(false)
```

It's weird that if you move your mouse a bit before lifting and testing clicks, the first printed Output will have velocity like this:
```
InputEventMouseMotion: button_mask=1 (Left Mouse Button), position=((997.0, 350.0)), relative=((0.0, 0.0)), velocity=((-89.57668, 69.10201)), pressure=0.50, tilt=((0.0, 0.0)), pen_inverted=(false)
```

Also you'll see that pressure is set to 0.50, I don't know if that's a bug on it's own.

All Tested Versions were done on both Firefox 149.0.2 (64-bit) and Google Chrome Version 147.0.7727.116 (Official Build) (64-bit). Both acted the same.

### Steps to reproduce

Steps to reproduce
1. Create project with compatibility renderer
2. Create a new scene with a Node3D as root (I don't believe the node type matters, I just used Node3D for consistency)
3. Attach a script with code:
```gdscript
extends Node3D

func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
if event.button_mask != 0:
print(event)
```
4. Run project in browser with Remote Deploy - Run in Browser (Shift+F5)
5. Pickup your mouse so it isn't touching anything making sure it's sensor doesn't pick up movement
6. Hold the left mouse button and press the right mouse button. Try it with other mouse button combinations, even with the scroll wheel press.
7. Look at Output in Godot, or open the dev tools for your browser and look at console and look at the output.
8. You should see that InputEventMouseMotion event is being fired even though there is no mouse motion happening, only mouse button pressing.

### Minimal reproduction project (MRP)

[4_5_beta1-MRP.zip](https://github.com/user-attachments/files/27035533/4_5_beta1-MRP.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the supplied minimal reproduction project and the GDScript _input handler, then reproduce it in a browser using Remote Deploy with the listed mouse-button combinations. Compare browser console and Godot Output events, and trace the web input path to determine why button presses produce zero-motion InputEventMouseMotion events; done means those events no longer fire without movement while genuine motion remains reported.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.