First person mouse movement is jittery

I am making an FPS game and I noticed the mouse inputs are slightly stuttery, and for some frames will be 0 even though I am moving the mouse.
For example, I printed the mouse movement every frame and got something that looked like:

(-0.34188, 0)
(-0.2849, 0)
(-0.34188, 0)
(-0.2849, 0)
(-0.34188, 0)
(0, 0) <— skips a frame
(-0.2849, 0)
(-0.34188, 0)
(-0.2849, 0)
(-0.34188, 0)
(-0.34188, 0)

This slight jitteriness causes the movement to also be jittery which is really noticeable and janky looking. I would like to specify that my mouse mode is set to captured and accumulated input is set to false (although I noticed the issue regardless of whether it was true or false)

This is the code that I use to handle the mouse input:

func _unhandled_input(event) -> void:
	if event is InputEventMouseMotion:
		r += event.relative * sens * SENS_CONSTANT

and in the _process function:

func _process(delta : float) -> void:
	cam.rotation_degrees.x = clamp(cam.rotation_degrees.x - r.y, -90, 90)
	cam.rotation_degrees.y = cam.rotation_degrees.y - r.x
	print(r)
	r = Vector2.ZERO

But im not even sure if the problem is the (0, 0) frames. I tried to make it so if the mouse input randomly switches to (0, 0) for one frame, it will use the previous mouse motion instead:

func _process(delta : float) -> void:
	if og_r == Vector2.ZERO and not one_frame:
		one_frame = true
	else:
		r = og_r
	if og_r != Vector2.ZERO:
		one_frame = false
	cam.rotation_degrees.x = clamp(cam.rotation_degrees.x - r.y, -90, 90)
	cam.rotation_degrees.y = cam.rotation_degrees.y - r.x
	og_r = Vector2.ZERO

But it’s still jittery. I really don’t know what else I could do. Does anyone know how to fix this?

Why don’t you apply the mouse input in the _input function? Why wait until _process?

It was like that before (still jittery) and i tried the method of applying it in the _process to try to fix it. Either way it’s kind of the same thing if you think about it.

If you don’t see this in other applications, try slotting Input.use_accumulated_input = false in a _ready function, should give you more data at least.

Sorry if this is a dumb question, but what exactly does slotting Input.use_accumulated_input = false mean?

By default Godot accumulates input, instead of sending a _input function for every little jitter it will add up mouse movements and what not, then call _input about every frame.

That’s why I find your sample strange, it’s doing this work twice.

Well i already have Input.use_accumulated_input = false

Ah maybe enable it then lol. How are sens and SENS_CONSTANT defined?

I tried with it enabled too, but the issue persisted. sens is a value that remains constant but is set in the game’s settings and SENS_CONSTANT = 0.022. Something really weird I forgot to mention is that I could have sworn that I didn’t have this issue before when working on this game and that this is a new thing, but when I reverted to a much older version, the issue was still there. Either I just didn’t notice it back then, or maybe it’s something wrong with my computer or my mouse? But that is strange because I don’t have any issues on any other FPS games I play.

actually nevermind it could be a hardware issue I think I might have noticed some stuttering in some other games. oops