Going about mouse collision?

Godot Version

4.6

Question

I’m making a 3D game with a computer screen and I am using a subViewport and a template I found to interact with the gui in 3D. But I want the mouse to stay inside the in-game computer screen, so how would I go about doing this? Do I add collision shapes to the 2D subViewport? I can’t find how anywhere so if someone could help that would be great.

I dont know if mouse can have collision but my rough idea will be:

  1. check position of the mouse
  2. if a coordinate of mouse exceed the boundary, set mouse position to boundary.

Thank you so much! I’ll try and test it out tonight.