How do i lock cursor?

How do i lock cursor in Game screen in Blender?

I do not understand what you mean by “lock”, but if you want to show / hide the cursor, then go to:

Properties window —>

Render window (the first one with the camera icon) —> Display =

It has a tick mark “Cursor”, to turn the cursor on or off when your game is playing.

Lock as in it does not hover out of in game screen!

A - setMousePosition to screen center each frame and get diff from center
set real mouse cursor invisible

use this input to move your own ‘virtual’ mouse around inside the window
(typically you have to move a object in a overlay and cast rays on main based on the screen position of the mouse)

logic.mouse.position = (0.5, 0.5)