Here is my code. I wanted to prevent the mouse stopping me being able to move the gun when it leaves the screen bounds in windowed mode. Also, if the mouse reached the edge of the screen in fullscreen I wanted the gun to still rotate with the mouse movement.
obj_m4a1_obj = LoadObject( "m4a1.3ds" )
tex1 = LoadImage("m4skin2.jpg")
SetObjectMeshImage(obj_m4a1_obj, 1, tex1, 0)
SetObjectScale(obj_m4a1_obj, 0.05, 0.05, 0.05)
SetObjectRotation(obj_m4a1_obj, 0, 180, 0)
SetRawMouseVisible(0)
do
local mx as float
local my as float
mx = -GetRawMouseY()
my = GetRawMouseX()
if my > 300
my = 300
endif
if my < -300
my = -300
endif
if mx > -150
mx = -150
endif
if mx < -300
mx = -300
endif
SetObjectRotation(obj_m4a1_obj, mx / 20.0, 180 + my / 20.0, 0)
Print( my)
Print( mx)
Sync()
loop
Imaginations' greatest gift is the knowledge you supply it.